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

Class: visualboard

Source Location: /Games_Chess-0.7.0/examples/HTMLChess.php

Class Overview


The primary class - declare one of these at the top of the file


Author(s):

Version:

  • 1.0

Copyright:

  • Copyright 2002, Greg Beaver

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 62]
The primary class - declare one of these at the top of the file

Do it like this:

  1.  setup_game('mygame','x');
  2.  $x $_SESSION['x'];
  3.  if (!isset($x)) $x = new visualboard;



[ Top ]


Class Variables

$promote =  false

[line 73]

Promotion contents

Type:   false|array


[ Top ]



Method Detail

visualboard (Constructor)   [line 78]

visualboard visualboard( [ $fen = false], [ $type = 'Standard'])

Initializes $moves, $board

Parameters:

   $fen   — 
   $type   — 

[ Top ]

castlebutton   [line 367]

void castlebutton( )

Prints the castling buttons after checking castling rights

If castling rights have been taken away by a king or rook move, the button is not displayed. This function uses Games_Chess::canCastleKingside(), Games_Chess::canCastleQueenside() to find out.


[ Top ]

domove   [line 125]

void domove( )

Grabs the next move from form variables start, goto, kingcastle and queencastle

If $_GET['start'] is not used, it checks for $_GET['kingcastle'] and tries to castle kingside if found. Otherwise, it looks for $_GET['queencastle'] and tries to castle queenside


[ Top ]

dopromote   [line 175]

void dopromote( )

This function prints the javascript that will ask the user what to promote the pawn to

Using the alert() function, this method asks the user if they want a queen. If they click Cancel, it asks if they want a rook, then knight, then bishop. If they cancel on bishop, it promotes to queen to avoid any illogical possibilities


[ Top ]

draw   [line 236]

void draw( )

Print out the chess game in its entirety: the board, move list and control buttons

first, it checks for a pawn promotion and adds the promote move to $moves using game::addpromote(). Then it moves the next piece by calling domove(). Then it checks for stalemate and checkmate, and stops the gameplay if either condition is met. It creates a visual representation of the board using abstractboard::createrows(), and displays the chessboard by linking together the display of each row on the chessboard using row::draw(), and finally the movelist using game::draw()


[ Top ]

javascript   [line 93]

void javascript( )

Prints javascript for the function addmove:

  1. function javascript()
  2.     {?>
  3. <script language="JavaScript" type="text/javascript">
  4. <!--
  5. function addMove(move)
  6. {
  7.     if (document.forms[0].start.value == '')
  8.     document.forms[0].start.value = move;
  9.     else
  10.     {
  11.         if (document.forms[0]["goto"].value == '')
  12.         {
  13.             document.forms[0]["goto"].value = move;
  14.             if (confirm("Do this move?"))
  15.             {
  16.                 document.forms[0].submit();
  17.             }
  18.         }
  19.     }
  20. }
  21. //-->
  22. </script>
  23. <?php
  24.     }


[ Top ]


Documentation generated on Mon, 11 Mar 2019 10:14:58 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.