-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolo_game.php
More file actions
71 lines (67 loc) · 1.62 KB
/
solo_game.php
File metadata and controls
71 lines (67 loc) · 1.62 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
require_once("clue.php");
session_start();
if(!isset($_SESSION["game"]))
{
// number of players
$p = 3;
if(isset($_GET['ai']))
{
$p = (int)$_GET['ai'] + 1;
}
$game = new Clue($p);
$_SESSION["game"] = $game;
$_SESSION["player"] = $game->getCurPlayer();
if(isset($_GET['name']))
$_SESSION["player"]->name = $_GET['name'];
}
// Game interface here ^_^
$seats = array_fill(0,5,"");
$key =array();
switch(count($_SESSION["game"]->players) - 1)
{
case 2:
$key = array(1,3);
break;
case 3:
$key = array(0,2,4);
break;
case 4:
$key = array(0,1,3,4);
break;
case 5:
$key = array(0,1,2,3,4);
break;
}
$key = array_reverse($key);
foreach($_SESSION["game"]->players as $play)
{
if($play == $_SESSION["player"]) continue;
$seats[array_pop($key)] = $play->name;
}
?>
<html>
<head>
<title>Clue in PHP</title>
<script src="js/ajax.js" type="text/javascript"></script>
<script src="js/ajax-dynamic-content.js" type="text/javascript"></script>
</head>
<body>
<table align="center">
<tr>
<td align="center"><?php echo $seats[1]; ?></td><td align="center"><?php echo $seats[2]; ?></td><td align="center"><?php echo $seats[3]; ?></td>
</tr>
<tr>
<td align="center"><?php echo $seats[0]; ?></td><td align="center" style="background: black; color: white;" id="out"> </td><td align="center"><?php echo $seats[4]; ?></td>
</tr>
<tr>
<td align="center" colspan="3" style="padding: 8px;" id="player">
</td>
</tr>
</table>
<script type="text/javascript">
var enableCache = false;
ajax_loadContent('player', 'the_player.php');
</script>
</body>
</html>