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; }
protected function execute(InputInterface $input, OutputInterface $output) { /** @var LoggerInterface $logger */ $logger = $this->getContainer()->get('logger'); $logger->info('DailyBudgets begun ... '); $map = $this->getContainer()->get('service_map'); $agents = $this->getContainer()->get('service_agent'); $db = $this->getContainer()->get('db'); $allCities = $map->getCitiesByID(); foreach ($allCities as $k => $c) { $city = new City($c->id); $city->setDb($db); $city->load(); $agentList = $agents->getAgentsByCity($c->id); foreach ($agentList as $j => $a) { $agent = new Agent($a->id); $agent->setDb($db); $agent->load(); $agent->setTradeincome($city->getTradeincome()); $income = $agent->getCoin() + ceil($city->getTradeincome()); $logger->info('The estate of ' . $agent->getNamed() . ' collected ' . $city->getTradeincome() . ' from nearby markets'); $agent->setCoin($income); $agent->update(); } $city->setTradeincome(0.0); $city->update(); } $logger->info('DailyBudgets complete ... '); }
function indexAction() { $db = $this->get('db'); $session = $this->get('session'); $aid = $session->get('aid'); $player = new Agent($aid); $player->setDb($db); $player->load(); $cid = $player->getCity(); $city = new City($cid); $city->setDb($db); $city->load(); $persona = new Persona($player->getPersona()); $persona->setDb($db); $persona->load(); $player->setDb(null); $player->setIsplayer(null); $player->setPtype(null); return $this->render('GameBundle:Game:characterview.html.twig', array('myCity' => $city, 'myCharacter' => $player, 'myReputation' => $persona)); }
function indexAction() { $db = $this->get('db'); $session = $this->get('session'); $aid = $session->get('aid'); $player = new Agent($aid); $player->setDb($db); $player->load(); $cid = $player->getCity(); $city = new City($cid); $city->setDb($db); $city->load(); $myName = $player->getNamed(); $myCoin = $player->getCoin(); $myCity = $city->getNamed(); $myTradeIncome = $city->getTradeincome(); // City's property reflects tomorrow's income from markets $myTotalIncome = $myTradeIncome; $myBuildingCosts = 0; $myTotalCosts = $myBuildingCosts; $myTotal = $myCoin + ceil($myTotalIncome) - $myTotalCosts; $myBuildings = []; return $this->render('GameBundle:Game:estateview.html.twig', array('myName' => $myName, 'myCoin' => $myCoin, 'myCity' => $myCity, 'myTradeIncome' => $myTradeIncome, 'myBuildingCosts' => $myBuildingCosts, 'myTotal' => $myTotal, 'myBuildings' => $myBuildings)); }
/** * @param $userid * @param $named * @param $culture * @param $city * @param $allegiance * @return int */ private function newPlayerAgent($userid, $named, $culture, $city, $allegiance) { // Create an undefined object to be assembled and pass it the DB $agent = new Agent(null); $agent->setDb($this->db); // Plunk, plonk, plonk $agent->setIsplayer(true); $agent->setUserid($userid); $agent->setNamed($named); $agent->setCulture($culture); // Get the player's chosen city out of the DB $query = 'SELECT * FROM game.city WHERE named="' . $city . '";'; $this->db->setQuery($query); $this->db->query(); $dbObject = $this->db->loadObject(); // Plunk, plonk, city data $agent->setX($dbObject->x); $agent->setY($dbObject->y); $agent->setCity($dbObject->id); $agent->setActivity('idle'); // Create a new buildinglist and point the value of $this->holdings to its primary key $query = 'INSERT INTO game.estate(id) VALUES(null);'; $this->db->setQuery($query); $this->db->query(); $agent->setHoldings($this->db->getLastInsertId()); // Ditto for a blank persona $query = 'INSERT INTO game.persona(id) VALUES(null);'; $this->db->setQuery($query); $this->db->query(); $agent->setPersona($this->db->getLastInsertId()); // Plunk $agent->setAllegiance($allegiance); // Insert the new Agent into SQL and return the primary key $agent->update(); return $this->db->getLastInsertId(); }