Minigame Scripting
Game sessions are bound to a game board (action location) and identified by a unique name. The name of the game board is defined in the action_locations table (name field). The game itself is defined in the gameboards db table.
Database Entry
name VARCHAR(30) NOT NULL, numColumns INTEGER UNSIGNED NOT NULL, numRows INTEGER UNSIGNED NOT NULL, layout TEXT NOT NULL, pieces TEXT NOT NULL, numPlayers INTEGER DEFAULT 2 NOT NULL, gameboardOptions varchar(100) DEFAULT 'White,Checked' NOT NULL, gameRules TEXT, endgames TEXT,
Example Database Entry
'Tic Tac Toe', 3, 3, '000000000', '12', 2, 'White,Plain',
The response string specifies the name to the record in gameboards and an optional prepared layout & is expected to have the following format:
* <Examine> * <GameBoard Name='gameboard name' [Layout='board layout'] [Session='personal'|'public'] [EndGame='yes'|'no'] /> * <Description>Description as seen by players</Description> * </Examine>
An action location example:
<Examine> <GameBoard Name='Weather game' EndGame='Yes' Script='rain' Layout="" Session="personal/public"/> <Description>Magic puzzle that makes it rain. Make a simple r shape with the game pieces.</Description> </Examine>
<Examine> <GameBoard Name='Tic Tac Toe' EndGame='Yes' Script='minigame_win' /> <Description>Tic Tac Toe Board Game with $$$ prizes $$$.</Description> </Examine>
The Layout attribute defines the layout of the game board and optionally also preset game pieces on it. Optional - to override the default.
The Session attribute allows a game to be personal (restricted to one-player games) whereby only the player sees the game, no other players or watchers. One such minigame at one action_location can spawn a session per player who plays their own private game. Set to public is for the traditional board game, and is the default if this option is omitted.
The EndGame attribute specifies whether this game session is to adhere to the end-game rules. Optional. Default is No.
In the future we will add more attributes like for game options and name of a plugin or script for managed games.
Every session can have 0, 1, 2 or more players attached to it. The first player gets white game pieces and the second player black game pieces. All other players can just watch the game.
GameRules
PlayerTurns: can be Ordered (order of players' moves enforced) or StrictOrdered (as Ordered, and all players must be present) or 'Relaxed' (default - free for all).
MoveType: can be MoveOnly (player can only move existing pieces), PlaceOnly (player can only place new pieces on the board; cant move others), or 'PlaceOrMovePiece' (default - either move existing or place new pieces).
MoveablePieces: can be Own (player can only move their own pieces) or Any (default - player can move any piece in play).
MoveTo: can be Vacancy (player can move pieces to vacant squares only) or Anywhere (default - can move to any square, vacant or occupied).
<GameRules> <Rules PlayerTurns="StrictOrdered" MoveType="MoveOnly" MoveablePieces="Own" MoveTo="Vacancy" /> </GameRules>
<GameRules> <Rules PlayerTurns="StrictOrdered" MoveType="PlaceOnly" MoveTo="Vacancy" /> </GameRules>
EndGame
Decipher end game XML
<MGEndGame> <EndGame Coords="relative"/"absolute" [SourceTile="T"] [Winner="T"]> <Coord Col="?" Row="?" Tile="T" /> </EndGame> </MGEndGame>
[SourceTile="T"] (optional)
[Winner="T"] // winner is white or black player
Coord: - Tile 'A': tile has any played piece on - Tile 'W': tile has white piece - Tile 'B': tile has black piece - Tile 'E': empty tile - Tile 'F': tile has piece as per first tile in pattern
Example:
<MGEndGame> <EndGame Coords="absolute"> <Coord Col="0" Row="0" Tile="A" /> <Coord Col="1" Row="0" Tile="A" /> <Coord Col="2" Row="0" Tile="A" /> <Coord Col="0" Row="1" Tile="A" /> <Coord Col="0" Row="2" Tile="A" /> </EndGame> <EndGame Coords="absolute"> ... </EndGame> </MGEndGame>
Example 2:
<MGEndGame> <EndGame Coords="relative" SourceTile="A"> <Coord Col="1" Row="0" Tile="F" /> <Coord Col="2" Row="0" Tile="F" /> </EndGame> <EndGame Coords="relative" SourceTile="A"> <Coord Col="0" Row="1" Tile="F" /> <Coord Col="0" Row="2" Tile="F" /> </EndGame> <EndGame Coords="relative" SourceTile="A"> <Coord Col="1" Row="1" Tile="F" /> <Coord Col="2" Row="2" Tile="F" /> </EndGame> <EndGame Coords="relative" SourceTile="A"> <Coord Col="-1" Row="1" Tile="F" /> <Coord Col="-2" Row="2" Tile="F" /> </EndGame> </MGEndGame>