You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930
  1. <?php
  2. require_once 'board.php';
  3. session_start();
  4. // Ships initializen naar gelang de difficulty
  5. function assignShips($difficulty)
  6. {
  7. $_SESSION['currentShips'] = new Board($difficulty);
  8. for ($x = 0; $x <= count($_SESSION['currentShips']->returnCurrentShips()) - 1; $x++) {
  9. $_SESSION['shipsPositions'][$x] = $_SESSION['currentShips']->returnCurrentShips()[$x]->posArr();
  10. }
  11. }
  12. // We checken of ons shot raak of mis is
  13. function hitOrMis($shot)
  14. {
  15. for ($x = 0; $x <= count($_SESSION['currentShips']->returnCurrentShips()) - 1; $x++) {
  16. if ($_SESSION['currentShips']->returnCurrentShips()[$x]->hitOrMis($shot)) {
  17. $plaats = array_search($shot, $_SESSION['shipsPositions'][$x]);
  18. unset($_SESSION['shipsPositions'][$x][$plaats]);
  19. return $_SESSION['currentShips']->returnCurrentShips()[$x]->returnName() . ' geraakt!<br>';
  20. }
  21. }
  22. }