diff --git a/src/arenas/Battleship/act.php b/src/arenas/Battleship/act.php index d948505..091e900 100644 --- a/src/arenas/Battleship/act.php +++ b/src/arenas/Battleship/act.php @@ -99,8 +99,8 @@ switch ($_POST['act']){ } //init grid - for($y = 0; $y < $height; $y++){ - for($x = 0; $x < $width; $x++){ + for($y = 0; $y < $postValues['gridHeight']; $y++){ + for($x = 0; $x < $postValues['gridWidth']; $x++){ $grid[$player][$y][$x]=0; } } diff --git a/src/arenas/Battleship/functions.php b/src/arenas/Battleship/functions.php index 7f1e08e..deca0ce 100644 --- a/src/arenas/Battleship/functions.php +++ b/src/arenas/Battleship/functions.php @@ -54,9 +54,12 @@ function get_IA_Response($iaUrl,$postParams){ return htmlentities($output); } function place_ship_on_map($x1,$y1,$x2,$y2,$map){ - if (($x1 <> $x2) && ($y1 <> $y2)){ - return false; + if ((($x1 <> $x2) && ($y1 <> $y2)) + OR (!isset($map[$y1][$x1])) + OR (!isset($map[$y2][$x2]))){ + return false; } + if($x1 == $x2){ //horizontal ship