Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

BaseRPSGame Class Reference
[Base Objects]

Inheritance diagram for BaseRPSGame:

MyObject BaseObject MyModule BaseModule List of all members.

Detailed Description

Easily add RPS gaming functionality to your site.

Allow your users to challenge each other to Rock Paper Scissors and duke it out with taunts, statistics, and alert sytem integration. Lots of fun.

Definition at line 9 of file base-rps-game.inc.php.

Public Member Functions

 __construct ($data=null, $table= 'janken')
 initialize our oject.
 getPagesXml ()
 add in our special pages.
 initChallengePage ()
 prep our challenge page
 drawChallengePage ()
 draw our challenge page
 initTauntPage ()
 prep our taunt page
 drawTauntPage ()
 draw our taunt page
 createTauntForm ()
 create a form for adding our taunt
 initDefendPage ()
 prep our defend page.
 canView ()
 who can view it? by default everyone =)
 canEdit ()
 who can edit it? by default nobody
 canDelete ()
 who can delete it? by default nobody
 drawChallengeBox ($userId)
 draw a challenge box for a user.
 initViewPage ()
 prep our view page
 drawViewPage ()
 draw our view page
 drawDefendBox ()
 draw a box for the defender to defend themselves.
 drawFightBox ()
 draw information about the fight
 getUserStats ($userId)
 get an array of stats about a users RPS performance
 lookupData ($deep=true)
 lookup our data.
 getDataToCache ($deep=true)
 this is the funciton that gets the data we need saved to cache.
 setDataFromCache ($data, $deep=true)
 this function sets the data in the object from the data we retrieved from the cache.
 getCreateFieldsArray ()
 get the fields for the table.
 getCreateIndexesArray ()
 get the indexes for the table.

Public Attributes

 $Attacker
 this is our attacker object
 $Defender
 this is our defender object

Static Public Attributes

 $winMatrix
 our win matrix.

Protected Member Functions

 getDeletePageXml ()
 no delete page.
 getEditPageXml ()
 no edit page.


Member Function Documentation

BaseRPSGame::__construct data = null,
table = 'janken'
 

initialize our oject.

See also:
BaseObject::__construct()

Reimplemented from BaseObject.

Definition at line 46 of file base-rps-game.inc.php.

BaseRPSGame::canDelete  ) 
 

who can delete it? by default nobody

Reimplemented from BaseObject.

Definition at line 252 of file base-rps-game.inc.php.

BaseRPSGame::canEdit  ) 
 

who can edit it? by default nobody

Reimplemented from BaseObject.

Definition at line 244 of file base-rps-game.inc.php.

BaseRPSGame::canView  ) 
 

who can view it? by default everyone =)

Reimplemented from BaseObject.

Definition at line 236 of file base-rps-game.inc.php.

BaseRPSGame::createTauntForm  ) 
 

create a form for adding our taunt

Returns:
a Form used for taunting

Definition at line 185 of file base-rps-game.inc.php.

References BaseModule::getUrl().

Referenced by drawChallengePage(), and drawTauntPage().

BaseRPSGame::drawChallengeBox userId  ) 
 

draw a challenge box for a user.

it shows some text and the three options for attacking

Parameters:
$userId the id of the user who will be challenged

Definition at line 263 of file base-rps-game.inc.php.

References BaseModule::getLink().

Referenced by drawViewPage().

BaseRPSGame::drawChallengePage  ) 
 

draw our challenge page

Definition at line 122 of file base-rps-game.inc.php.

References createTauntForm(), BaseModule::params(), and BaseObject::save().

BaseRPSGame::drawDefendBox  ) 
 

draw a box for the defender to defend themselves.

Definition at line 348 of file base-rps-game.inc.php.

References BaseModule::getLink().

Referenced by drawViewPage().

BaseRPSGame::drawFightBox  ) 
 

draw information about the fight

Definition at line 366 of file base-rps-game.inc.php.

Referenced by drawViewPage().

BaseRPSGame::drawTauntPage  ) 
 

draw our taunt page

Definition at line 165 of file base-rps-game.inc.php.

References createTauntForm(), Util::redirect(), and BaseObject::save().

BaseRPSGame::drawViewPage  ) 
 

draw our view page

Definition at line 291 of file base-rps-game.inc.php.

References Linkify::bbcode(), drawChallengeBox(), drawDefendBox(), and drawFightBox().

BaseRPSGame::getCreateFieldsArray  ) 
 

get the fields for the table.

