Minigame Scripting: Difference between revisions

From PSwiki
Jump to navigation Jump to search
Eonwind (talk | contribs)
No edit summary
Eonwind (talk | contribs)
No edit summary
Line 1: Line 1:




=== Introduction ===
==Introduction==
Game sessions are bound to a game board (action location) and identified
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).
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.
The game itself is defined in the gameboards db table.


gameboards table Database Entry:
==Gameboards Database Table==


  name VARCHAR(30) NOT NULL,
These are the fields specified by the ''gameboards'' db table:
  numColumns INTEGER UNSIGNED NOT NULL,
{| border="1"
  numRows INTEGER UNSIGNED NOT NULL,
!name
  layout TEXT NOT NULL,
!numColumns
  pieces TEXT NOT NULL,
!numRows
  numPlayers INTEGER DEFAULT 2 NOT NULL,
!layout
  gameboardOptions varchar(100) DEFAULT 'White,Checked' NOT NULL,
!pieces
  gameRules TEXT,
!numPlayers
  endgames TEXT,
!gameboardOptions
 
!gameRules
{|
!endgames
!Entry
!Description
!Default
|-
|name
|the name of the game (must be unique)
|-
|numColumns
|columns of the game board
|
|-
|numRows
|rows of the game board
|
|-
|-
|layout
|game's name (must be unique)
|starting layout of the row/columns in a string format
|number of board's columns
|
|number of board's rows
|-
|layout of the row/columns in a string format
|pieces
|type of pieces in a string format (allowed pieces: 1234567890ABCDE)
|type of pieces in a string format (allowed pieces: 1234567890ABCDE)
|-
|numPlayers
|number of players, 2 default, 1 for single player games
|number of players, 2 default, 1 for single player games
|-
|game options (default: White,Checked)
|gameboardOptions
|game options  
|'White,Checked'
|-
|gameRules
|specify the game rules in XML format
|specify the game rules in XML format
|
|-
|endgames
|specify the end-game rules (winning conditions) in XML format
|specify the end-game rules (winning conditions) in XML format
|-
|-
|}
|}


Example Database Entry:


  'Tic Tac Toe', 3, 3, '000000000', '12', 2, 'White,Plain', "<GameRules>...</GameRules>", " <MGEndGame>...</MGEndGame>"


Example Database Entry:
==Action Locations 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:
The response string specifies the name to the record in gameboards and an optional prepared layout is expected to have the following format:
Line 94: Line 69:




=== Game Rules ===
==Game Rules==


'''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).
'''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).
Line 113: Line 88:




=== End Game Rules ===
==End Game Rules==


Decipher end game XML
Decipher end game XML

Revision as of 04:12, 15 September 2013


Introduction

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.

Gameboards Database Table

These are the fields specified by the gameboards db table:

name numColumns numRows layout pieces numPlayers gameboardOptions gameRules endgames
game's name (must be unique) number of board's columns number of board's rows layout of the row/columns in a string format type of pieces in a string format (allowed pieces: 1234567890ABCDE) number of players, 2 default, 1 for single player games game options (default: White,Checked) specify the game rules in XML format specify the end-game rules (winning conditions) in XML format

Example Database Entry:

 'Tic Tac Toe', 3, 3, '000000000', '12', 2, 'White,Plain', "<GameRules>...</GameRules>", " <MGEndGame>...</MGEndGame>"

Action Locations Entry

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.


Game Rules

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>


End Game Rules

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>