-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
47 lines (35 loc) · 893 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
require_once('vendor/autoload.php');
use App\Game;
use App\GameSession;
session_start();
$game = new Game;
$game->start();
$input = $game->listenForInput();
if ($game->isFinished()) {
session_destroy();
echo "Well done! You completed the game in ". GameSession::getAction() . "shots.";
echo "<br /><a href='/index.php'>Try again</a>";
return;
}
if ($input === false) {
echo "<pre>\n *** ERROR *** \n</pre>";
}
if ($game->actionResult && strlen($game->actionResult)) {
echo "<pre>\n $game->actionResult \n</pre>";
}
?>
<html>
<pre>
<?= $game->playergrid->renderColumns(); ?>
<?= $game->renderGrid(); ?>
</pre>
<p>
<form name="input" action="index.php" method="post">
Enter coordinates (row, col), e.g. A5
<input type="input" size="5" name="coord" autocomplete="off" autofocus="">
<input type="submit">
</form>
</p>
</html>