echo "<p>" . $playerName . " " . $playerCHAR . " a gagné.</p>"; save_battle('tictactoe', $bots[$bot1]['name'], $bots[$bot2]['name'], $playerPlayingNow); $end = true; break; } //tester si toutes les cases ne seraient pas prises $full = true; foreach ($map as $char) { if ($char == "") { $full = false; break; } } if ($full) { echo "<p>Match nul</p>"; save_battle('tictactoe', $bots[$bot1]['name'], $bots[$bot2]['name'], 0); $end = true; break; } //on change de joueur if ($playerPlayingNow == 1) { $playerPlayingNow = 2; } else { $playerPlayingNow = 1; } } else { echo "<p>" . $playerName . " a fait une réponse non conforme. Il perd</p>"; break; } } die;
foreach ($ennemyBoat as $boatCase) { if (!in_array($boatCase, $previousStrikes) && $boatCase != $x . "," . $y) { $sunk = false; break; } } if ($sunk) { $result = "hit and sunk"; //remove the ship unset($_SESSION['ships'][$opponent][$shipIndex]); $_SESSION['ships'][$opponent] = array_values($_SESSION['ships'][$opponent]); //var_dump($_SESSION['ships'][$opponent]); //win the game? if (count($_SESSION['ships'][$opponent]) == 0) { $result = "hit sunk and win"; $continue = 0; save_battle('Battleship', $_SESSION['bot1']['name'], $_SESSION['bot2']['name'], $currentPlayer); } } break; } } //remember this shot $_SESSION['strikes'][$currentPlayer][] = array('target' => $x . "," . $y, 'result' => $result); //send message for the arena's ajax web page echo json_encode(array('opponent' => $opponent, 'target' => $x . "," . $y, 'log' => $currentBot['name'] . " tire en " . $x . "," . $y . " " . $result, 'continue' => $continue)); die; break; default: break; }