Wrong number for Rows, Cols or Mines!";
exit;
}
if ($NumMine > $RowSize*$ColSize) {
print "
Too many mines!";
exit;
}
for ($Row=1;$Row<=$RowSize;$Row++) {
for ($Col=1;$Col<=$ColSize;$Col++) {
$Mine[$Row][$Col]="0";
$Decouv[$Row][$Col]="0";
}
}
$index=0;
while ($index<$NumMine) {
$Row=rand(1,$RowSize);
$Col=rand(1,$ColSize);
if ($Mine[$Row][$Col]=="0") {
$Mine[$Row][$Col]="1";
$index++;
}
}
} else {
$perdu=0;
$reste=$RowSize*$ColSize;
for ($Row=1;$Row<=$RowSize;$Row++) {
for ($Col=1;$Col<=$ColSize;$Col++) {
$temp="Mine".($Row*($ColSize+1)+$Col);
$Mine[$Row][$Col]=$$temp;
$temp="Decouv".($Row*($ColSize+1)+$Col);
$Decouv[$Row][$Col]=$$temp;
if ($Decouv[$Row][$Col]=="1") {$reste=$reste-1;}
$temp="submit".($Row*($ColSize+1)+$Col);
if ($$temp=="ok") {
$reste=$reste-1;
if ($Mine[$Row][$Col]=="0") {
$Decouv[$Row][$Col]="1";
} else {
$perdu=1;
}
}
}
}
if ($perdu==1) {
print "
Your score: $time"; for ($i=1;$i<=$RowSize;$i++) { for ($j=1;$j<=$ColSize;$j++) { $Decouv[$i][$j]="1"; } } } } print "
"; ?>