public static function makeRaster($array, $grootte)
 {
     $arrSoorten = soortService::getAllSoorten();
     print "<div class='matrix grootte" . $grootte . " clearFix'>";
     for ($rij = 1; $rij <= $grootte; $rij++) {
         for ($kol = 1; $kol <= $grootte; $kol++) {
             $bln = organismeservice::checkPositionInArray($kol, $rij, $array);
             if ($bln == null) {
                 print "<div class='cell'><div class='innercell'></div></div>";
             }
             if ($bln != null) {
                 foreach ($arrSoorten as $soort) {
                     $posSoort = $bln->soort;
                     if ($soort->id == $posSoort) {
                         $imgsrc = $soort->image;
                         $imgtitle = $soort->soort;
                     }
                     if ($posSoort == "1") {
                         $kracht = "";
                     } else {
                         $kracht = "Kracht:" . $bln->kracht;
                     }
                 }
                 print "<div class='cell'><div class='innercell'><img src='" . $imgsrc . "' alt='" . $imgtitle . "'><span class='tooltip'><strong>ID : " . $bln->id . "</strong> " . $imgtitle . " " . $kracht . "</span></div></div>";
             }
         }
     }
     print "</div>";
 }
Example #2
0
 public static function play($game, $arrNextStep)
 {
     // DAG UPDATE
     $dag = $game->dag;
     $id = $game->id;
     $dag += 1;
     GameDAO::updatedate($id, $dag);
     // VERWIJDER OPGEGETEN
     foreach ($_SESSION['verwijderd'] as $verwijder) {
         organismeservice::deleteOrganisme($verwijder);
     }
     $arrDBorganismen = organismeservice::getAllOrganismen($game->id);
     $totaal = $game->grootte * $game->grootte;
     $teller = 0;
     foreach ($arrNextStep as $organisme) {
         if ($teller < $totaal) {
             foreach ($arrDBorganismen as $dborganisme) {
                 if ($organisme->id == $dborganisme->id) {
                     OrganismeDAO::updateOrganisme($organisme);
                 }
             }
             if ($organisme->id == 0) {
                 organismeservice::createOrganisme($organisme->soort, $organisme->kracht, $organisme->kolom, $organisme->rij, $organisme->gameid);
             }
         }
         $teller = $teller + 1;
     }
 }
 public static function checkPositionFree($kolom, $rij, $gameid)
 {
     $arrOrg = organismeservice::getAllOrganismen($gameid);
     foreach ($arrOrg as $org) {
         if ($org->kolom == $kolom && $org->rij == $rij && $org->gameid == $gameid) {
             return false;
         }
     }
     return true;
 }
Example #4
0
<?php

$games = gameService::getAllGames();
$soorten = soortService::getAllSoorten();
foreach ($games as $game) {
    if ($game->id == $_GET["game"]) {
        $grootte = $game->grootte;
    }
}
print "<div class='matrix grootte" . $grootte . " clearFix'>";
for ($rij = 1; $rij <= $grootte; $rij++) {
    for ($kol = 1; $kol <= $grootte; $kol++) {
        $positie = organismeservice::checkPosition($kol, $rij, $_GET["game"]);
        if (isset($positie)) {
            $posSoort = $positie->soort;
            foreach ($soorten as $soort) {
                if ($soort->id == $posSoort) {
                    $imgtitle = $soort->soort;
                    $imgsrc = $soort->image;
                }
            }
            if ($posSoort == "1") {
                $kracht = "";
            } else {
                $kracht = "Kracht:" . $positie->kracht;
            }
            print "<div class='cell'><div class='innercell'><img src='" . $imgsrc . "' alt='" . $imgtitle . "'><span class='tooltip'>" . $imgtitle . " " . $kracht . "</span></div></div>";
        } else {
            print "<div class='cell'><div class='innercell'></div></div>";
        }
    }
Example #5
0
 public static function addToArray($soort, $array, $aantal, $grootte, $gameid)
 {
     for ($i = 1; $i <= $aantal; $i++) {
         if (count($array) >= $grootte * $grootte) {
             return $array;
         }
         do {
             $kolom = rand(1, $grootte);
             $rij = rand(1, $grootte);
             $check = organismeservice::checkPositionInArray($kolom, $rij, $array);
         } while ($check != false);
         $organisme = new Organisme(0, $soort, 1, $kolom, $rij, $gameid);
         array_push($array, $organisme);
     }
     return $array;
 }
Example #6
0
// CHECK FOR POST
if (isset($_POST["grootte"])) {
    gameService::initNewGame($_POST["grootte"]);
    header('Location:index.php');
    die;
}
// MAAK GAMELIJST AAN
$gamelijst = gameService::getAllGames();
if (!isset($_GET['page']) && !isset($_GET['game'])) {
    include 'presentation/homepage.php';
}
if (isset($_GET['nextstep']) && isset($_GET['game'])) {
    if (isset($_SESSION['nextStep'])) {
        $game = GameDAO::getGameFromId($_GET['game']);
        playservice::play($game, $_SESSION['nextStep']);
    }
}
if (isset($_GET['game'])) {
    $game = GameDAO::getGameFromId($_GET['game']);
    if (isset($game)) {
        $arrGameOrganismen = organismeservice::getAllOrganismen($_GET['game']);
        include 'presentation/game.php';
    }
    if (!isset($game)) {
        $error = "<h3>Game " . $_GET['game'] . " bestaat niet meer.</h3>Selecteer een andere of start een nieuwe game.";
        include 'presentation/homepage.php';
    }
}
if (isset($_GET['page'])) {
    include 'presentation/' . $_GET['page'] . '.php';
}