123456789101112131415161718192021222324252627282930 |
- <?php
-
- require_once 'board.php';
-
- session_start();
-
- // Ships initializen naar gelang de difficulty
-
- function assignShips($difficulty)
- {
- $_SESSION['currentShips'] = new Board($difficulty);
- for ($x = 0; $x <= count($_SESSION['currentShips']->returnCurrentShips()) - 1; $x++) {
- $_SESSION['shipsPositions'][$x] = $_SESSION['currentShips']->returnCurrentShips()[$x]->posArr();
- }
- }
-
- // We checken of ons shot raak of mis is
-
- function hitOrMis($shot)
- {
-
- for ($x = 0; $x <= count($_SESSION['currentShips']->returnCurrentShips()) - 1; $x++) {
-
- if ($_SESSION['currentShips']->returnCurrentShips()[$x]->hitOrMis($shot)) {
- $plaats = array_search($shot, $_SESSION['shipsPositions'][$x]);
- unset($_SESSION['shipsPositions'][$x][$plaats]);
- return $_SESSION['currentShips']->returnCurrentShips()[$x]->returnName() . ' geraakt!<br>';
- }
- }
- }
|