-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayold.php
executable file
·213 lines (190 loc) · 3.86 KB
/
playold.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
session_start();
$timesAllowed = 50;
$_SESSION['turns'] = $_SESSION['turns'] + 1;
if ((isset($_GET['j']))||($_GET['j']!=""))
if (($_GET['j'] > 0)||($_GET['j'] < 10))
$inpVal = $_GET['j'];
else
$inpVal = 999;
else
$inpVal = 999;
if (isset($_GET["reset"])){
unset($_SESSION['board']);
unset($_SESSION['turns']);
}
if (!isset($_SESSION['board']))
initBoard();
else
$board = $_SESSION['board'];
function initBoard() {
if (isset($_GET["reset"])){
if ($_GET["reset"] == "y")
{
include("levels/one.php");
}
else if ($_GET["reset"] == "one")
include("levels/one.php");
else if ($_GET["reset"] == "two")
include("levels/two.php");
else if ($_GET["reset"] == "three")
include("levels/three.php");
}
else {
include("levels/one.php");
}
$_SESSION['board']=$board;
}
function writeBoard()
{
$board = $_SESSION['board'];
foreach( $board as $key => $value){
foreach( $board[$key] as $key2 => $value2){
echo "<div class='box a$value2'></div>";
}
echo "<div style='clear:both;margin:0;padding:0;height:0px;line-height:0px;font-size:0px;'></div>";
}
echo "";
}
function changeIt($j)
{
$retval = false;
$board = $_SESSION['board'];
foreach( $board as $key => $value){
foreach( $board[$key] as $key2 => $value2){
if ($value2 == 0)
{
$x = $key;
$y = $key2;
if ($board[$x+1][$y] == $j) {
$retval = true;
$board[$x+1][$y] = 0;
}
if ($board[$x-1][$y] == $j){
$retval = true;
$board[$x-1][$y] = 0;
}
if ($board[$x][$y+1] == $j){
$retval = true;
$board[$x][$y+1] = 0;
}
if ($board[$x][$y-1] == $j){
$retval = true;
$board[$x][$y-1] = 0;
}
}
}
}
$_SESSION['board']=$board;
return $retval;
}
function checkforcolors() {
$retVal = 0;
$board = $_SESSION['board'];
foreach( $board as $key => $value){
foreach( $board[$key] as $key2 => $value2){
if (($value2 > 0)||($value2 < 10))
$retVal += 1;
}
}
return $retVal;
}
?>
<?php
$changes = 0;
while(changeIt($inpVal)){$changes += 1;}
if ($changes == 0) {
//check to see if all the squares are 0
//if so, check count
//if less, display WINNER and the difference
}
if ($_SESSION['turns'] >= $timesAllowed)
echo "<script>alert('LOSER!');</script>";
?>
<body>
<div class="boarde" style="">
<?php writeBoard();?>
</div>
<head>
<style>
body {
margin:1px;
padding:0;
}
.boarde {
}
.box {
width:13px;
height:13px;
float:left;
margin:0;
padding:0;
line-height:1px;
font-size:1px;
border:1px black solid;
}
.bot {
width:25px;
height:25px;
margin:1px;
}
.a1 {
background-color:red;
}
.a2 {
background-color:#FF00FF;
}
.a3 {
background-color:blue;
}
.a4 {
background-color:cyan;
}
.a5 {
background-color:purple;
}
.a6 {
background-color:#FFF000;
}
.a7 {
background-color:brown;
}
.a8 {
background-color:#BF7C00;
}
.a9 {
background-color:lime;
}
.a0 {
background:black;
border:1px green solid;
}
.a10 {
background:white;
border:1px black solid;
}
</style>
</head>
</p style="">
<a class="a1 box bot" href="play.php?j=1"></a>
<a class="a2 box bot" href="play.php?j=2"></a>
<a class="a3 box bot" href="play.php?j=3"></a>
<a class="a4 box bot" href="play.php?j=4"></a>
<a class="a5 box bot" href="play.php?j=5"></a>
<a class="a6 box bot" href="play.php?j=6"></a>
<a class="a7 box bot" href="play.php?j=7"></a>
<a class="a8 box bot" href="play.php?j=8"></a>
<a class="a9 box bot" href="play.php?j=9"></a>
</p>
<div style="clear:both" />
<p>Directions: Start with the black square and try to fill the board with black.</p>
<p>Winning is not actually programmed yet. Losing, works half the time.</p>
<br/>Turns:
<?php echo $_SESSION['turns'] ?>
. Try to beat in less than <?php echo $timesAllowed; ?>.
<br/>
<a href="play.php?reset=y">reset</a> | <a href="play.php?reset=two">level2</a> | <a href="play.php?reset=three">level3</a>
</p>
<h2>Flood-It - In PHP</h2>
<p>by Daniel Folkes</p>
</body>