Base
[ class tree: Base ] [ index: Base ] [ all elements ]

Class: Game

Source Location: /objects/game.php

Class Overview


Prints data on a game, and loads and manages the collections of members which this game contains.


Variables

Methods


Child classes:

processGame
This class creates games, joins players up to games, manages the passing of games from phase to phase, decides when they're over and allocates points when they are, etc. It is the most general part of the gamemaster, just about all game manipulation occurs within this class.

Class Details

[line 30]
Prints data on a game, and loads and manages the collections of members which this game contains.

Most used to display the summary, when not loaded as processGame




[ Top ]


Class Variables

static $validCountries = array('England', 'France', 'Italy', 'Germany', 'Austria', 'Turkey', 'Russia')

[line 37]

An array of valid country names



Tags:

access:  public

Type:   array


[ Top ]

$gameOver =

[line 85]

The conditions under which the game ended; 'Won', 'No', 'Drawn'



Tags:

access:  public

Type:   int


[ Top ]

$id =

[line 43]

The game ID



Tags:

access:  public

Type:   int


[ Top ]

$Members =

[line 105]

An array of Member(/processMember) objects indexed by country



Tags:

access:  public

Type:   array


[ Top ]

$name =

[line 79]

The game's name



Tags:

access:  public

Type:   string


[ Top ]

$password =

[line 49]

The MD5 hash of the game's password



Tags:

access:  public

Type:   string


[ Top ]

$phase =

[line 61]

The game phase: 'Pre-game', 'Diplomacy', 'Retreats', 'Unit-placing', 'Finished'



Tags:

access:  public

Type:   int


[ Top ]

$phaseHours =

[line 98]

The number of hours per phase, defaults to 24



Tags:

access:  public

Type:   int


[ Top ]

$pot =

[line 91]

The number of points in the pot



Tags:

access:  public

Type:   int


[ Top ]

$potType =

[line 111]

Winner-takes-all/Points-per-supply-center



Tags:

access:  public

Type:   string


[ Top ]

$private =

[line 73]

True if the game is private



Tags:

access:  public

Type:   bool


[ Top ]

$processStatus =

[line 117]

Not-processing/Processing/Crashed/Paused



Tags:

access:  public

Type:   string


[ Top ]

$processTime =

[line 67]

The deadline when the game must next be processed, a UNIX timestamp



Tags:

access:  public

Type:   int


[ Top ]

$turn =

[line 55]

The in-game turn, 0 = Spring 1919, 1 = Autumn 1919



Tags:

access:  public

Type:   int


[ Top ]



Class Methods


static method static_datetxt [line 556]

static string static_datetxt( int $turn)

Return the in-game turn in text format. 0 = Spring 1901 , 1 = Autumn 1901, etc.



Tags:

return:  The game turn in text format
access:  public


Parameters:

int   $turn   The game turn to use

[ Top ]

constructor __construct [line 123]

Game __construct( int $gameID, [string[optional] $lockMode = NOLOCK])



Tags:

access:  public


Overridden in child classes as:

processGame::__construct()
Create a new game from a game ID; create the parent for UPDATE so that no-one else can process this game at the same tiem
datcGame::__construct()
Create a clean new game to apply the test to

Parameters:

int   $gameID   The game ID of the game to load
string[optional]   $lockMode   The database locking phase to use; no locking by default

[ Top ]

method bet [line 251]

void bet( [string[optional] $country = 'Unassigned'], [int[optional] $pointsPerSupplyCenter = -1])

Calculate the worth of a certain country, or the size of the required bet to join. With no args it will calculate the bet size required to join pre-game, with a country specified it will calculate the amount that country is worth, ie how much it would cost to take it over.



Tags:

access:  protected


Parameters:

string[optional]   $country   The country to value, pre-game value if none given
int[optional]   $pointsPerSupplyCenter   The pre-calculated PPSC; will be calculated if not provided

[ Top ]

method datetxt [line 579]

string datetxt( [int[optional] $turn = false])

Return the in-game turn in text format. 0 = Spring 1901 , 1 = Autumn 1901, etc.

It can use the Game object's turn, or a supplied $gdate




Tags:

return:  The game turn in text format


Parameters:

int[optional]   $turn   If this optional parameter is not supplied the Game's turn is used

[ Top ]

method gameovertxt [line 529]

string gameovertxt( [bool[optional] $map = FALSE])

A textual representation of the game over conditions



Tags:

return:  Either HTML or text depending on whether map.php is calling


Parameters:

bool[optional]   $map   Optional, false by default. If true the text will be without HTML, for the map

[ Top ]

method isMember [line 513]

string|bool isMember( int $userID)

Determines if the given user ID is registered in the current game. Returns the user's country if so, false if not



Tags:

return:  The user's country if he is a member, false if he isn't


Parameters:

int   $userID   The user ID to check

[ Top ]

method load [line 149]

void load( )

Reload the variables which are stored within this object specificially, ie everything

except aggregates




[ Top ]

method loadMembers [line 184]

void loadMembers( )

Reload the Members array



[ Top ]

method modetxt [line 592]

string modetxt( )

The Game's phase in textual format



[ Top ]

method pointsPerSupplyCenter [line 282]

int pointsPerSupplyCenter( )

Calculate the points value of a single supply center in this game



Tags:

access:  protected


[ Top ]

method processTimetxt [line 602]

string processTimetxt( )

Return the next process time in textual format, in terms of time remaining



[ Top ]

method summary [line 320]

string summary( [bool[optional] $ingame = FALSE])

Output an HTML summary of the game

Name, turn, game phase, next process time, pot, members&member info, a join&view dialog




Tags:

return:  The HTML of the summary


Parameters:

bool[optional]   $ingame   True if viewing the summary from within the game

[ Top ]


Documentation generated on Thu, 13 Nov 2008 18:15:48 +0900 by phpDocumentor 1.4.1