See also:
BaseObject::getCreateFieldsArray()

Reimplemented from BaseObject.

Definition at line 495 of file base-rps-game.inc.php.

BaseRPSGame::getCreateIndexesArray  ) 
 

get the indexes for the table.

See also:
BaseObject::getCreateIndexesArray()

Reimplemented from BaseObject.

Definition at line 520 of file base-rps-game.inc.php.

BaseRPSGame::getDataToCache deep = true  ) 
 

this is the funciton that gets the data we need saved to cache.

by default it saves our data, and will save the comments or tags objects if needed. its recommended to extend this to add data that you'd like cached by the object

Returns:
an array of data to cache

Reimplemented from BaseObject.

Definition at line 468 of file base-rps-game.inc.php.

BaseRPSGame::getDeletePageXml  )  [protected]
 

no delete page.

you cant delete your games. sorry losers.

Reimplemented from BaseObject.

Definition at line 56 of file base-rps-game.inc.php.

BaseRPSGame::getEditPageXml  )  [protected]
 

no edit page.

you cant edit your games. sorry losers.

Reimplemented from BaseObject.

Definition at line 64 of file base-rps-game.inc.php.

BaseRPSGame::getPagesXml  ) 
 

add in our special pages.

challenge - challenge someone to a game of RPS defend - defend yourself in a game of RPS taunt - add a taunt to your attack

Reimplemented from BaseObject.

Definition at line 76 of file base-rps-game.inc.php.

BaseRPSGame::getUserStats userId  ) 
 

get an array of stats about a users RPS performance

This function return a keyed array here are what they mean:

offwin - offense wins offloss - offense losses offtie - offense ties offpercent - offense win percent defwin - defense wins defloss - defense losses deftie - defense ties defpercent - defense win percent totwin - total wins totloss - total losses tottie - total ties totpercent - total win percent

Parameters:
$userId the id of the user to lookup
Returns:
an array with keys as described above

Definition at line 396 of file base-rps-game.inc.php.

References dbFetchAssoc(), and dbQuery().

BaseRPSGame::initChallengePage  ) 
 

prep our challenge page

Definition at line 107 of file base-rps-game.inc.php.

References BaseModule::assertLogin(), and BaseModule::params().

BaseRPSGame::initDefendPage  ) 
 

prep our defend page.

Definition at line 207 of file base-rps-game.inc.php.

References BaseModule::assertLogin(), initViewPage(), BaseModule::params(), Util::redirect(), and BaseObject::save().

BaseRPSGame::initTauntPage  ) 
 

prep our taunt page

Definition at line 149 of file base-rps-game.inc.php.

References BaseModule::assertLogin(), and BaseModule::params().

BaseRPSGame::initViewPage  ) 
 

prep our view page

Definition at line 281 of file base-rps-game.inc.php.

Referenced by initDefendPage().

BaseRPSGame::lookupData deep = true  ) 
 

lookup our data.

See also:
BaseObject::lookupData()

Reimplemented from BaseObject.

Definition at line 457 of file base-rps-game.inc.php.

BaseRPSGame::setDataFromCache data,
deep = true
 

this function sets the data in the object from the data we retrieved from the cache.

it takes the data from the array and puts it in the object. you'll want to override this one if you added custome data in getDataToCache() and load it into the object.

Parameters:
$data the data we got from teh cache

Reimplemented from BaseObject.

Definition at line 478 of file base-rps-game.inc.php.


Member Data Documentation

BaseRPSGame::$Attacker
 

this is our attacker object

Definition at line 36 of file base-rps-game.inc.php.

BaseRPSGame::$Defender
 

this is our defender object

Definition at line 41 of file base-rps-game.inc.php.

BaseRPSGame::$winMatrix [static]
 

Initial value:

 array(
        'rock' => array(
            'rock' => 'tie',
            'paper' => 'defense',
            'scissors' => 'offense'
        ),
        'paper' => array(
            'rock' => 'offense',
            'paper' => 'tie',
            'scissors' => 'defense'
        ),
        'scissors' => array(
            'rock' => 'defense',
            'paper' => 'offense',
            'scissors' => 'tie'
        ),
    )
our win matrix.

a 3x3 array of win/loss/tie where the first index is the attackers move, and the second index is the defenders move

Definition at line 15 of file base-rps-game.inc.php.


The documentation for this class was generated from the following file:
Generated on Fri Oct 27 12:26:41 2006 for BaseJumper by doxygen 1.3.9.1