コード例 #1
0
ファイル: RandomEvents.php プロジェクト: sp1ke77/SymfonyGame
 /**
  * @return string
  */
 public function NewTradeTokenEvent()
 {
     /* This event causes a random tradegood_token to appear in a mapzone where
        there are currently fewer than three tradegoods. Note that this event will
        fail sometimes because it drew a mapzone with three tokens already present. */
     $mz = $this->map->getRandomPassableMapZone();
     $tradegood = $this->trade->searchZoneForTradegoodTokens($mz);
     if (count($tradegood) <= 2) {
         $tg = $this->trade->getARandomTradegoodPlatonic();
         $this->trade->insertANewTradegoodToken($mz, $tg);
         $this->news->createSomeNews(ucwords($tg->getNamed()) . ' will now be produced in ' . $mz->getX() . ', ' . $mz->getY() . '', $mz->getX(), $mz->getY());
         return ucwords($tg->getNamed()) . ' will now be produced in ' . $mz->getX() . ', ' . $mz->getY();
     }
 }
コード例 #2
0
ファイル: Behavior.php プロジェクト: sp1ke77/SymfonyGame
 /**
  * @param Clan $clan
  */
 public function consumeFood(Clan $clan)
 {
     $consumption = intval($clan->getPopulation() * 0.1);
     $newamt = $clan->getFood() - $consumption;
     if ($newamt <= 0) {
         if (rand(1, 3) == 3) {
             $clan->setPopulation($clan->getPopulation() - 1);
             $clan->setFood(0);
             $this->news->createSomeNews('Clan' . $clan->getId() . ' are starving', $clan->getX(), $clan->getY());
         } else {
             $clan->setFood(0);
         }
     } else {
         $clan->setFood($newamt);
     }
     $clan->update();
 }