spl_autoload_register("my_autoload"); /* * Statuses * 0 - Free spot * 1 - Ship * 2 - Miss * 3 - Hit * 4 - Sank */ session_start(); $game = new game(); if (isset($_GET['y']) && isset($_GET['x'])) { $game->makeShot($_GET['y'], $_GET['x']); } $currentMap = $game->map; if ($game->targetsLeft() == 0) { echo "<h1>You WON!</h1>"; } echo "<table border='1'>"; echo "<tr><td></td><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td><td>F</td><td>G</td><td>H</td><td>I</td><td>J</td></tr>"; for ($i = 0; $i < 10; $i++) { echo "<tr>"; echo "<td width='10' height='10'>{$i}</td>"; for ($j = 0; $j < 10; $j++) { if ($currentMap[$i][$j] === 1) { echo "<td class='" . $i . " " . $j . "' width='10' height='10' style='cursor: pointer;' onclick='location.href = \"?y=" . $i . "&x=" . $j . "\";'> </td>"; } else { if ($currentMap[$i][$j] === 2) { echo "<td bgcolor='silver' class='" . $i . " " . $j . "' width='10' height='10'> </td>"; } else { if ($currentMap[$i][$j] === 3) {