public static function nest() { $us = User::getUserById($_SESSION['id']); $nests = Nest::getUserNests($_SESSION['id']); $us['nests'] = $nests; View::$data['user'] = $us; if (empty($_SESSION['nestid'])) { $_SESSION['nestid'] = $nests[0]; } $nest = Nest::getNestsLevelID($_SESSION['nestid']); $barrackNextLevel = Barracks::getNextLevel($nest[1])->fetch_assoc(); $upgradeWater = $barrackNextLevel['water']; $upgradeFood = $barrackNextLevel['food']; $upgradeLevelTo = $barrackNextLevel['level']; View::$data["upgrade"]["water"] = $upgradeWater; View::$data["upgrade"]["food"] = $upgradeFood; View::$data["upgrade"]["levelto"] = $upgradeLevelTo; if (isset($_POST['Upgrade'])) { Barracks::upgradeBarracks($nest[0], $upgradeLevelTo, 2); header("Location: /MVCProject/buildings/nest"); exit; } $model = null; return new View($model); }
public function home() { echo "<h1>Home</h1>"; $us = User::getUserById($_SESSION['id']); $us['nests'] = Nest::getUserNests($_SESSION['id']); View::$data['user'] = $us; $battles = BattleReport::getBattles(); $model = new HomeViewModel($battles); return new View($model); }
public static function assignMap() { $db = mysqli_connect("localhost", "root", "1234", "ant_rpg"); $result = mysqli_query($db, "SELECT * FROM map WHERE ocuppied = 0"); $rows = $result->fetch_all(); $idToAssign = rand(0, count($rows)); $update = mysqli_query($db, "UPDATE map SET ocuppied=1,ocuppied_by='" . $_SESSION['id'] . "' WHERE map_id='" . $rows[$idToAssign][0] . "'"); Nest::createNest($rows[$idToAssign][0]); mysqli_close($db); }