Post by Kristal Rose Phoenix McKinstry on Oct 17, 2005 3:28:25 GMT -5
<?php
// en passant attack
##########################################################################################
######################### SMC CS85 CHESS PROGRAM #########################################
#### ATTENTION: Now requires renamed extended chess piece gif's! #########################
##########################################################################################
if ($ulShowVersions) print('
#### oBuildGui.rphj ######################################################################<br />
#### 2005.11.09 23:50 - km en passant option. ###############<br />
#### 2005.11.09 23:50 - km deleted echocall. ###############<br />
#### 2005.11.09 21:15 - km revised contructor call to oForum. ###############<br />
#### 2005.11.06 06:45 - km fBuildGui now uses $laGui arg instead of $lsState & Msg.#######<br />
#### 2005.11.06 03:45 - km deleted hidden vars: submitter,submit,formId,LastState ########<br />
#### 2005.11.06 03:00 - km deleted test fields. ###############<br />');
#### 2005.11.05 02:25 - km clears LogIn text box when focused. ###############
#### 2005.11.05 02:15 - km deleted refresh seconds button. ###############
#### 2005.11.04 23:40 - km added button vbCheck to see if players arrive. ###############
#### 2005.11.04 20:00 - km deleted refresh meta. Doesnt POST. ###############
#### 2005.11.04 20:00 - km added conditional refresh meta to header. ###############
#### 2005.11.04 02:05 - km Javascript for Move only if their turn to move. ###############
#### 2005.11.03 05:45 - km worked on forum. ###############
#### 2005.11.03 05:45 - km salvaged preexisting hidden form vals. ###############
#### 2005.10.31 01:35 - km corrected for-loop which missed last SelectPlayer.#############
#### 2005.10.31 01:05 - km changed screen mode condition for chat option. ###############
#### 2005.10.30 23:59 - km added fBuildCell using $laBoard values. ###############
#### 2005.10.30 19:45 - km fBuildGui now requires first "Board-Array" arg. ###############
#### 2005.10.30 04:35 - km oops - commented out alerts. ###############
#### 2005.10.30 01:40 - km conditional includeChat choice. ###############
#### 2005.10.30 01:30 - km added $vhLastState for refresh of forum. ###############
#### 2005.10.30 01:00 - km ADDED JAVASCRIPT SETMOVE to cell images. ###############
#### 2005.10.29 08:00 - km added $vhLastState for refresh of forum. ###############
#### 2005.10.29 04:35 - km modified other player selector to auto submit. ###############
#### 2005.10.29 02:30 - km modified to suppert populating SelectPlayers. ###############
#### 2005.10.29 02:30 - km modified Test to say Override fGetRequest. ###############
#### 2005.10.26 19:40 - km added $ulShowVersions for testing. ###############
#### 2005.10.26 19:40 - km - modified test html text. ###############
#### 2005.10.26 18:40 - km - added definitions. ###############
#### 2005.10.25 04:20 - km Added GUI testing vars (btn & text field). ###############
#### 2005.10.25 10:25 - km added utilize last form variables eg. #########################
#### 'vcIncludeChat' ###############
#### 2005.10.25 08:00 - km added State & msg args ###############
#### 2005.10.24 11:12 - km added line for printing inputs, reformatted. ###############
#### 2005.10.24 08:20 - km EDITED args. ###############
#### 2005.10.24 05:55 - km Added Forum Features. ###############
#### 2005.10.24 03:45 - km Replaced print's with HereDoc Variables. ###############
#### 2005.10.23 04:15 - km Improved documentation (Board States). ###############
#### 2005.10.22 19:35 - km ADDED row/col 'Move' hidden fields. ###############
#### 2005.10.22 17:15 - km ADDED Board colors & Chess Set selectors. ###############
#### 2005.10.21 20:50 - km EDITED btn NAMES ###############
#### 2005.10.20 21:00 - km - NO EDITED Req'd for VAR NAMES new conventions ###############
#### 2005.10.19.05:15 - km completed static html display ###############
#### 2005.10.19.02:00 - km added test method oBuildGui.fPrintArg ###############
#### 2005.10.17.03:00 - km adde Title block ###############
##########################################################################################
##########################################################################################
#### Status: !! LOCKED !! by KM ##########################################################
#### Kristal McKinstry has volunteered to write this entire object #######################
##########################################################################################
##########################################################################################
#### Description: ##############################
#### ##############################
#### Generates form with requested board state. ##############################
#### Handed a board and game/player info to create form. ##############################
#### ##############################
#### This module is mode based. It sequentially goes through the ####################
#### construction process and supplies arguments based on mode. ####################
#### ##############################
#### oBuildGui will use oCFV to determine if oGame and oBoard exist. ###################
####>> #######
####>> !! BOARD STATES !! #######
####>> #######
####>> Additional game window link is always available. #######
####>> Select-colors, Select-set, and Set-refresh are always available if logged. #######
####>> #######
####>> Splash screen (not logged-in) #######
####>> .. screen options: Log-in. #######
####>> #######
####>> Logged-in, waiting #######
####>> .. screen options: Log-out. #######
####>> #######
####>> [C] Logged-in, waiting, other player available #######
####>> .. screen options: Log-out, SelectPlayer #######
####>> #######
####>> [D] Logged-in, other selected, you and other have saved games available. #######
####>> .. screen options: Log-out, Select-saved-game(includes new game option) #######
####>> #######
####>> [E] Logged-in, game-in-progress, others turn. #######
####>> .. screen options: Quit-game, Log-out #######
####>> #######
####>> [F] Logged-in, game-in-progress, your turn. #######
####>> .. screen options: Quit-game, Log-out, Move(hidden feature) #######
####>> #######
#### ######################
##########################################################################################
##########################################################################################
##########################################################################################
#### Agenda: #############################################################################
#### [] Utilize aesthetic settings (color and pieces). #################
#### [] Finish $lsState under HiddenInputs for forum usage. #################
#### [] Make script and no-script versions of Move option. #################
#### [] utilize last form variables. See eg. 'vcIncludeChat'in body. #################
#### [] add QuitGame btn, ChooseGame selector #################
#### (Involves editing oCollect..rp & sSet..rsp) #################
#### oCFV->fGetRequestType will need to analyze those values #################
#### fBuildGui will need to show these controls. #################
#### [] Replace cell backgrounds with user colors and images (animated water/fire) #####
#### [] Build table from zolfege type array w/ laBoard #################
##########################################################################################
##########################################################################################
#### Programmer: Kristal McKinstry #################
##########################################################################################
##########################################################################################
####
##>> OPTIONS:
/*
$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)
*/
##########################################################################################
class oBuildGui {
function fBuildGui ($laBoard, &$loCFV, $laGui){
$lsMsg = $laGui['Text'];
$lsJavascript = <<<SKRIPT
<SCRIPT LANGUAGE="JavaScript">
function setmove(x, y){
if (document.form1.vhMoveFromRow.value == '0'){
document.form1.vhMoveFromRow.value = y;
document.form1.vhMoveFromCol.value = x;
}
else {
document.form1.vhMoveToRow.value = y;
document.form1.vhMoveToCol.value = x;
document.form1.submit();
};
}
</SCRIPT>
SKRIPT;
##alert(x); //useful javascript debugger
$lsHeader = '<html><head><title>Online Chess Game</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">';
$lsHeader .= '<link href=\"chess.css\" rel=\"stylesheet\" type=\"text/css\">';
if ($laGui['Move']) $lsHeader .= $lsJavascript;
$lsHeader .= '</head>';
if (!$laGui['PriorVals']){
$lsHiddenInputs = <<<HIDDENINPUTS
<input name="vhPlayer" type="hidden" id="vhPlayer" value="zilch">
<input name="vhMoveFromRow" type="hidden" id="vhMoveFromRow" value='0'>
<input name="vhMoveFromCol" type="hidden" id="vhMoveFromCol" value='0'>
<input name="vhMoveToRow" type="hidden" id="vhMoveToRow" value='0'>
<input name="vhMoveToCol" type="hidden" id="vhMoveToCol" value='0'>
HIDDENINPUTS;
}//end-if
else {
$lsPlayer = $loCFV->fGetVal('vhPlayer');
$lsHiddenInputs = '';
$lsHiddenInputs .= "<input name='vhPlayer' type='hidden' id='vhPlayer' value='$lsPlayer'>";
$lsHiddenInputs .= "<input name='vhMoveFromRow' type='hidden' id='vhMoveFromRow' value='0'>";
$lsHiddenInputs .= "<input name='vhMoveFromCol' type='hidden' id='vhMoveFromCol' value='0'>";
$lsHiddenInputs .= "<input name='vhMoveToRow' type='hidden' id='vhMoveToRow' value='0'>";
$lsHiddenInputs .= "<input name='vhMoveToCol' type='hidden' id='vhMoveToCol' value='0'>";
}//end-else
$lsInputs = '';
if ($laGui['LogIn']) {$lsInputs .= '<input name="vtPlayer" type="text" onFocus="this.value=\'\';" value="Enter name"><input name="vbLogIn" type="submit" id="vbLogIn" value="Log-in"><br />';}
if ($laGui['CheckStatus']) {$lsInputs .= '<input name="vbCheck" type="submit" id="vbCheck" value="Check Status"><br />';}
if ($laGui['LogOut']) {$lsInputs .= '<input name="vbLogOut" type="submit" id="vbLogOut" value="Log-out"><br />';}
if ($laGui['SelectOther']) {
$lsSelectOther = '<select name="vsOtherPlayer" onChange="this.form.submit();"><option value="0" selected>Select Player! </option>';
// for loop: <option value="1">Next Player</option>
$laOthers = $loCFV->fGetVal('uaOthers');
$N = count($laOthers);
for ($X=0; $X!=$N; $X++){
$lsSelectOther .= "<option value=\"";
$lsSelectOther .= $laOthers[$X][0];
$lsSelectOther .= "\">";
$lsSelectOther .= $laOthers[$X][0];
$lsSelectOther .= '</option>';
}//end-for
$lsSelectOther .= '</select><br>';
$lsInputs .= $lsSelectOther;
}//end-if
if ($laGui['Move']) {$lsInputs .= '<p><select name="vsMove"><option value="0" selected>Special moves.. </option><option value="1" >Castle - short </option><option value="2" >Castle - long </option><option value="3" >Declare "check" </option><option value="4" >Declare "check-mate" </option><option value="5" >En passant attack </option></select></p>';}
$lsInputs .= '<p></p>';
if ($laGui['Aesthetics']) {$lsInputs .= '<select name="vsColors"><option value="0" selected>Board colors.. </option><option value="1" >Green & Purple </option></select><br />';}
if ($laGui['Aesthetics']) {$lsInputs .= '<select name="vsSet"><option value="0" selected>Chess set.. </option><option value="1" >Scribbles </option></select><br />';}
if ($laGui['incChat']) {
$lsInputs .= '<span class="forumcontrols">Include Chat feature?</span><input type="checkbox" name="vcIncludeChat" value="yes"';
if ($loCFV->fGetVal('vcIncludeChat') == 'yes') {$lsInputs .= ' checked';}
$lsInputs .= '>';
$lsInputs .= '<p><a href="chess.php" class="forumcontrols" target="_blank">additional game...</a></p>';
$lsInputs .= '<p><a href="http://www.chessvariants.com/d.chess/chess.html" class="forumcontrols" target="_blank">rules of chess...</a></p>';
}//end-if
function fBuildCell($laBoard, &$lsAddToString, $liY, $liX){
$liX--; //because array starts at 0.
$liY--; //because array starts at 0.
$lsCellA = '<td class="';
if ((1&($liX+$liY))) $lsCellB = 'celllight';//if X+Y=odd
else $lsCellB = 'celldark';//if X+Y=even
$lsCellC = '"><img src="images/';
$lsCellD = 'scribbles';
$lsCellE= '/';
$lsCellF = $laBoard[$liY][$liX];
$lsCellG = '.gif" width="64" height="64" onclick="setmove(this.parentNode.cellIndex, this.parentNode.parentNode.rowIndex)"></td>';
$lsCellComplete = $lsCellA.$lsCellB.$lsCellC.$lsCellD.$lsCellE.$lsCellF.$lsCellG;
$lsAddToString .= $lsCellComplete;
}//end-func
$lsBoardTable = '<table width="100%" border="1">';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray"> </td>';
$lsBoardTable .= '<td class="cellgray">a</td>';
$lsBoardTable .= '<td class="cellgray">b</td>';
$lsBoardTable .= '<td class="cellgray">c</td>';
$lsBoardTable .= '<td class="cellgray">d</td>';
$lsBoardTable .= '<td class="cellgray">e</td>';
$lsBoardTable .= '<td class="cellgray">f</td>';
$lsBoardTable .= '<td class="cellgray">g</td>';
$lsBoardTable .= '<td class="cellgray">h</td>';
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">8</td>';
fBuildCell($laBoard, $lsBoardTable, 1, 1);
fBuildCell($laBoard, $lsBoardTable, 1, 2);
fBuildCell($laBoard, $lsBoardTable, 1, 3);
fBuildCell($laBoard, $lsBoardTable, 1, 4);
fBuildCell($laBoard, $lsBoardTable, 1, 5);
fBuildCell($laBoard, $lsBoardTable, 1, 6);
fBuildCell($laBoard, $lsBoardTable, 1, 7);
fBuildCell($laBoard, $lsBoardTable, 1, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">7</td>';
fBuildCell($laBoard, $lsBoardTable, 2, 1);
fBuildCell($laBoard, $lsBoardTable, 2, 2);
fBuildCell($laBoard, $lsBoardTable, 2, 3);
fBuildCell($laBoard, $lsBoardTable, 2, 4);
fBuildCell($laBoard, $lsBoardTable, 2, 5);
fBuildCell($laBoard, $lsBoardTable, 2, 6);
fBuildCell($laBoard, $lsBoardTable, 2, 7);
fBuildCell($laBoard, $lsBoardTable, 2, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">6</td>';
fBuildCell($laBoard, $lsBoardTable, 3, 1);
fBuildCell($laBoard, $lsBoardTable, 3, 2);
fBuildCell($laBoard, $lsBoardTable, 3, 3);
fBuildCell($laBoard, $lsBoardTable, 3, 4);
fBuildCell($laBoard, $lsBoardTable, 3, 5);
fBuildCell($laBoard, $lsBoardTable, 3, 6);
fBuildCell($laBoard, $lsBoardTable, 3, 7);
fBuildCell($laBoard, $lsBoardTable, 3, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">5</td>';
fBuildCell($laBoard, $lsBoardTable, 4, 1);
fBuildCell($laBoard, $lsBoardTable, 4, 2);
fBuildCell($laBoard, $lsBoardTable, 4, 3);
fBuildCell($laBoard, $lsBoardTable, 4, 4);
fBuildCell($laBoard, $lsBoardTable, 4, 5);
fBuildCell($laBoard, $lsBoardTable, 4, 6);
fBuildCell($laBoard, $lsBoardTable, 4, 7);
fBuildCell($laBoard, $lsBoardTable, 4, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">3</td>';
fBuildCell($laBoard, $lsBoardTable, 5, 1);
fBuildCell($laBoard, $lsBoardTable, 5, 2);
fBuildCell($laBoard, $lsBoardTable, 5, 3);
fBuildCell($laBoard, $lsBoardTable, 5, 4);
fBuildCell($laBoard, $lsBoardTable, 5, 5);
fBuildCell($laBoard, $lsBoardTable, 5, 6);
fBuildCell($laBoard, $lsBoardTable, 5, 7);
fBuildCell($laBoard, $lsBoardTable, 5, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">2</td>';
fBuildCell($laBoard, $lsBoardTable, 6, 1);
fBuildCell($laBoard, $lsBoardTable, 6, 2);
fBuildCell($laBoard, $lsBoardTable, 6, 3);
fBuildCell($laBoard, $lsBoardTable, 6, 4);
fBuildCell($laBoard, $lsBoardTable, 6, 5);
fBuildCell($laBoard, $lsBoardTable, 6, 6);
fBuildCell($laBoard, $lsBoardTable, 6, 7);
fBuildCell($laBoard, $lsBoardTable, 6, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">1</td>';
fBuildCell($laBoard, $lsBoardTable, 7, 1);
fBuildCell($laBoard, $lsBoardTable, 7, 2);
fBuildCell($laBoard, $lsBoardTable, 7, 3);
fBuildCell($laBoard, $lsBoardTable, 7, 4);
fBuildCell($laBoard, $lsBoardTable, 7, 5);
fBuildCell($laBoard, $lsBoardTable, 7, 6);
fBuildCell($laBoard, $lsBoardTable, 7, 7);
fBuildCell($laBoard, $lsBoardTable, 7, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">1</td>';
fBuildCell($laBoard, $lsBoardTable, 8, 1);
fBuildCell($laBoard, $lsBoardTable, 8, 2);
fBuildCell($laBoard, $lsBoardTable, 8, 3);
fBuildCell($laBoard, $lsBoardTable, 8, 4);
fBuildCell($laBoard, $lsBoardTable, 8, 5);
fBuildCell($laBoard, $lsBoardTable, 8, 6);
fBuildCell($laBoard, $lsBoardTable, 8, 7);
fBuildCell($laBoard, $lsBoardTable, 8, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '</table>';
print($lsHeader);
//<body bgcolor="#003366"> // From css.topmost.color
print('<p class="topmost"> </p>');
print('<form name="form1" ID="form1" method="post" action="chess.php">');
/*
print('<font color="#FB3715" size="6">No Meeting HALLOWEEN night.</font><font color="#FB3715" size="4">
See forum questions or group email.</font>
');
*/
print($lsHiddenInputs);
print('<table width="100%" border="1">');
print(' <tr>');
print(' <td> <p><img src="../horuslogospectrum.gif" width="144" height="144"> </p>');
print(' <p class="topmost">CS85 - Chess match</p>');
print(" <p class='alert'>$lsMsg</p>");
print(' <p> </p><p>');
print ($lsInputs);
print(' </td>');
print(' <td>');
print ($lsBoardTable);
print(' </td>');
print(' </tr>');
print('</table>');
if ($laGui['Forum']) {
print(oForum::fGetFormHtml($loCFV->fGetForumSettings())); // VOILA! - call to abstract function !!
##$loF = new oForum($loCFV->fGetVal('vhPlayer'));
$loF = new oForum();
print($loF->fGetPostingsHtml(&$loCFV));
}//end-if body
print('</form>');
print('</body>');
print('</html>');
}//end-fBuildGui
}//end-oBuildGui
?>
// en passant attack
##########################################################################################
######################### SMC CS85 CHESS PROGRAM #########################################
#### ATTENTION: Now requires renamed extended chess piece gif's! #########################
##########################################################################################
if ($ulShowVersions) print('
#### oBuildGui.rphj ######################################################################<br />
#### 2005.11.09 23:50 - km en passant option. ###############<br />
#### 2005.11.09 23:50 - km deleted echocall. ###############<br />
#### 2005.11.09 21:15 - km revised contructor call to oForum. ###############<br />
#### 2005.11.06 06:45 - km fBuildGui now uses $laGui arg instead of $lsState & Msg.#######<br />
#### 2005.11.06 03:45 - km deleted hidden vars: submitter,submit,formId,LastState ########<br />
#### 2005.11.06 03:00 - km deleted test fields. ###############<br />');
#### 2005.11.05 02:25 - km clears LogIn text box when focused. ###############
#### 2005.11.05 02:15 - km deleted refresh seconds button. ###############
#### 2005.11.04 23:40 - km added button vbCheck to see if players arrive. ###############
#### 2005.11.04 20:00 - km deleted refresh meta. Doesnt POST. ###############
#### 2005.11.04 20:00 - km added conditional refresh meta to header. ###############
#### 2005.11.04 02:05 - km Javascript for Move only if their turn to move. ###############
#### 2005.11.03 05:45 - km worked on forum. ###############
#### 2005.11.03 05:45 - km salvaged preexisting hidden form vals. ###############
#### 2005.10.31 01:35 - km corrected for-loop which missed last SelectPlayer.#############
#### 2005.10.31 01:05 - km changed screen mode condition for chat option. ###############
#### 2005.10.30 23:59 - km added fBuildCell using $laBoard values. ###############
#### 2005.10.30 19:45 - km fBuildGui now requires first "Board-Array" arg. ###############
#### 2005.10.30 04:35 - km oops - commented out alerts. ###############
#### 2005.10.30 01:40 - km conditional includeChat choice. ###############
#### 2005.10.30 01:30 - km added $vhLastState for refresh of forum. ###############
#### 2005.10.30 01:00 - km ADDED JAVASCRIPT SETMOVE to cell images. ###############
#### 2005.10.29 08:00 - km added $vhLastState for refresh of forum. ###############
#### 2005.10.29 04:35 - km modified other player selector to auto submit. ###############
#### 2005.10.29 02:30 - km modified to suppert populating SelectPlayers. ###############
#### 2005.10.29 02:30 - km modified Test to say Override fGetRequest. ###############
#### 2005.10.26 19:40 - km added $ulShowVersions for testing. ###############
#### 2005.10.26 19:40 - km - modified test html text. ###############
#### 2005.10.26 18:40 - km - added definitions. ###############
#### 2005.10.25 04:20 - km Added GUI testing vars (btn & text field). ###############
#### 2005.10.25 10:25 - km added utilize last form variables eg. #########################
#### 'vcIncludeChat' ###############
#### 2005.10.25 08:00 - km added State & msg args ###############
#### 2005.10.24 11:12 - km added line for printing inputs, reformatted. ###############
#### 2005.10.24 08:20 - km EDITED args. ###############
#### 2005.10.24 05:55 - km Added Forum Features. ###############
#### 2005.10.24 03:45 - km Replaced print's with HereDoc Variables. ###############
#### 2005.10.23 04:15 - km Improved documentation (Board States). ###############
#### 2005.10.22 19:35 - km ADDED row/col 'Move' hidden fields. ###############
#### 2005.10.22 17:15 - km ADDED Board colors & Chess Set selectors. ###############
#### 2005.10.21 20:50 - km EDITED btn NAMES ###############
#### 2005.10.20 21:00 - km - NO EDITED Req'd for VAR NAMES new conventions ###############
#### 2005.10.19.05:15 - km completed static html display ###############
#### 2005.10.19.02:00 - km added test method oBuildGui.fPrintArg ###############
#### 2005.10.17.03:00 - km adde Title block ###############
##########################################################################################
##########################################################################################
#### Status: !! LOCKED !! by KM ##########################################################
#### Kristal McKinstry has volunteered to write this entire object #######################
##########################################################################################
##########################################################################################
#### Description: ##############################
#### ##############################
#### Generates form with requested board state. ##############################
#### Handed a board and game/player info to create form. ##############################
#### ##############################
#### This module is mode based. It sequentially goes through the ####################
#### construction process and supplies arguments based on mode. ####################
#### ##############################
#### oBuildGui will use oCFV to determine if oGame and oBoard exist. ###################
####>> #######
####>> !! BOARD STATES !! #######
####>> #######
####>> Additional game window link is always available. #######
####>> Select-colors, Select-set, and Set-refresh are always available if logged. #######
####>> #######
####>> Splash screen (not logged-in) #######
####>> .. screen options: Log-in. #######
####>> #######
####>> Logged-in, waiting #######
####>> .. screen options: Log-out. #######
####>> #######
####>> [C] Logged-in, waiting, other player available #######
####>> .. screen options: Log-out, SelectPlayer #######
####>> #######
####>> [D] Logged-in, other selected, you and other have saved games available. #######
####>> .. screen options: Log-out, Select-saved-game(includes new game option) #######
####>> #######
####>> [E] Logged-in, game-in-progress, others turn. #######
####>> .. screen options: Quit-game, Log-out #######
####>> #######
####>> [F] Logged-in, game-in-progress, your turn. #######
####>> .. screen options: Quit-game, Log-out, Move(hidden feature) #######
####>> #######
#### ######################
##########################################################################################
##########################################################################################
##########################################################################################
#### Agenda: #############################################################################
#### [] Utilize aesthetic settings (color and pieces). #################
#### [] Finish $lsState under HiddenInputs for forum usage. #################
#### [] Make script and no-script versions of Move option. #################
#### [] utilize last form variables. See eg. 'vcIncludeChat'in body. #################
#### [] add QuitGame btn, ChooseGame selector #################
#### (Involves editing oCollect..rp & sSet..rsp) #################
#### oCFV->fGetRequestType will need to analyze those values #################
#### fBuildGui will need to show these controls. #################
#### [] Replace cell backgrounds with user colors and images (animated water/fire) #####
#### [] Build table from zolfege type array w/ laBoard #################
##########################################################################################
##########################################################################################
#### Programmer: Kristal McKinstry #################
##########################################################################################
##########################################################################################
####
##>> OPTIONS:
/*
$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)
*/
##########################################################################################
class oBuildGui {
function fBuildGui ($laBoard, &$loCFV, $laGui){
$lsMsg = $laGui['Text'];
$lsJavascript = <<<SKRIPT
<SCRIPT LANGUAGE="JavaScript">
function setmove(x, y){
if (document.form1.vhMoveFromRow.value == '0'){
document.form1.vhMoveFromRow.value = y;
document.form1.vhMoveFromCol.value = x;
}
else {
document.form1.vhMoveToRow.value = y;
document.form1.vhMoveToCol.value = x;
document.form1.submit();
};
}
</SCRIPT>
SKRIPT;
##alert(x); //useful javascript debugger
$lsHeader = '<html><head><title>Online Chess Game</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">';
$lsHeader .= '<link href=\"chess.css\" rel=\"stylesheet\" type=\"text/css\">';
if ($laGui['Move']) $lsHeader .= $lsJavascript;
$lsHeader .= '</head>';
if (!$laGui['PriorVals']){
$lsHiddenInputs = <<<HIDDENINPUTS
<input name="vhPlayer" type="hidden" id="vhPlayer" value="zilch">
<input name="vhMoveFromRow" type="hidden" id="vhMoveFromRow" value='0'>
<input name="vhMoveFromCol" type="hidden" id="vhMoveFromCol" value='0'>
<input name="vhMoveToRow" type="hidden" id="vhMoveToRow" value='0'>
<input name="vhMoveToCol" type="hidden" id="vhMoveToCol" value='0'>
HIDDENINPUTS;
}//end-if
else {
$lsPlayer = $loCFV->fGetVal('vhPlayer');
$lsHiddenInputs = '';
$lsHiddenInputs .= "<input name='vhPlayer' type='hidden' id='vhPlayer' value='$lsPlayer'>";
$lsHiddenInputs .= "<input name='vhMoveFromRow' type='hidden' id='vhMoveFromRow' value='0'>";
$lsHiddenInputs .= "<input name='vhMoveFromCol' type='hidden' id='vhMoveFromCol' value='0'>";
$lsHiddenInputs .= "<input name='vhMoveToRow' type='hidden' id='vhMoveToRow' value='0'>";
$lsHiddenInputs .= "<input name='vhMoveToCol' type='hidden' id='vhMoveToCol' value='0'>";
}//end-else
$lsInputs = '';
if ($laGui['LogIn']) {$lsInputs .= '<input name="vtPlayer" type="text" onFocus="this.value=\'\';" value="Enter name"><input name="vbLogIn" type="submit" id="vbLogIn" value="Log-in"><br />';}
if ($laGui['CheckStatus']) {$lsInputs .= '<input name="vbCheck" type="submit" id="vbCheck" value="Check Status"><br />';}
if ($laGui['LogOut']) {$lsInputs .= '<input name="vbLogOut" type="submit" id="vbLogOut" value="Log-out"><br />';}
if ($laGui['SelectOther']) {
$lsSelectOther = '<select name="vsOtherPlayer" onChange="this.form.submit();"><option value="0" selected>Select Player! </option>';
// for loop: <option value="1">Next Player</option>
$laOthers = $loCFV->fGetVal('uaOthers');
$N = count($laOthers);
for ($X=0; $X!=$N; $X++){
$lsSelectOther .= "<option value=\"";
$lsSelectOther .= $laOthers[$X][0];
$lsSelectOther .= "\">";
$lsSelectOther .= $laOthers[$X][0];
$lsSelectOther .= '</option>';
}//end-for
$lsSelectOther .= '</select><br>';
$lsInputs .= $lsSelectOther;
}//end-if
if ($laGui['Move']) {$lsInputs .= '<p><select name="vsMove"><option value="0" selected>Special moves.. </option><option value="1" >Castle - short </option><option value="2" >Castle - long </option><option value="3" >Declare "check" </option><option value="4" >Declare "check-mate" </option><option value="5" >En passant attack </option></select></p>';}
$lsInputs .= '<p></p>';
if ($laGui['Aesthetics']) {$lsInputs .= '<select name="vsColors"><option value="0" selected>Board colors.. </option><option value="1" >Green & Purple </option></select><br />';}
if ($laGui['Aesthetics']) {$lsInputs .= '<select name="vsSet"><option value="0" selected>Chess set.. </option><option value="1" >Scribbles </option></select><br />';}
if ($laGui['incChat']) {
$lsInputs .= '<span class="forumcontrols">Include Chat feature?</span><input type="checkbox" name="vcIncludeChat" value="yes"';
if ($loCFV->fGetVal('vcIncludeChat') == 'yes') {$lsInputs .= ' checked';}
$lsInputs .= '>';
$lsInputs .= '<p><a href="chess.php" class="forumcontrols" target="_blank">additional game...</a></p>';
$lsInputs .= '<p><a href="http://www.chessvariants.com/d.chess/chess.html" class="forumcontrols" target="_blank">rules of chess...</a></p>';
}//end-if
function fBuildCell($laBoard, &$lsAddToString, $liY, $liX){
$liX--; //because array starts at 0.
$liY--; //because array starts at 0.
$lsCellA = '<td class="';
if ((1&($liX+$liY))) $lsCellB = 'celllight';//if X+Y=odd
else $lsCellB = 'celldark';//if X+Y=even
$lsCellC = '"><img src="images/';
$lsCellD = 'scribbles';
$lsCellE= '/';
$lsCellF = $laBoard[$liY][$liX];
$lsCellG = '.gif" width="64" height="64" onclick="setmove(this.parentNode.cellIndex, this.parentNode.parentNode.rowIndex)"></td>';
$lsCellComplete = $lsCellA.$lsCellB.$lsCellC.$lsCellD.$lsCellE.$lsCellF.$lsCellG;
$lsAddToString .= $lsCellComplete;
}//end-func
$lsBoardTable = '<table width="100%" border="1">';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray"> </td>';
$lsBoardTable .= '<td class="cellgray">a</td>';
$lsBoardTable .= '<td class="cellgray">b</td>';
$lsBoardTable .= '<td class="cellgray">c</td>';
$lsBoardTable .= '<td class="cellgray">d</td>';
$lsBoardTable .= '<td class="cellgray">e</td>';
$lsBoardTable .= '<td class="cellgray">f</td>';
$lsBoardTable .= '<td class="cellgray">g</td>';
$lsBoardTable .= '<td class="cellgray">h</td>';
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">8</td>';
fBuildCell($laBoard, $lsBoardTable, 1, 1);
fBuildCell($laBoard, $lsBoardTable, 1, 2);
fBuildCell($laBoard, $lsBoardTable, 1, 3);
fBuildCell($laBoard, $lsBoardTable, 1, 4);
fBuildCell($laBoard, $lsBoardTable, 1, 5);
fBuildCell($laBoard, $lsBoardTable, 1, 6);
fBuildCell($laBoard, $lsBoardTable, 1, 7);
fBuildCell($laBoard, $lsBoardTable, 1, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">7</td>';
fBuildCell($laBoard, $lsBoardTable, 2, 1);
fBuildCell($laBoard, $lsBoardTable, 2, 2);
fBuildCell($laBoard, $lsBoardTable, 2, 3);
fBuildCell($laBoard, $lsBoardTable, 2, 4);
fBuildCell($laBoard, $lsBoardTable, 2, 5);
fBuildCell($laBoard, $lsBoardTable, 2, 6);
fBuildCell($laBoard, $lsBoardTable, 2, 7);
fBuildCell($laBoard, $lsBoardTable, 2, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">6</td>';
fBuildCell($laBoard, $lsBoardTable, 3, 1);
fBuildCell($laBoard, $lsBoardTable, 3, 2);
fBuildCell($laBoard, $lsBoardTable, 3, 3);
fBuildCell($laBoard, $lsBoardTable, 3, 4);
fBuildCell($laBoard, $lsBoardTable, 3, 5);
fBuildCell($laBoard, $lsBoardTable, 3, 6);
fBuildCell($laBoard, $lsBoardTable, 3, 7);
fBuildCell($laBoard, $lsBoardTable, 3, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">5</td>';
fBuildCell($laBoard, $lsBoardTable, 4, 1);
fBuildCell($laBoard, $lsBoardTable, 4, 2);
fBuildCell($laBoard, $lsBoardTable, 4, 3);
fBuildCell($laBoard, $lsBoardTable, 4, 4);
fBuildCell($laBoard, $lsBoardTable, 4, 5);
fBuildCell($laBoard, $lsBoardTable, 4, 6);
fBuildCell($laBoard, $lsBoardTable, 4, 7);
fBuildCell($laBoard, $lsBoardTable, 4, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">3</td>';
fBuildCell($laBoard, $lsBoardTable, 5, 1);
fBuildCell($laBoard, $lsBoardTable, 5, 2);
fBuildCell($laBoard, $lsBoardTable, 5, 3);
fBuildCell($laBoard, $lsBoardTable, 5, 4);
fBuildCell($laBoard, $lsBoardTable, 5, 5);
fBuildCell($laBoard, $lsBoardTable, 5, 6);
fBuildCell($laBoard, $lsBoardTable, 5, 7);
fBuildCell($laBoard, $lsBoardTable, 5, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">2</td>';
fBuildCell($laBoard, $lsBoardTable, 6, 1);
fBuildCell($laBoard, $lsBoardTable, 6, 2);
fBuildCell($laBoard, $lsBoardTable, 6, 3);
fBuildCell($laBoard, $lsBoardTable, 6, 4);
fBuildCell($laBoard, $lsBoardTable, 6, 5);
fBuildCell($laBoard, $lsBoardTable, 6, 6);
fBuildCell($laBoard, $lsBoardTable, 6, 7);
fBuildCell($laBoard, $lsBoardTable, 6, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">1</td>';
fBuildCell($laBoard, $lsBoardTable, 7, 1);
fBuildCell($laBoard, $lsBoardTable, 7, 2);
fBuildCell($laBoard, $lsBoardTable, 7, 3);
fBuildCell($laBoard, $lsBoardTable, 7, 4);
fBuildCell($laBoard, $lsBoardTable, 7, 5);
fBuildCell($laBoard, $lsBoardTable, 7, 6);
fBuildCell($laBoard, $lsBoardTable, 7, 7);
fBuildCell($laBoard, $lsBoardTable, 7, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '<tr>';
$lsBoardTable .= '<td class="cellgray">1</td>';
fBuildCell($laBoard, $lsBoardTable, 8, 1);
fBuildCell($laBoard, $lsBoardTable, 8, 2);
fBuildCell($laBoard, $lsBoardTable, 8, 3);
fBuildCell($laBoard, $lsBoardTable, 8, 4);
fBuildCell($laBoard, $lsBoardTable, 8, 5);
fBuildCell($laBoard, $lsBoardTable, 8, 6);
fBuildCell($laBoard, $lsBoardTable, 8, 7);
fBuildCell($laBoard, $lsBoardTable, 8, 8);
$lsBoardTable .= '</tr>';
$lsBoardTable .= '</table>';
print($lsHeader);
//<body bgcolor="#003366"> // From css.topmost.color
print('<p class="topmost"> </p>');
print('<form name="form1" ID="form1" method="post" action="chess.php">');
/*
print('<font color="#FB3715" size="6">No Meeting HALLOWEEN night.</font><font color="#FB3715" size="4">
See forum questions or group email.</font>
');
*/
print($lsHiddenInputs);
print('<table width="100%" border="1">');
print(' <tr>');
print(' <td> <p><img src="../horuslogospectrum.gif" width="144" height="144"> </p>');
print(' <p class="topmost">CS85 - Chess match</p>');
print(" <p class='alert'>$lsMsg</p>");
print(' <p> </p><p>');
print ($lsInputs);
print(' </td>');
print(' <td>');
print ($lsBoardTable);
print(' </td>');
print(' </tr>');
print('</table>');
if ($laGui['Forum']) {
print(oForum::fGetFormHtml($loCFV->fGetForumSettings())); // VOILA! - call to abstract function !!
##$loF = new oForum($loCFV->fGetVal('vhPlayer'));
$loF = new oForum();
print($loF->fGetPostingsHtml(&$loCFV));
}//end-if body
print('</form>');
print('</body>');
print('</html>');
}//end-fBuildGui
}//end-oBuildGui
?>