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 ... ');
 }
Example #2
0
 /**
  * @param City $city
  * @return array
  */
 public function getClansByCity(City $city)
 {
     $query = "SELECT * FROM game.clan WHERE city=" . $city->getId() . ';';
     $this->db->setQuery($query);
     $this->db->query();
     $objList = $this->db->loadObjectList();
     $clans = null;
     foreach ($objList as $obj) {
         $clan = new Clan($obj->id);
         $clan->setDb($this->db);
         $clan->load();
         $clans[] = $clan;
     }
     return $clans;
 }
 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));
 }
Example #5
0
 /**
  * @param Clan $clan
  * @param City $city
  * @return mixed
  */
 public function clanBuyBehavior(Clan $clan, City $city)
 {
     $request = $this->rules->createRequest($clan, 'buy goods', $city->getId() . ',1,25');
     $result = $this->rules->submit($request);
     return $result['Description'];
 }
Example #6
0
 /**
  * @param IDepotHaver $issuer
  * @param City $city
  * @param $good
  * @param $amt
  * @return array
  */
 public function buyGoods(IDepotHaver $issuer, $city, $good, $amt)
 {
     $depot = new Depot($issuer->getDepot());
     $depot->setDb($this->db);
     $depot->load();
     $tgp = new TradegoodPlatonic($good);
     $tgp->setDb($this->db);
     $tgp->load();
     $city = new City($city);
     $city->setDb($this->db);
     $city->load();
     if (empty($depot) | empty($tgp)) {
         return $this->getResult('Event failure', 'Null depot or tradegood');
     }
     // Calculate costs, taxes, etc.
     $purse = $issuer->getCoin();
     $cost = $amt * $tgp->tradevalue;
     // If we have sufficient coin
     if ($purse >= $cost) {
         $this->SetCoins($issuer, $purse - $cost);
         $city->taxTrade($cost);
         $currentStores = $depot->GetValueByString($tgp->named);
         $depot->setValueByString($tgp->named, $currentStores + $amt);
         return $this->getResult('Success', 'bought ' . $amt . ' ' . $tgp->named . ' for ' . $cost . ' coin');
     } else {
         return $this->getResult('Illegal move', 'attempted to purchase ' . $amt . ' ' . $tgp->named . ' but had insufficient coin');
     }
 }
Example #7
0
 /**
  * Teleports the input IMappable to the input City
  *
  * @param IMappable $mappable
  * @param City $city
  */
 public function teleportCity(IMappable $mappable, City $city)
 {
     $query = 'UPDATE ' . $this->getClass($mappable) . ' SET x=' . $city->getX() . ' WHERE id=' . $mappable->getId() . ';';
     $this->db->setQuery($query);
     $this->db->query();
     $query = 'UPDATE ' . $this->getClass($mappable) . ' SET y=' . $city->getY() . ' WHERE id=' . $mappable->getId() . ';';
     $this->db->setQuery($query);
     $this->db->query();
 }