Post by Kristal Rose Phoenix McKinstry on Oct 17, 2005 3:30:51 GMT -5
<?php
##########################################################################################
######################### SMC CS85 CHESS PROGRAM #########################################
##########################################################################################
if ($ulShowVersions) print('
//fGetWinner
#### oBoard.rpq ##########################################################################<br />
#### 2005.12.12 22:15 - km added oGame->fSetWinner($lsGameId=zilch, $lsWinnerId).#########<br />
#### 2005.12.12 22:00 - km added oBoard->fTestWinner($laBoard). ###############<br />
#### 2005.12.12 20:00 - km fCommitMove special-move arg (castling). ###############<br />
#### 2005.12.12 18:00 - km getBoard Alt arg. ###############<br />
#### 2005.11.11 18:00 - km disabled oGame->fTestMove. ###############<br />
#### 2005.11.07 04:00 - km removed debugging aids. ###############<br />
#### 2005.11.06 01:00 - km streamlined fGetCurrentBoard & fCommitMove by ###############<br />
#### 2005.11.06 01:00 - using fGetCurrentTurnNum. ###############<br />');
#### 2005.11.05 09:15 - km did oBoard->fGetPiece & fSetPiece & fApplyMove ###############
#### 2005.11.05 09:15 - km did oGame->fGetCurrentBoard & fCommitMove ###############
#### 2005.11.05 03:45 - km added/finished oBoard->fGetBoardArray(). ###############
#### 2005.11.05 02:30 - km fTestMove returns true for now. ###############
#### 2005.11.05 00:45 - km wrote code for fToggleTurn($lsGameId=!zilch!). ###############
#### 2005.11.03 23:55 - km moved fLoadBoard and fSaveBoard from oboard to oGame. #########
#### 2005.11.03 23:55 - km oBoard functions have Set-this flags now. ###############
#### 2005.11.03 23:50 - km added oBoard->fGetPiece & fApplyMove. ###############
#### 2005.11.03 16:35 - km new function skeletons and oGame class. ###############
#### 2005.11.01 17:00 - km ###############
#### 2005.10.30 19:15 - km modified fGetNewBoard and piece naming protocol.###############
#### 2005.10.26 19:40 - km added $ulShowVersions for testing. ###############
#### 2005.10.20 20:50 - km EDITED VAR NAMES for consistency with new conventions #########
#### 2005.10.19.02:00 - km added test method oBoard.fPrintArg ############################
#### 2005.10.17.03:30 - km added STUB fGetNewBoard #######################################
#### 2005.10.17.02:00 - km added Title block #############################################
##########################################################################################
##########################################################################################
#### Status: Available to edit ###########################################################
##########################################################################################
##########################################################################################
#### Description: ####################################
#### ####################################
#### Look at fGetNewBoard for a sample protocol ####################################
#### b & w (black and white) have been changed to l & d (light & dark) ##############
#### so that one can parse-search for 'b' and find a Bishop, not just ##############
#### any black piece. ##############
#### Pieces are now numbered to uniquely identify pieces for better game ##############
#### processing and better display. Eg. 'dn02' (2nd dark knight). ##############
#### Keeping in mind that pieces can be swapped for other piece, ##############
#### naming protcol is as follows: ##############
#### prefix: 'l' or 'd' (light or dark) ##############
#### 'r'(rook) 01,02 + additional 03-15 ##############
#### 'n'(knight) 01,02 + additional 03-15 ##############
#### 'b'(bishop) 01,02 + additional 03-15 ##############
#### 'q'(queen) 01 + additional 02-15 * #02 probably never used. ##############
#### 'k'(king) 01 *# added for consistency, can't trade in king ##############
#### 'p'(pawn) 01-08 + additional 08-15 ##############
##########################################################################################
#### #############
#### ! A history of boards will be stored for each game. #############
#### #############
##########################################################################################
#### Programmer: Kristal McKinstry #######################################################
##########################################################################################
##########################################################################################
#### Agenda: #############################################################################
#### #####################################
##########################################################################################
##########################################################################################
##########################################################################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class oBoard { // oBoard is used for generic board manipulation utilities.
// oGame manages actual game instances or testing instances (create a new oGame for a testing instance).
var $vaBoard;
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function oBoard($laExistingBoard = 'zilch'){ // Constructor always sets default board.
if ($laExistingBoard == 'zilch') $this->fGetNewBoard(TRUE);
else $this->vaBoard = $laExistingBoard;
return TRUE;
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetNewBoard ($llSet=FALSE){
$laBoard = array(
array('dr01', 'dn01', 'db01', 'dq01', 'dk01', 'db02', 'dn02', 'dr02'),
array('dp01', 'dp02', 'dp03', 'dp04', 'dp05', 'dp06', 'dp07', 'dp08'),
array('ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss'),
array('ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss'),
array('ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss'),
array('ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss'),
array('lp01', 'lp02', 'lp03', 'lp04', 'lp05', 'lp06', 'lp07', 'lp08'),
array('lr01', 'ln01', 'lb01', 'lq01', 'lk01', 'lb02', 'ln02', 'lr02'));
if ($llSet) $this->vaBoard = $laBoard;
return($laBoard);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fFlipBoard($llSet=FALSE, $laBoard='zilch'){
// returns upside down display of a board for second player
if ($laBoard=='zilch') $laBoard = $this->vaBoard;
$laBoard = array_reverse_insides($laBoard);
if ($llSet) $this->vaBoard = $laBoard;
return($laBoard);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetPiece($liX, $liY, $laBoard='zilch'){
$liX = $liX-1;
$liY = $liY-1;
if ($laBoard =='zilch') $laBoard = $this->vaBoard;
$lsPiece = $laBoard[$liY][$liX];
return($lsPiece);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fSetPiece($liX, $liY, $lsPiece, $laBoard='zilch', $llSet=FALSE){
$liX = $liX-1;
$liY = $liY-1;
if ($laBoard =='zilch') $laBoard = $this->vaBoard;
$laBoard[$liY][$liX] = $lsPiece;
if ($llSet) $this->vaBoard = $laBoard;
return($laBoard);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fApplyMove($laMove, $laBoard='zilch', $llSet=FALSE){ //UNTESTED
if ($laBoard='zilch') {
$loB = new oBoard();
$laBoard = $loB->fGetBoardArray();
}//end-if
//Apply move
$lsPiece = $loB->fGetPiece($laMove[1], $laMove[0]);
$loB->fSetPiece($laMove[1], $laMove[0], 'ss');
$loB->fSetPiece($laMove[3], $laMove[2], $lsPiece);
$laBoard = $loB->fGetBoardArray();
if ($llSet) $this->vaBoard = $laBoard;
return($laBoard);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetBoardArray(){
$laBoardArray = $this->vaBoard;
return($laBoardArray);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fTestWinner($laBoard = 'zilch'){
if ($laBoard=='zilch') $laBoard = $this->vaBoard;
$llFoundDarkKing = FALSE;
foreach ($laBoard as $laRow){
if (in_array('dk01', $laRow)) $llFoundDarkKing = TRUE;
} //end-foreach
$llFoundLightKing = FALSE;
foreach ($laBoard as $laRow){
if (in_array('lk01', $laRow)) $llFoundLightKing = TRUE;
} //end-foreach
if (!$llFoundDarkKing) return 1;
if (!$llFoundLightKing) return 2;
else return FALSE;
} //end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
}//end-class
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class oGame {
var $voServer;
var $vsGameId;
var $viTurn;
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function oGame(&$loServer, $lsGameId='zilch'){ ### SET DEFAULTS
$this->voServer = $loServer;
$this->vsGameId = $lsGameId;
// if $lsGameId is supplied, loads that game info from oReg,
// otherwise creates a new game for testing and returns it's GameId.
// Keep in mind that all functions below will apply to an 'INSTANCE' of oGame.
//eg. $loTest07 = new oGame();
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function oDestroyGame($lsGameId='zilch'){
// Removes test game and assosiated boards from qtReg.. & qtBoards.
// Refers to gameId of current object unless another GameId arg is supplied.
if ($lsGameId!='zilch') $this->vsGameId = $lsGameId;
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fToggleTurn($lsGameId='zilch'){
if ($lsGameId!='zilch') $this->vsGameId = $lsGameId;
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
$query = "SELECT DISTINCT qfTurn FROM qtRegisteredGames WHERE qfGameId = '$lsGameId'";
list($liX, $laTable) = mysql_fetch_table_array(mysql_query($query));
$liTurn = $laTable[0][0];
if ($liTurn==1) $liTurn=2;
else $liTurn=1;
$query = "UPDATE qtRegisteredGames SET qfturn=$liTurn WHERE qfGameId = '$lsGameId'";
mysql_query($query);
$this->viTurn = $liTurn;
return($liTurn);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#### function fIsPlayersTurn($lsId){ // method of oRegistration!
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetCurrentBoard($liAltTurnboard='zilch'){
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
if ($liAltTurnboard=='zilch') $liLastTurnNum = $this->fGetCurrentTurnNum();
else $liLastTurnNum = $liAltTurnboard;
$query = "SELECT qfBoardArray FROM qtBoards WHERE qfGameId = '$lsGameId' AND qfTurnNum = $liLastTurnNum;";
list($liX, $laTable) = mysql_fetch_table_array(mysql_query($query));
$laBoard = unserialize($laTable[0][0]);
return($laBoard);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetCurrentTurnNum(){
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
$query = "SELECT qfLastBoard FROM qtRegisteredGames WHERE qfGameId = '$lsGameId'";
list($liX, $laTable) = mysql_fetch_table_array(mysql_query($query));
$liLastTurnNum = $laTable[0][0];
return($liLastTurnNum);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetPriorBoard($liTurn){
//return BoardArray
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fFlipMoveArray($laMove){
//return move-array appropriate for a flipped board.
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fTestMove($laMove, $laBoard='zilch'){
// Should already be that players turn. should examine temp flipped board and flipped
// move-array if player 2's turn.
$loS = $this->voServer;
//$loT = new oTestMove($loS); Would require oCFV
//function fTestMove($laMoveToTest='zilch', $loGame='zilch', $loBoard='zilch'){
//$llCool = $loT->fTestMove();
//return($llCool);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fCommitMove($laMove, $lsSpecialMove='0'){
/*
Uses unflipped board. (No need to ever flip beforehand either except in testing)
Sets this and qtReg..
Uses current board if none in args - get board and board #
- Get via select qtReg.. where $lsGameId
Adds board to qtBoards
*/
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
$liLastTurnNum = $this->fGetCurrentTurnNum();
$query = "SELECT qfBoardArray FROM qtBoards WHERE qfGameId = '$lsGameId' AND qfTurnNum = $liLastTurnNum;";
list($liX, $laTable) = mysql_fetch_table_array(mysql_query($query));
$laBoard = unserialize($laTable[0][0]);
$loB = new oBoard($laBoard);
//Apply move
switch ($lsSpecialMove){ // Some special moves overwrite pieces.
case '0': // no special move
{
$lsPiece = $loB->fGetPiece($laMove[1], $laMove[0]);
$loB->fSetPiece($laMove[1], $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece($laMove[3], $laMove[2], $lsPiece, 'zilch', TRUE);
}
break;
case '1': // castle - short
{
// Col.5to7, 8to6, ss to5, ss to8
$loB->fSetPiece(7, $laMove[0], $loB->fGetPiece(5, $laMove[0]), 'zilch', TRUE);
$loB->fSetPiece(6, $laMove[0], $loB->fGetPiece(8, $laMove[0]), 'zilch', TRUE);
$loB->fSetPiece(5, $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece(8, $laMove[0], 'ss', 'zilch', TRUE);
}
break;
case '2': // castle - long
{
// 1to4, 5to3, ss to1, ss to5
$loB->fSetPiece(4, $laMove[0], $loB->fGetPiece(1, $laMove[0]), 'zilch', TRUE);
$loB->fSetPiece(3, $laMove[0], $loB->fGetPiece(5, $laMove[0]), 'zilch', TRUE);
$loB->fSetPiece(1, $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece(5, $laMove[0], 'ss', 'zilch', TRUE);
}
break;
case '3': // no special move (actually 'check')
{
$lsPiece = $loB->fGetPiece($laMove[1], $laMove[0]);
$loB->fSetPiece($laMove[1], $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece($laMove[3], $laMove[2], $lsPiece, 'zilch', TRUE);
}
break;
case '4': // no special move (actually 'check-mate')
{
$lsPiece = $loB->fGetPiece($laMove[1], $laMove[0]);
$loB->fSetPiece($laMove[1], $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece($laMove[3], $laMove[2], $lsPiece, 'zilch', TRUE);
}
break;
case '5': // en passant
{
$lsPiece = $loB->fGetPiece($laMove[1], $laMove[0]);
$loB->fSetPiece($laMove[1], $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece($laMove[3], $laMove[2], $lsPiece, 'zilch', TRUE);
if ($laMove[2] == 3) $loB->fSetPiece($laMove[3], 4, 'ss', 'zilch', TRUE);
else $loB->fSetPiece($laMove[3], 5, 'ss', 'zilch', TRUE);
}
break;
default:
break;
}//end-switch
$laBoard = $loB->fGetBoardArray();
$lsBoard = serialize($laBoard);
$liLastTurnNum++;
$query = "UPDATE qtRegisteredGames SET qfLastBoard=$liLastTurnNum WHERE qfGameId = '$lsGameId'";
mysql_query($query);
$query = "INSERT INTO qtBoards (qfGameId, qfTurnNum, qfBoardArray) VALUES ('$lsGameId', $liLastTurnNum, '$lsBoard')";
mysql_query($query);
return($laBoard);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fSetWinner($lsGameId='zilch', $lsWinnerId){
if ($lsGameId!='zilch') $this->vsGameId = $lsGameId;
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
$query = "UPDATE qtRegisteredGames SET qfWinner='$lsWinnerId' WHERE qfGameId = '$lsGameId'";
mysql_query($query);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetWinner($lsGameId='zilch'){
if ($lsGameId!='zilch') $this->vsGameId = $lsGameId;
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
$query = "SELECT qfWinner FROM qtRegisteredGames WHERE qfGameId = '$lsGameId'";
list($liX, $laTable) = mysql_fetch_table_array(mysql_query($query));
if ($laTable[0][0]=='zilch') return FALSE;
else return($laTable[0][0]);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fQuitGame($args){
//removes all boards except last
// set this & qtReg Winner to 'quit'.
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fSaveGame($args){
//removes all boards except last
// set this & qtReg Winner to 'saved'.
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
####function fLoadBoard(optional turnnum, optional game else get this){
##set this
##return this
##}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
####function fSaveBoard(turnnum dflt=this, board dflt=this){
##set this
##return this
##}//end-meth
}//end-class
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
?>
##########################################################################################
######################### SMC CS85 CHESS PROGRAM #########################################
##########################################################################################
if ($ulShowVersions) print('
//fGetWinner
#### oBoard.rpq ##########################################################################<br />
#### 2005.12.12 22:15 - km added oGame->fSetWinner($lsGameId=zilch, $lsWinnerId).#########<br />
#### 2005.12.12 22:00 - km added oBoard->fTestWinner($laBoard). ###############<br />
#### 2005.12.12 20:00 - km fCommitMove special-move arg (castling). ###############<br />
#### 2005.12.12 18:00 - km getBoard Alt arg. ###############<br />
#### 2005.11.11 18:00 - km disabled oGame->fTestMove. ###############<br />
#### 2005.11.07 04:00 - km removed debugging aids. ###############<br />
#### 2005.11.06 01:00 - km streamlined fGetCurrentBoard & fCommitMove by ###############<br />
#### 2005.11.06 01:00 - using fGetCurrentTurnNum. ###############<br />');
#### 2005.11.05 09:15 - km did oBoard->fGetPiece & fSetPiece & fApplyMove ###############
#### 2005.11.05 09:15 - km did oGame->fGetCurrentBoard & fCommitMove ###############
#### 2005.11.05 03:45 - km added/finished oBoard->fGetBoardArray(). ###############
#### 2005.11.05 02:30 - km fTestMove returns true for now. ###############
#### 2005.11.05 00:45 - km wrote code for fToggleTurn($lsGameId=!zilch!). ###############
#### 2005.11.03 23:55 - km moved fLoadBoard and fSaveBoard from oboard to oGame. #########
#### 2005.11.03 23:55 - km oBoard functions have Set-this flags now. ###############
#### 2005.11.03 23:50 - km added oBoard->fGetPiece & fApplyMove. ###############
#### 2005.11.03 16:35 - km new function skeletons and oGame class. ###############
#### 2005.11.01 17:00 - km ###############
#### 2005.10.30 19:15 - km modified fGetNewBoard and piece naming protocol.###############
#### 2005.10.26 19:40 - km added $ulShowVersions for testing. ###############
#### 2005.10.20 20:50 - km EDITED VAR NAMES for consistency with new conventions #########
#### 2005.10.19.02:00 - km added test method oBoard.fPrintArg ############################
#### 2005.10.17.03:30 - km added STUB fGetNewBoard #######################################
#### 2005.10.17.02:00 - km added Title block #############################################
##########################################################################################
##########################################################################################
#### Status: Available to edit ###########################################################
##########################################################################################
##########################################################################################
#### Description: ####################################
#### ####################################
#### Look at fGetNewBoard for a sample protocol ####################################
#### b & w (black and white) have been changed to l & d (light & dark) ##############
#### so that one can parse-search for 'b' and find a Bishop, not just ##############
#### any black piece. ##############
#### Pieces are now numbered to uniquely identify pieces for better game ##############
#### processing and better display. Eg. 'dn02' (2nd dark knight). ##############
#### Keeping in mind that pieces can be swapped for other piece, ##############
#### naming protcol is as follows: ##############
#### prefix: 'l' or 'd' (light or dark) ##############
#### 'r'(rook) 01,02 + additional 03-15 ##############
#### 'n'(knight) 01,02 + additional 03-15 ##############
#### 'b'(bishop) 01,02 + additional 03-15 ##############
#### 'q'(queen) 01 + additional 02-15 * #02 probably never used. ##############
#### 'k'(king) 01 *# added for consistency, can't trade in king ##############
#### 'p'(pawn) 01-08 + additional 08-15 ##############
##########################################################################################
#### #############
#### ! A history of boards will be stored for each game. #############
#### #############
##########################################################################################
#### Programmer: Kristal McKinstry #######################################################
##########################################################################################
##########################################################################################
#### Agenda: #############################################################################
#### #####################################
##########################################################################################
##########################################################################################
##########################################################################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class oBoard { // oBoard is used for generic board manipulation utilities.
// oGame manages actual game instances or testing instances (create a new oGame for a testing instance).
var $vaBoard;
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function oBoard($laExistingBoard = 'zilch'){ // Constructor always sets default board.
if ($laExistingBoard == 'zilch') $this->fGetNewBoard(TRUE);
else $this->vaBoard = $laExistingBoard;
return TRUE;
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetNewBoard ($llSet=FALSE){
$laBoard = array(
array('dr01', 'dn01', 'db01', 'dq01', 'dk01', 'db02', 'dn02', 'dr02'),
array('dp01', 'dp02', 'dp03', 'dp04', 'dp05', 'dp06', 'dp07', 'dp08'),
array('ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss'),
array('ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss'),
array('ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss'),
array('ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss', 'ss'),
array('lp01', 'lp02', 'lp03', 'lp04', 'lp05', 'lp06', 'lp07', 'lp08'),
array('lr01', 'ln01', 'lb01', 'lq01', 'lk01', 'lb02', 'ln02', 'lr02'));
if ($llSet) $this->vaBoard = $laBoard;
return($laBoard);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fFlipBoard($llSet=FALSE, $laBoard='zilch'){
// returns upside down display of a board for second player
if ($laBoard=='zilch') $laBoard = $this->vaBoard;
$laBoard = array_reverse_insides($laBoard);
if ($llSet) $this->vaBoard = $laBoard;
return($laBoard);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetPiece($liX, $liY, $laBoard='zilch'){
$liX = $liX-1;
$liY = $liY-1;
if ($laBoard =='zilch') $laBoard = $this->vaBoard;
$lsPiece = $laBoard[$liY][$liX];
return($lsPiece);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fSetPiece($liX, $liY, $lsPiece, $laBoard='zilch', $llSet=FALSE){
$liX = $liX-1;
$liY = $liY-1;
if ($laBoard =='zilch') $laBoard = $this->vaBoard;
$laBoard[$liY][$liX] = $lsPiece;
if ($llSet) $this->vaBoard = $laBoard;
return($laBoard);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fApplyMove($laMove, $laBoard='zilch', $llSet=FALSE){ //UNTESTED
if ($laBoard='zilch') {
$loB = new oBoard();
$laBoard = $loB->fGetBoardArray();
}//end-if
//Apply move
$lsPiece = $loB->fGetPiece($laMove[1], $laMove[0]);
$loB->fSetPiece($laMove[1], $laMove[0], 'ss');
$loB->fSetPiece($laMove[3], $laMove[2], $lsPiece);
$laBoard = $loB->fGetBoardArray();
if ($llSet) $this->vaBoard = $laBoard;
return($laBoard);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetBoardArray(){
$laBoardArray = $this->vaBoard;
return($laBoardArray);
}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fTestWinner($laBoard = 'zilch'){
if ($laBoard=='zilch') $laBoard = $this->vaBoard;
$llFoundDarkKing = FALSE;
foreach ($laBoard as $laRow){
if (in_array('dk01', $laRow)) $llFoundDarkKing = TRUE;
} //end-foreach
$llFoundLightKing = FALSE;
foreach ($laBoard as $laRow){
if (in_array('lk01', $laRow)) $llFoundLightKing = TRUE;
} //end-foreach
if (!$llFoundDarkKing) return 1;
if (!$llFoundLightKing) return 2;
else return FALSE;
} //end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
}//end-class
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class oGame {
var $voServer;
var $vsGameId;
var $viTurn;
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function oGame(&$loServer, $lsGameId='zilch'){ ### SET DEFAULTS
$this->voServer = $loServer;
$this->vsGameId = $lsGameId;
// if $lsGameId is supplied, loads that game info from oReg,
// otherwise creates a new game for testing and returns it's GameId.
// Keep in mind that all functions below will apply to an 'INSTANCE' of oGame.
//eg. $loTest07 = new oGame();
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function oDestroyGame($lsGameId='zilch'){
// Removes test game and assosiated boards from qtReg.. & qtBoards.
// Refers to gameId of current object unless another GameId arg is supplied.
if ($lsGameId!='zilch') $this->vsGameId = $lsGameId;
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fToggleTurn($lsGameId='zilch'){
if ($lsGameId!='zilch') $this->vsGameId = $lsGameId;
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
$query = "SELECT DISTINCT qfTurn FROM qtRegisteredGames WHERE qfGameId = '$lsGameId'";
list($liX, $laTable) = mysql_fetch_table_array(mysql_query($query));
$liTurn = $laTable[0][0];
if ($liTurn==1) $liTurn=2;
else $liTurn=1;
$query = "UPDATE qtRegisteredGames SET qfturn=$liTurn WHERE qfGameId = '$lsGameId'";
mysql_query($query);
$this->viTurn = $liTurn;
return($liTurn);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#### function fIsPlayersTurn($lsId){ // method of oRegistration!
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetCurrentBoard($liAltTurnboard='zilch'){
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
if ($liAltTurnboard=='zilch') $liLastTurnNum = $this->fGetCurrentTurnNum();
else $liLastTurnNum = $liAltTurnboard;
$query = "SELECT qfBoardArray FROM qtBoards WHERE qfGameId = '$lsGameId' AND qfTurnNum = $liLastTurnNum;";
list($liX, $laTable) = mysql_fetch_table_array(mysql_query($query));
$laBoard = unserialize($laTable[0][0]);
return($laBoard);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetCurrentTurnNum(){
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
$query = "SELECT qfLastBoard FROM qtRegisteredGames WHERE qfGameId = '$lsGameId'";
list($liX, $laTable) = mysql_fetch_table_array(mysql_query($query));
$liLastTurnNum = $laTable[0][0];
return($liLastTurnNum);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetPriorBoard($liTurn){
//return BoardArray
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fFlipMoveArray($laMove){
//return move-array appropriate for a flipped board.
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fTestMove($laMove, $laBoard='zilch'){
// Should already be that players turn. should examine temp flipped board and flipped
// move-array if player 2's turn.
$loS = $this->voServer;
//$loT = new oTestMove($loS); Would require oCFV
//function fTestMove($laMoveToTest='zilch', $loGame='zilch', $loBoard='zilch'){
//$llCool = $loT->fTestMove();
//return($llCool);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fCommitMove($laMove, $lsSpecialMove='0'){
/*
Uses unflipped board. (No need to ever flip beforehand either except in testing)
Sets this and qtReg..
Uses current board if none in args - get board and board #
- Get via select qtReg.. where $lsGameId
Adds board to qtBoards
*/
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
$liLastTurnNum = $this->fGetCurrentTurnNum();
$query = "SELECT qfBoardArray FROM qtBoards WHERE qfGameId = '$lsGameId' AND qfTurnNum = $liLastTurnNum;";
list($liX, $laTable) = mysql_fetch_table_array(mysql_query($query));
$laBoard = unserialize($laTable[0][0]);
$loB = new oBoard($laBoard);
//Apply move
switch ($lsSpecialMove){ // Some special moves overwrite pieces.
case '0': // no special move
{
$lsPiece = $loB->fGetPiece($laMove[1], $laMove[0]);
$loB->fSetPiece($laMove[1], $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece($laMove[3], $laMove[2], $lsPiece, 'zilch', TRUE);
}
break;
case '1': // castle - short
{
// Col.5to7, 8to6, ss to5, ss to8
$loB->fSetPiece(7, $laMove[0], $loB->fGetPiece(5, $laMove[0]), 'zilch', TRUE);
$loB->fSetPiece(6, $laMove[0], $loB->fGetPiece(8, $laMove[0]), 'zilch', TRUE);
$loB->fSetPiece(5, $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece(8, $laMove[0], 'ss', 'zilch', TRUE);
}
break;
case '2': // castle - long
{
// 1to4, 5to3, ss to1, ss to5
$loB->fSetPiece(4, $laMove[0], $loB->fGetPiece(1, $laMove[0]), 'zilch', TRUE);
$loB->fSetPiece(3, $laMove[0], $loB->fGetPiece(5, $laMove[0]), 'zilch', TRUE);
$loB->fSetPiece(1, $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece(5, $laMove[0], 'ss', 'zilch', TRUE);
}
break;
case '3': // no special move (actually 'check')
{
$lsPiece = $loB->fGetPiece($laMove[1], $laMove[0]);
$loB->fSetPiece($laMove[1], $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece($laMove[3], $laMove[2], $lsPiece, 'zilch', TRUE);
}
break;
case '4': // no special move (actually 'check-mate')
{
$lsPiece = $loB->fGetPiece($laMove[1], $laMove[0]);
$loB->fSetPiece($laMove[1], $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece($laMove[3], $laMove[2], $lsPiece, 'zilch', TRUE);
}
break;
case '5': // en passant
{
$lsPiece = $loB->fGetPiece($laMove[1], $laMove[0]);
$loB->fSetPiece($laMove[1], $laMove[0], 'ss', 'zilch', TRUE);
$loB->fSetPiece($laMove[3], $laMove[2], $lsPiece, 'zilch', TRUE);
if ($laMove[2] == 3) $loB->fSetPiece($laMove[3], 4, 'ss', 'zilch', TRUE);
else $loB->fSetPiece($laMove[3], 5, 'ss', 'zilch', TRUE);
}
break;
default:
break;
}//end-switch
$laBoard = $loB->fGetBoardArray();
$lsBoard = serialize($laBoard);
$liLastTurnNum++;
$query = "UPDATE qtRegisteredGames SET qfLastBoard=$liLastTurnNum WHERE qfGameId = '$lsGameId'";
mysql_query($query);
$query = "INSERT INTO qtBoards (qfGameId, qfTurnNum, qfBoardArray) VALUES ('$lsGameId', $liLastTurnNum, '$lsBoard')";
mysql_query($query);
return($laBoard);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fSetWinner($lsGameId='zilch', $lsWinnerId){
if ($lsGameId!='zilch') $this->vsGameId = $lsGameId;
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
$query = "UPDATE qtRegisteredGames SET qfWinner='$lsWinnerId' WHERE qfGameId = '$lsGameId'";
mysql_query($query);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fGetWinner($lsGameId='zilch'){
if ($lsGameId!='zilch') $this->vsGameId = $lsGameId;
$lsGameId = $this->vsGameId;
$this->voServer->fSelectDB();
$query = "SELECT qfWinner FROM qtRegisteredGames WHERE qfGameId = '$lsGameId'";
list($liX, $laTable) = mysql_fetch_table_array(mysql_query($query));
if ($laTable[0][0]=='zilch') return FALSE;
else return($laTable[0][0]);
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fQuitGame($args){
//removes all boards except last
// set this & qtReg Winner to 'quit'.
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
function fSaveGame($args){
//removes all boards except last
// set this & qtReg Winner to 'saved'.
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
####function fLoadBoard(optional turnnum, optional game else get this){
##set this
##return this
##}//end-meth
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
####function fSaveBoard(turnnum dflt=this, board dflt=this){
##set this
##return this
##}//end-meth
}//end-class
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
?>