Module:Krazy Wordz

From Vassal
KrazyWordz.jpg
Publisher Ravensburger Spieleverlag GmbH Era Contemporary
Year 2016 Topic Humor
Players 3 to 7 Scale Abstract
Length 45 min

Files

Files have been removed at request of module creator


Module Information

Maintainer Peter8Elf
Contributors Peter8Elf

Comments

First full Version of the crazy word guessing game. Official Rules can be found here.

Also a QuickStart is available how to play the game in Vassal. (Help -> QuickStart, when module is loaded)

Important: You need to load a card deck inside the game. The game itself has not cards by default. (see also Screenshots)

To easily create your own Card Decks with custom words see #Creating a Card Deck for Krazy Wordz

Creating a Card Deck for Krazy Wordz

The following Powershell Script can be used to convert a text file with a line for each card content to a Vassal Card Deck.

Run the script in a folder with a file called "cards.txt" which will then converted in a "cards.vdck" file that can be loaded.

function Word-Wrap {
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
        [string[]]$Text,
        [int]$MaxWidth=$Host.UI.RawUI.BufferSize.Width,
        [int]$Indent,
        [switch]$PadMax
    )

    Process {

        # setup our return array
        $retLines = @()

        if ($Indent) { $MaxWidth -= $Indent }

        foreach ($origString in $Text) {
            Write-Debug "Top length $($origString.Length)"

            # because we may be indenting, we need to care about embedded NewLine
            # characters and insert the indent for each one
            foreach ($line in $origString.Split([Environment]::NewLine)) {
                Write-Debug "new outer line"

                while ($line.Length -gt $MaxWidth) {
                    $newLine = ''

                    # copy a maxWidth+1 chunk
                    $chunk = $line.Substring(0,$MaxWidth+1)
                    $lastSpaceIndex = $chunk.LastIndexOf(' ')
                    Write-Debug "chunk length $($chunk.length) and space index $lastSpaceIndex"

                    if ($lastSpaceIndex -le 0) {
                        # no natural spaces to split, so just split on max width
                        $lastSpaceIndex = $MaxWidth
                    }

                    # grab the piece we need, pad and indent if necessary,
                    # and add it to the output
                    $newLine = $chunk.Substring(0,$lastSpaceIndex)
                    if ($PadMax) { $newLine = $newLine.PadRight($MaxWidth) }
                    if ($Indent) { $newLine = "$(' ' * $Indent)$newLine" }
                    $retLines += $newLine

                    # remove the piece from current line
                    $line = $line.Substring($lastSpaceIndex + 1)
                }

                Write-Debug "last chunk length $($line.length)"
                # pad and indent if necessary and add the last piece to the output
                if ($PadMax) { $line = $line.PadRight($MaxWidth) }
                if ($Indent) { $line = "$(' ' * $Indent)$line" }
                $retLines += $line
            }

        }
        $retLines
    }

    <#
    .SYNOPSIS
        Attempts to wrap a string or array of strings at the word boundary given a maximum width.
 
    .PARAMETER Text
        A string or an array of strings.
 
    .PARAMETER MaxWidth
        The maximum characters per line.
 
    .PARAMETER Indent
        The number of characters to indent each line.
 
    .PARAMETER PadMax
        If set, each line will be padded with spaces on the right with enough to reach -MaxWidth.
 
    .EXAMPLE
        Word-Wrap $longString
 
        Word wrap $longString to the max console width.
 
    .EXAMPLE
        $longString | Word-Wrap -max 100 -indent 4 -pad
 
        Word wrap $longString to 100 characters with a 4 character indent and right padding.
    #>
}

$FileBegin = "DECK	"
$ESCChar = [char]27
$CardBegin = $ESCChar + "+/null/obs;;TermCardBack.png;;GTermCardBack.png;?;player:;Peek	"
$CardEnd = "	null;85;74;%ID%;0"
$CardOneLine = "label;;;12;;0,0,0;c;0;c;0;c;c;;Dialog;0;0;;\	piece;;;TermCardFront.png;Term/null;	%Line1%\"
$CardTwoLines = "label;;;12;;0,0,0;c;10;c;0;c;c;;Dialog;0;0;;\	label;;;12;;0,0,0;c;-10;c;0;c;c;;Dialog;0;0;;\\	piece;;;TermCardFront.png;Term/null;	%Line2%\	%Line1%\\"
$CardThreeLines = "label;;;12;;0,0,0;c;20;c;0;c;c;;Dialog;0;0;;\	label;;;12;;0,0,0;c;0;c;0;c;c;;Dialog;0;0;;\\	label;;;12;;0,0,0;c;-20;c;0;c;c;;Dialog;0;0;;\\\	piece;;;TermCardFront.png;Term/null;	%Line3%\	%Line2%\\	%Line1%\\\"

$FileContent = $FileBegin
$ID = 1000

foreach($line in Get-Content .\cards.txt) {
    $FileContent += $CardBegin

    $CardLines = Word-Wrap $line -MaxWidth 20

    if($CardLines.Count -eq 1)
    {
        $FileContent += $CardOneLine.Replace("%Line1%", $line)
    }
    elseif ($CardLines.Count -eq 2)
    {
        $FileContent += $CardTwoLines.Replace("%Line1%", $CardLines[0]).Replace("%Line2%", $CardLines[1])
    }
    elseif ($CardLines.Count -eq 3)
    {
        $FileContent += $CardThreeLines.Replace("%Line1%", $CardLines[0]).Replace("%Line2%", $CardLines[1]).Replace("%Line3%", $CardLines[2])
    }
    else
    {
        Write-Error "Text is too long: " + $line
    }

    $FileContent += $CardEnd.Replace("%ID%", $ID)
    $ID += 1
}

Set-Content -Path .\cards.vdck -Value $FileContent

Screen Shots

Players

  • Peter8Elf