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(); $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)); }