public function trashDeadObjects() { $getAll[] = $this->getAllDeadClans(); $clans = $getAll[0]; if (!isset($clans)) { $this->status .= 'No dead clans found this turn.'; } else { $score = 0; foreach ($clans as $clan) { // Get the tribe name and pass it along ... $query = "SELECT named FROM tribe WHERE id=" . $clan->getClanId() . ";"; $this->db->setQuery($query); $tribeName = $this->db->loadResult(); // Create some news about the death ... $query = "INSERT INTO News(text) VALUE('A clan of the tribe of " . $tribeName . " have dwindled to nothing. Last seen in " . $clan->getX() . ", " . $clan->getY() . "');"; $this->db->setQuery($query); $this->db->Query($query); // Rack one up $score += 1; // Trash the record for the clan $query = "DELETE FROM clan WHERE id=" . $clan->getClanId() . ";"; $this->db->setQuery($query); $this->db->Query($query); } $this->status .= "Clans killed this round: " . $score; } }
function getCharacterByUserID($userid) { // Check if this is in the DB or not. $query = 'select characterid from game.useraccount where id=' . $userid . ';'; $this->db->setQuery($query); $result = $this->db->loadResult(); return $result; }
function getMapviewID($agentid) { $character = new Agent($agentid); $character->setDb($this->db); $character->load(); $topleft['x'] = $character->getX() - 5; $topleft['y'] = $character->getY() - 3; $query = "SELECT id FROM game.mapzone WHERE x=" . $topleft['x'] . " AND y=" . $topleft['y'] . ";"; $this->db->setQuery($query); $this->db->query(); $mvid = $this->db->loadResult(); return $mvid; }
public function createClan($tribeId) { $depotId = $this->createDepot(); $query = "SELECT named FROM tribe WHERE id=" . $tribeId . ";"; $this->db->setQuery($query); $this->db->query(); $tribeName = $this->db->loadResult(); // This will eventually point to some logic for placing clans by culture-group $mz = $this->map->getRandomPassableMapZone(); $x = $mz->getX(); $y = $mz->getY(); $query = "INSERT INTO clan(named, tribe, x, y, depot, population, fighters, morale, food, coin, activity) VALUES('" . $tribeName . "', " . $tribeId . ", " . $x . ', ' . $y . ', ' . $depotId . ", 100, 60, 100, 35, 0, 'wandering');"; $this->db->setQuery($query); $this->db->query(); }
/** * INSERT INTO game.clan * * Must have a valid tribeId to create a clan * * @param $tribeId */ private function createClan($tribeId) { $depotId = $this->createDepot(); $query = "SELECT named FROM tribe WHERE id=" . $tribeId . ";"; $this->db->setQuery($query); $this->db->query(); $tribeName = $this->db->loadResult(); $MapService = new MapService(); $MapService->setDb($this->db); $mz = $MapService->getRandomPassableMapZone(); $x = $mz->getX(); $y = $mz->getY(); $query = "INSERT INTO clan(named, tribe, x, y, depot, population, fighters, morale, food, coin, activity) VALUES('" . $tribeName . "', " . $tribeId . ", " . $x . ', ' . $y . ', ' . $depotId . ", 100, 60, 100, 35, 0, 'wandering');"; $this->db->setQuery($query); $this->db->query(); }