Post by Kristal Rose Phoenix McKinstry on Oct 17, 2005 3:24:24 GMT -5
<?php
$ulShowVersions = FALSE; // SET THIS TO SHOW HEADER UPDATES FROM TITLE BLACKS.
##########################################################################################
######################### SMC CS85 CHESS PROGRAM #########################################
##########################################################################################
if ($ulShowVersions) print('
// fCommitMove special-move arg
// winner test
#### chess.php ###########################################################################<br />
#### 2005.12.12 20:00 - km fCommitMove has special moves arg for castling/passant.########<br />
#### 2005.11.11 18:00 - km calling oTestMove->fTestMove directly. ###############<br />
#### 2005.11.09 21:00 - km activated TryPostComment procedure. ###############<br />
#### 2005.11.07 07:00 - km chess.php now uses oCFV.fGetProcess list of processes. ########<br />
#### 2005.11.06 06:45 - km fBuildGui now uses $laGui arg instead of $lsState & Msg.#######<br />');
#### 2005.11.05 09:10 - km Major work on Move function. ###############
#### 2005.11.04 05:45 - km RESTRUCTURED switch. NO more functions! ###############
#### 2005.11.04 02:05 - km added WaitTurn, Yourturn, ChosenGo, ChosenWait. ###############
#### 2005.11.03 05:45 - km working on RegisterPartner function again. ###############
#### 2005.10.31 04:15 - km working on RegisterPartner function. ###############
#### 2005.10.30 19:45 - km fBuildGui now requires first "Board-Array" arg. ###############
#### 2005.10.30 04:00 - km got PostComment mostly working. ###############
#### 2005.10.30 02:25 - km added RegisterPartner function. ###############
#### 2005.10.30 02:15 - km added oForum init to LogIn. ###############
#### 2005.10.30 01:30 - km cleaned doc, PostComment(arg). ###############
#### 2005.10.29 08:00 - km added $vhLastState for refresh of forum. ###############
#### 2005.10.29 02:30 - km FINISHED entire LogIn procedure. ###############
#### 2005.10.28 20:45 - km FINISHED LogIn to register user on database. ###############
#### 2005.10.27 06:45 - km modified LogIn to register user on database. ###############
#### 2005.10.26 22:40 - km modified to support new oServer object ! ! ###############
#### 2005.10.26 19:40 - km added $ulShowVersions for testing. ###############
#### 2005.10.25 10:25 - km added stub BoardState args to calls ###############
#### 2005.10.24 08:35 - km Restructured Splash to pass args to oBuildGui to oForum #######
#### 2005.10.24 05:55 - km Added Forum Features. ###############
#### 2005.10.23 04:15 - km Added QuitGame function stub. ###############
#### 2005.10.23 04:15 - km Improved documentation (Board States). ###############
#### 2005.10.23 02:30 - km added controlling stub function descriptions. #################
#### 2005.10.22 19:05 - km Calls default oCollectFormVars instead. ####################
#### 2005.10.20 20:50 - km EDITED VAR NAMES for consistency with new conventions #########
#### 2005.10.19 05:15 - km req'd page sSetPageVarsObj.rsp to collect form vars ###########
#### 2005.10.19 02:10 - km got object passing stub working in Splash #####################
#### 2005.10.17 02:00 - km added Title block #############################################
#### 2005.10.17 01:30 - km build switch, test methods ####################################
##########################################################################################
##########################################################################################
#### Status: !! LOCKED !! by KM ##########################################################
##########################################################################################
##########################################################################################
#### Description: #####################################################################
#### ###########
#### This is the main program page. It generates an intitial Splash page or ###########
#### collects form variables, determines type of request, determines ###########
#### state of game, and sends back appropriate page via oBuildGui. ###########
#### ###########
##########################################################################################
##########################################################################################
#### Ver. 2.0 - Basic Game #####################################################
##########################################################################################
#### Agenda: #############################################################################
#### #############################################################################
#### Call chess.php with process list instead. ################
#### Player 1 of only two doesnt get status if they choose partner first. ################
#### Use move screens, not chosen screens if game both players have gone. ################
#### Remind user who their partner is. ######################################
#### Delete abandoned games. ######################################
#### Prevent LogIns starting w/ ''. ######################################
#### PostComment isn't tracking other player yet. ######################################
#### ! session deserialization via oCollectFormVars ######################################
#### ######################################
##########################################################################################
##########################################################################################
#### Programmer: Kristal McKinstry #######################################################
##########################################################################################
##########################################################################################
?>
<html>
<head>
<title>Online Chess Game</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="chess.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#003366">
<?php
require('chessobjects.rphj'); // Load all libraries.
require('sSetPageVarsObj.rsp'); // Sets array $laCFV used in next line.
$uoCFV = new oCollectFormVars($laCFV);// ($uoCFV object needs import_request_variables, not available from within methods)
$uoS = new oServer();// Needed by any functions/objects using Sql.
$uoB = new oBoard();
$uoBG = new oBuildGui();// Every case returns a screen to the user.
$uoReg = new oRegistration($uoS);// Used by game cases.
$uaBoard = $uoB->fGetBoardArray();// For display in cases before game actually exists.
####include('sTestTemp.php'); //Trial code snippets to run first (after libraries load).
$laGui = array('Text' => 'Welcome. Please Log in.',
'PriorVals' => FALSE,
'LogIn' => TRUE,
'CheckStatus' => FALSE,
'LogOut' => FALSE,
'SelectOther' => FALSE,
'Move' => FALSE,
'Aesthetics' => TRUE,
'incChat' => FALSE,
'Forum' => FALSE,
'Quit' => FALSE,
'SaveGame' => FALSE,
'LoadGame' => FALSE);
/*
$laProcess = array('DataId' =>FALSE, // = Logged in? [x]
'DataTheirName' =>FALSE,//[x]
'DataGameId' =>FALSE,//[x]
'DataTurnNum' =>FALSE,//[x]
'DataTheirTurn' =>FALSE,//[x]
'DataFirstPlayer' =>FALSE,//[x]
'DataPlayersAvailable' =>FALSE,
'DataRecentlyChosen' =>FALSE,
'DataChosePlayer' =>FALSE,//[x]
'DataPartnerName' =>FALSE,//[x]
'DataGameWonAlready' =>FALSE,//[x]
'DataCheckDeclaredByOtherUser' => FALSE,
'TryMove' => FALSE,//[x]
'TryPostComment' => FALSE,//[x]
'TrySelectPlayer' => FALSE,
'TryRegister' => FALSE,
'TryRegisterPartner' => FALSE, // what if player now unavailable?
'TrySaveGame' => FALSE,//[%]
'TryLoadGame' => FALSE,//[%]
'TryQuitGame' => FALSE,//[%]
'TryLogOut' => FALSE);//[x]
*/
$laProcess = $uoCFV->fGetProcess();
####echocall('first process:');
####var_dump($laProcess);
if ($laProcess['DataId']){ // Logged In.
$laGui['Text']="Hello {$laProcess['DataTheirName']}. ";
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryRegister']){
//echocall('TryRegister was called');
$lsLongName = $uoCFV->fGetVal('vtPlayer');
$llIsUnique = $uoReg->fIsNameAvail($lsLongName); // otherwise SelectPlayer feature would fail.
if (!$llIsUnique) $laGui['Text'] = 'That name is already in use. Please log-in with another name';
else {
$laGui['LogIn']=FALSE;
$lsId = $uoReg->fAddActiveUser($lsLongName); // register as online+available.
$uoCFV->fSetVal('vhPlayer', $lsId); // so BuildGui will know who's screen it is.
$laProcess['DataId'] = $lsId;
$laProcess['DataTheirName'] = $lsLongName;
$laGui['Text'] = "Welcome {$laProcess['DataTheirName']}. ";
}//end-else ! Not Unique
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryLogOut']){ echocall('TryLogOut was called');
//>> a) if (player in game)
//>> .. if waiting > logout
//>> .. if in game > ask to save, notify other player
//>> else logout, remove from registered online, clear page vars (splash)
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TrySelectPlayer']){
//echocall('TrySelectPlayer was called');
//>> AGENDA: if in game "drop or save game?"
//>> if registered but not in game >
//>> .. if other(s) registerd >
//## Moved to final gui building
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TrySaveGame']){ echocall('TrySaveGame was called');
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryLoadGame']){ echocall('TryLoadGame was called');
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryQuitGame']){ echocall('TryQuitGame was called');
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryRegisterPartner']) {
//echocall('TryRegisterPartner was called');
// This case sets up a new game.
if ($laProcess['DataPlayersAvailable']) {
$lsOtherId = $uoReg->fRegisterGame($uoCFV);
$laProcess['DataPartnerName'] = $uoReg->fGetNameFromId($lsOtherId);
$laProcess['DataTheirTurn'] = TRUE;
$laProcess['DataGameId'] = $uoReg->fGetGameFromId($lsOtherId);
$laProcess['DataFirstPlayer'] = TRUE;
}//end-if
else{
$laGui['Text'] .= 'That player is no longer available. Please try again.';
$laGui['SelectOther']=TRUE;
$laProcess['DataPartnerName'] = FALSE;
}//end-else
}//end-if Try
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryMove']){
//echocall('TryMove was called');
if (!$laProcess['DataFirstPlayer']) $uoCFV->fFlipMove();
$lsGameId = $uoReg->fGetGameFromId($uoCFV->fGetVal('vhPlayer'));
$oG = new oGame($uoS, $lsGameId);
$oT = new oTestMove($uoS, $uoCFV, 'zilch', $oG); //@@@@@@ added args
/*
$lsToss = $laProcess['DataCheckDeclaredByThisUser'];
echocall("this is $lsToss");
$lsToss = $laProcess['DataCheckDeclaredByOtherUser'];
echocall("other is $lsToss");
*/
$llCool = $oT->fTestMove();
//$llCool = $oG->fTestMove($uoCFV->fGetMove()); //fTestMove($laMove, $laBoard='zilch'){
if ($llCool){
$uaBoard = $oG->fCommitMove($uoCFV->fGetMove(), (string)$uoCFV->fGetVal('vsMove'));
$uoB2 = new oBoard($uaBoard);
$liWinner = $uoB2->fTestWinner($uaBoard);
if ($liWinner){
$oG->fSetWinner($lsGameId='zilch', $laProcess['DataId']);
$laGui['Text'] .= 'Congratulations! You have won the game.';
}//end-if
$liTurn = $oG->fToggleTurn();
$laProcess['DataTheirTurn'] = FALSE;
}//end-if
else {
$laGui['Text'] = 'That was not a legal move! Please try again.';
}//end-else
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryPostComment']){
//echocall('TryPostComment was called');
$loF = new oForum($uoCFV->fGetVal('vhPlayer'));
$loF->fPostComment($uoCFV, $uoS);
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
$laGui['PriorVals']=TRUE;
if ($laProcess['DataId']){ // Logged In.
$laGui['LogOut']=TRUE;
$laGui['LogIn']=FALSE;
if ($laProcess['DataPartnerName']){
$uoG = new oGame($uoS, $laProcess['DataGameId']);
$uaBoard = $uoG->fGetCurrentBoard();
if (!$laProcess['DataFirstPlayer']){
$uoB = new oBoard($uaBoard);
$uaBoard = $uoB->fFlipBoard(TRUE);
}
$laGui['Text'] .= "You are playing {$laProcess['DataPartnerName']}. ";
}//end-if Partnered
else{
if ($laProcess['DataPlayersAvailable'] == TRUE){
$laGui['SelectOther']=TRUE;
$laGui['Text'] .= 'Please select a partner.';
}//end-if
else {
$laGui['Text'] .= 'Please wait for available partners.';
}//end-else
$laGui['CheckStatus']=TRUE; // Option either way in case they want a later partner selection.
}//end-else not partnered
if ($laProcess['DataTheirTurn']){
$laGui['Move']=FALSE;
$laGui['CheckStatus']=TRUE;
if ($laProcess['DataPartnerName']){
$laGui['Text'] .= 'It\'s your turn. Click off board then piece to move, then destination.';
}
}
else{
$laGui['Move']=FALSE;
$laGui['CheckStatus']=TRUE;
if ($laProcess['DataPartnerName']){
$laGui['Text'] .= 'Please wait. It\'s their turn.';
}
}//end-else
if ($laProcess['DataGameId']){
$laGui['Quit']=TRUE;
if ($laProcess['DataTheirTurn']){
$laGui['Move']=TRUE;
$laGui['CheckStatus']=FALSE;
}
else{
$laGui['CheckStatus']=TRUE;
$laGui['Move']=FALSE;
}//end-else
if ($laProcess['DataGameWonAlready']){
$lsName=$laProcess['DataTheirName'];
$laGui['Text'] = "Sorry $lsName, you have lost.";
$laGui['CheckStatus']=TRUE;
$laGui['Move']=FALSE;
}
if ($laProcess['DataCheckDeclaredByOtherUser']) $laGui['Text'] .= " They have declared 'Check'!";
}//end-if
if ($laProcess['DataPartnerName']) $laGui['incChat']=TRUE;
if ($uoCFV->fGetVal('vcIncludeChat') == 'yes') $laGui['Forum']=TRUE;
}//end-if
####echocall('process after chess:');
####var_dump($laProcess);
$uoBG->fBuildGui($uaBoard, $uoCFV, $laGui);
?>
</body>
</html>
$ulShowVersions = FALSE; // SET THIS TO SHOW HEADER UPDATES FROM TITLE BLACKS.
##########################################################################################
######################### SMC CS85 CHESS PROGRAM #########################################
##########################################################################################
if ($ulShowVersions) print('
// fCommitMove special-move arg
// winner test
#### chess.php ###########################################################################<br />
#### 2005.12.12 20:00 - km fCommitMove has special moves arg for castling/passant.########<br />
#### 2005.11.11 18:00 - km calling oTestMove->fTestMove directly. ###############<br />
#### 2005.11.09 21:00 - km activated TryPostComment procedure. ###############<br />
#### 2005.11.07 07:00 - km chess.php now uses oCFV.fGetProcess list of processes. ########<br />
#### 2005.11.06 06:45 - km fBuildGui now uses $laGui arg instead of $lsState & Msg.#######<br />');
#### 2005.11.05 09:10 - km Major work on Move function. ###############
#### 2005.11.04 05:45 - km RESTRUCTURED switch. NO more functions! ###############
#### 2005.11.04 02:05 - km added WaitTurn, Yourturn, ChosenGo, ChosenWait. ###############
#### 2005.11.03 05:45 - km working on RegisterPartner function again. ###############
#### 2005.10.31 04:15 - km working on RegisterPartner function. ###############
#### 2005.10.30 19:45 - km fBuildGui now requires first "Board-Array" arg. ###############
#### 2005.10.30 04:00 - km got PostComment mostly working. ###############
#### 2005.10.30 02:25 - km added RegisterPartner function. ###############
#### 2005.10.30 02:15 - km added oForum init to LogIn. ###############
#### 2005.10.30 01:30 - km cleaned doc, PostComment(arg). ###############
#### 2005.10.29 08:00 - km added $vhLastState for refresh of forum. ###############
#### 2005.10.29 02:30 - km FINISHED entire LogIn procedure. ###############
#### 2005.10.28 20:45 - km FINISHED LogIn to register user on database. ###############
#### 2005.10.27 06:45 - km modified LogIn to register user on database. ###############
#### 2005.10.26 22:40 - km modified to support new oServer object ! ! ###############
#### 2005.10.26 19:40 - km added $ulShowVersions for testing. ###############
#### 2005.10.25 10:25 - km added stub BoardState args to calls ###############
#### 2005.10.24 08:35 - km Restructured Splash to pass args to oBuildGui to oForum #######
#### 2005.10.24 05:55 - km Added Forum Features. ###############
#### 2005.10.23 04:15 - km Added QuitGame function stub. ###############
#### 2005.10.23 04:15 - km Improved documentation (Board States). ###############
#### 2005.10.23 02:30 - km added controlling stub function descriptions. #################
#### 2005.10.22 19:05 - km Calls default oCollectFormVars instead. ####################
#### 2005.10.20 20:50 - km EDITED VAR NAMES for consistency with new conventions #########
#### 2005.10.19 05:15 - km req'd page sSetPageVarsObj.rsp to collect form vars ###########
#### 2005.10.19 02:10 - km got object passing stub working in Splash #####################
#### 2005.10.17 02:00 - km added Title block #############################################
#### 2005.10.17 01:30 - km build switch, test methods ####################################
##########################################################################################
##########################################################################################
#### Status: !! LOCKED !! by KM ##########################################################
##########################################################################################
##########################################################################################
#### Description: #####################################################################
#### ###########
#### This is the main program page. It generates an intitial Splash page or ###########
#### collects form variables, determines type of request, determines ###########
#### state of game, and sends back appropriate page via oBuildGui. ###########
#### ###########
##########################################################################################
##########################################################################################
#### Ver. 2.0 - Basic Game #####################################################
##########################################################################################
#### Agenda: #############################################################################
#### #############################################################################
#### Call chess.php with process list instead. ################
#### Player 1 of only two doesnt get status if they choose partner first. ################
#### Use move screens, not chosen screens if game both players have gone. ################
#### Remind user who their partner is. ######################################
#### Delete abandoned games. ######################################
#### Prevent LogIns starting w/ ''. ######################################
#### PostComment isn't tracking other player yet. ######################################
#### ! session deserialization via oCollectFormVars ######################################
#### ######################################
##########################################################################################
##########################################################################################
#### Programmer: Kristal McKinstry #######################################################
##########################################################################################
##########################################################################################
?>
<html>
<head>
<title>Online Chess Game</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="chess.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#003366">
<?php
require('chessobjects.rphj'); // Load all libraries.
require('sSetPageVarsObj.rsp'); // Sets array $laCFV used in next line.
$uoCFV = new oCollectFormVars($laCFV);// ($uoCFV object needs import_request_variables, not available from within methods)
$uoS = new oServer();// Needed by any functions/objects using Sql.
$uoB = new oBoard();
$uoBG = new oBuildGui();// Every case returns a screen to the user.
$uoReg = new oRegistration($uoS);// Used by game cases.
$uaBoard = $uoB->fGetBoardArray();// For display in cases before game actually exists.
####include('sTestTemp.php'); //Trial code snippets to run first (after libraries load).
$laGui = array('Text' => 'Welcome. Please Log in.',
'PriorVals' => FALSE,
'LogIn' => TRUE,
'CheckStatus' => FALSE,
'LogOut' => FALSE,
'SelectOther' => FALSE,
'Move' => FALSE,
'Aesthetics' => TRUE,
'incChat' => FALSE,
'Forum' => FALSE,
'Quit' => FALSE,
'SaveGame' => FALSE,
'LoadGame' => FALSE);
/*
$laProcess = array('DataId' =>FALSE, // = Logged in? [x]
'DataTheirName' =>FALSE,//[x]
'DataGameId' =>FALSE,//[x]
'DataTurnNum' =>FALSE,//[x]
'DataTheirTurn' =>FALSE,//[x]
'DataFirstPlayer' =>FALSE,//[x]
'DataPlayersAvailable' =>FALSE,
'DataRecentlyChosen' =>FALSE,
'DataChosePlayer' =>FALSE,//[x]
'DataPartnerName' =>FALSE,//[x]
'DataGameWonAlready' =>FALSE,//[x]
'DataCheckDeclaredByOtherUser' => FALSE,
'TryMove' => FALSE,//[x]
'TryPostComment' => FALSE,//[x]
'TrySelectPlayer' => FALSE,
'TryRegister' => FALSE,
'TryRegisterPartner' => FALSE, // what if player now unavailable?
'TrySaveGame' => FALSE,//[%]
'TryLoadGame' => FALSE,//[%]
'TryQuitGame' => FALSE,//[%]
'TryLogOut' => FALSE);//[x]
*/
$laProcess = $uoCFV->fGetProcess();
####echocall('first process:');
####var_dump($laProcess);
if ($laProcess['DataId']){ // Logged In.
$laGui['Text']="Hello {$laProcess['DataTheirName']}. ";
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryRegister']){
//echocall('TryRegister was called');
$lsLongName = $uoCFV->fGetVal('vtPlayer');
$llIsUnique = $uoReg->fIsNameAvail($lsLongName); // otherwise SelectPlayer feature would fail.
if (!$llIsUnique) $laGui['Text'] = 'That name is already in use. Please log-in with another name';
else {
$laGui['LogIn']=FALSE;
$lsId = $uoReg->fAddActiveUser($lsLongName); // register as online+available.
$uoCFV->fSetVal('vhPlayer', $lsId); // so BuildGui will know who's screen it is.
$laProcess['DataId'] = $lsId;
$laProcess['DataTheirName'] = $lsLongName;
$laGui['Text'] = "Welcome {$laProcess['DataTheirName']}. ";
}//end-else ! Not Unique
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryLogOut']){ echocall('TryLogOut was called');
//>> a) if (player in game)
//>> .. if waiting > logout
//>> .. if in game > ask to save, notify other player
//>> else logout, remove from registered online, clear page vars (splash)
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TrySelectPlayer']){
//echocall('TrySelectPlayer was called');
//>> AGENDA: if in game "drop or save game?"
//>> if registered but not in game >
//>> .. if other(s) registerd >
//## Moved to final gui building
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TrySaveGame']){ echocall('TrySaveGame was called');
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryLoadGame']){ echocall('TryLoadGame was called');
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryQuitGame']){ echocall('TryQuitGame was called');
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryRegisterPartner']) {
//echocall('TryRegisterPartner was called');
// This case sets up a new game.
if ($laProcess['DataPlayersAvailable']) {
$lsOtherId = $uoReg->fRegisterGame($uoCFV);
$laProcess['DataPartnerName'] = $uoReg->fGetNameFromId($lsOtherId);
$laProcess['DataTheirTurn'] = TRUE;
$laProcess['DataGameId'] = $uoReg->fGetGameFromId($lsOtherId);
$laProcess['DataFirstPlayer'] = TRUE;
}//end-if
else{
$laGui['Text'] .= 'That player is no longer available. Please try again.';
$laGui['SelectOther']=TRUE;
$laProcess['DataPartnerName'] = FALSE;
}//end-else
}//end-if Try
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryMove']){
//echocall('TryMove was called');
if (!$laProcess['DataFirstPlayer']) $uoCFV->fFlipMove();
$lsGameId = $uoReg->fGetGameFromId($uoCFV->fGetVal('vhPlayer'));
$oG = new oGame($uoS, $lsGameId);
$oT = new oTestMove($uoS, $uoCFV, 'zilch', $oG); //@@@@@@ added args
/*
$lsToss = $laProcess['DataCheckDeclaredByThisUser'];
echocall("this is $lsToss");
$lsToss = $laProcess['DataCheckDeclaredByOtherUser'];
echocall("other is $lsToss");
*/
$llCool = $oT->fTestMove();
//$llCool = $oG->fTestMove($uoCFV->fGetMove()); //fTestMove($laMove, $laBoard='zilch'){
if ($llCool){
$uaBoard = $oG->fCommitMove($uoCFV->fGetMove(), (string)$uoCFV->fGetVal('vsMove'));
$uoB2 = new oBoard($uaBoard);
$liWinner = $uoB2->fTestWinner($uaBoard);
if ($liWinner){
$oG->fSetWinner($lsGameId='zilch', $laProcess['DataId']);
$laGui['Text'] .= 'Congratulations! You have won the game.';
}//end-if
$liTurn = $oG->fToggleTurn();
$laProcess['DataTheirTurn'] = FALSE;
}//end-if
else {
$laGui['Text'] = 'That was not a legal move! Please try again.';
}//end-else
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
if ($laProcess['TryPostComment']){
//echocall('TryPostComment was called');
$loF = new oForum($uoCFV->fGetVal('vhPlayer'));
$loF->fPostComment($uoCFV, $uoS);
}//end-if
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
$laGui['PriorVals']=TRUE;
if ($laProcess['DataId']){ // Logged In.
$laGui['LogOut']=TRUE;
$laGui['LogIn']=FALSE;
if ($laProcess['DataPartnerName']){
$uoG = new oGame($uoS, $laProcess['DataGameId']);
$uaBoard = $uoG->fGetCurrentBoard();
if (!$laProcess['DataFirstPlayer']){
$uoB = new oBoard($uaBoard);
$uaBoard = $uoB->fFlipBoard(TRUE);
}
$laGui['Text'] .= "You are playing {$laProcess['DataPartnerName']}. ";
}//end-if Partnered
else{
if ($laProcess['DataPlayersAvailable'] == TRUE){
$laGui['SelectOther']=TRUE;
$laGui['Text'] .= 'Please select a partner.';
}//end-if
else {
$laGui['Text'] .= 'Please wait for available partners.';
}//end-else
$laGui['CheckStatus']=TRUE; // Option either way in case they want a later partner selection.
}//end-else not partnered
if ($laProcess['DataTheirTurn']){
$laGui['Move']=FALSE;
$laGui['CheckStatus']=TRUE;
if ($laProcess['DataPartnerName']){
$laGui['Text'] .= 'It\'s your turn. Click off board then piece to move, then destination.';
}
}
else{
$laGui['Move']=FALSE;
$laGui['CheckStatus']=TRUE;
if ($laProcess['DataPartnerName']){
$laGui['Text'] .= 'Please wait. It\'s their turn.';
}
}//end-else
if ($laProcess['DataGameId']){
$laGui['Quit']=TRUE;
if ($laProcess['DataTheirTurn']){
$laGui['Move']=TRUE;
$laGui['CheckStatus']=FALSE;
}
else{
$laGui['CheckStatus']=TRUE;
$laGui['Move']=FALSE;
}//end-else
if ($laProcess['DataGameWonAlready']){
$lsName=$laProcess['DataTheirName'];
$laGui['Text'] = "Sorry $lsName, you have lost.";
$laGui['CheckStatus']=TRUE;
$laGui['Move']=FALSE;
}
if ($laProcess['DataCheckDeclaredByOtherUser']) $laGui['Text'] .= " They have declared 'Check'!";
}//end-if
if ($laProcess['DataPartnerName']) $laGui['incChat']=TRUE;
if ($uoCFV->fGetVal('vcIncludeChat') == 'yes') $laGui['Forum']=TRUE;
}//end-if
####echocall('process after chess:');
####var_dump($laProcess);
$uoBG->fBuildGui($uaBoard, $uoCFV, $laGui);
?>
</body>
</html>