gamemanager.currentGo++;
if (gamemanager.currentPlayer == "O") {
this.noughtOrCross = this.nought;
this.noughtOrCross.play( 6 );
} else if (gamemanager.currentPlayer == "X") {
this.noughtOrCross = this.cross;
this.noughtOrCross.play( 6 );
}
this.isClicked = true;
this.buttonLabel = gamemanager.currentPlayer;
this.horizLine.setAttribute('visible', false );
this.vertLine.setAttribute('visible', false );
this.forSlashLine.setAttribute('visible', false );
this.bakSlashLine.setAttribute('visible', false );
this.horizLine.setAttribute( "y", this.initHorizLineY );
this.vertLine.setAttribute( "x", this.initVertLineX );
this.secondRow )) {
this.forSlashLine.setAttribute('visible', true );
}
// back slash
if (( this.firstCol < this.secondCol ) ==
( this.firstRow < this.secondRow )) {
this.bakSlashLine.setAttribute('visible', true );
}
]]>
= 0) && (c < 3) ) {
if ( (r >= 0) && (r < 3) ) {
return true;
} else return false;
} else return false;
]]>
// prints a "O" or "X" in the button, then deactivates
// it so that it cannot be clicked again.
//
if (!cell.isClicked) {
var row = cell.immediateparent.row;
var col = cell.col;
cell.setLabel( gamemanager.currentPlayer );
if ( gamemanager.isWin(cell) ) {
victory_line.drawLine();
var message = "Player " + gamemanager.currentPlayer
message += " has won!";
gameOver.showGameOver( message );
return;
}
gamemanager.setCurrentPlayer();
// Stalemate
if (gamemanager.currentGo >= 9) {
var message = "Nobody wins.";
gameOver.showGameOver( message );
return;
}
}
this.setAttribute('visible', true );
gameOverScreen.setAttribute('visible', true );
// Prevent the user from clicking anything else
lz.ModeManager.makeModal( this );
this.message.setAttribute('text', message );
// Close the dialog box and, reset the game
//
// Allow the user to click other things (i.e. aside from the
// dialog box
lz.ModeManager.release(this);
this.setAttribute('visible', false );
gameOverScreen.setAttribute('visible', false );
// reset globals
gamemanager.currentPlayer = "O";
gamemanager.currentGo = 0;
allRowsCols.rows.row0.reset();
allRowsCols.rows.row1.reset();
allRowsCols.rows.row2.reset();
victory_line.reset();