{ window.location.replace(\'chess.php\'); } '; // ouput confirmation for wake up email if ($wake_up_sent) { $head_extra .= "alert('Wake Up email sent');\n "; } elseif (isset($_POST['wakeID']) && !$wake_up_sent) { $head_extra .= "alert('Wake Up email FAILED !!');\n "; } // transfer game data to javacript vars $head_extra .= getJSFEN(); // writes 'FEN' array, and 'result' (gui.inc.php) $head_extra .= getTurn(); // writes 'isBoardDisabled', 'isPlayersTurn', and 'perspective' (gui.inc.php) $head_extra .= getMoves(); // writes the 'moves' array (gui.inc.php) $head_extra .= getStatus(); // writes 'whosMove', 'gameState', and 'statusMsg' (gui.inc.php) $head_extra .= "var DEBUG = " . JS_DEBUG . ";\n "; $head_extra .= "var numMoves = FEN.length - 1;\n "; // if it's not the player's turn, enable auto-refresh $autoRefresh = !$isPlayersTurn && !isBoardDisabled() && !$_SESSION['shared']; $head_extra .= "var autoreload = "; if (!$autoRefresh || 0 == $CFG_MINAUTORELOAD) { $head_extra .= "0"; } elseif ($_SESSION['pref_auto_reload'] >= $CFG_MINAUTORELOAD) { $head_extra .= $_SESSION['pref_auto_reload']; } else { $head_extra .= $CFG_MINAUTORELOAD; }
if (!file_exists($dir)) { mkdir($dir); } } file_put_contents('boards/' . $path . '.html', $html); } function findFirstNull($board) { $nulls = findAllNulls($board); if (count($nulls)) { return $nulls[0]; } } function getMoves($board) { $moves = []; foreach (findAllNulls($board) as $x_move) { $new_board = $board; $new_board[$x_move[0]][$x_move[1]] = 'x'; if ($o_move = chooseMove($new_board, 'o')) { $new_board[$o_move[0]][$o_move[1]] = 'o'; } $moves[$x_move[0]][$x_move[1]] = getPath($new_board); } return $moves; } foreach (getAllPossibleBoards() as $i => $board) { $moves = getMoves($board); render($board, $moves); } echo "done";