Login   Register  
Icontem

File: bzchess-game.html

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Gábor Martini  >  bzChess  >  bzchess-game.html  >  Download  
File: bzchess-game.html
Role: Example script
Content type: text/plain
Description: Example: Playing game
Class: bzChess
Manage and display a chess board game
Author: By
Last change:
Date: 2012-06-10 21:26
Size: 2,358 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title> bzChess example - Play </title>
  <meta name="author" content="Gábor Martini" />
  <meta name="keywords" content="chess fen pgn puzzle" />
  <meta name="description" content="Javascript chess object to display positions" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <SCRIPT type="text/javascript" LANGUAGE=javascript src="bzchess.js"></script>


  <LINK rel="stylesheet" type="text/css" media="screen" href="chess.css" />

<script type="text/javascript">
<!--
	function bza_init_game(wb, bb) {
		wtbl = new bzChess(wb);
		btbl = new bzChess(bb);
		wtbl.onWhiteMove = function(fc,tc){
			wtbl.disablePlay();
			SAN.innerHTML = wtbl.getSAN();
			nm.value="b";

			//some script to send information to the other table
			fcln.value=fc.ln;
			tcln.value=tc.ln;

			makeMove();
		}
		btbl.onBlackMove = function(fc,tc){
			btbl.disablePlay();
			SAN.innerHTML = btbl.getSAN();
			nm.value="w";

			//some script to send information to the other table
			fcln.value=fc.ln;
			tcln.value=tc.ln;

			makeMove();
		}
		wtbl.makePlayable();
	}

	// Some script to recive move information and set to the table
	function makeMove() {
		if (nm.value=="b") {
			btbl.makePlayable();
			btbl.move(fcln.value,tcln.value);
		} else {
			wtbl.makePlayable();
			wtbl.move(fcln.value,tcln.value);
		}
	}
//-->
</script>


 </head>



 <body onload="bza_init_game(wbrd, bbrd)">

<h1>Example: playing game with an opponent</h1>
		<p style="margin: 0px;">The board with the blue border is playable. To play click the piece to select it, then click on a valid field to move.</p>
		<p style="margin: 0px;">The middle is representing the communication between the two boards. In the green DIV is displayed the game in SAN.</p>
<table width="100%" border=0>
	<tr>
		<td style="vertical-align: top;">
			<div id="wbrd" class="chbrd"></div>
		</td>
		<td>
			fc.ln=<input type="text" id="fcln" /><br />tc.ln<input type="text" id="tcln"/><br />nm=<input type="text" id="nm" />
			<p id="SAN" style="border: 1px solid green; width: 240px;"></p>
		</td>
		<td style="vertical-align: top;">
			<div id="bbrd" class="chbrd"></div>
		</td>
	</tr>
</table>

</body>
</html>