예제 #1
0
 /**
  * @inheritDoc
  */
 public function pickRegions(\Mastercoding\Conquest\Bot\AbstractBot $bot, \Mastercoding\Conquest\Move\PickRegions $move, $amountLeft, \Mastercoding\Conquest\Command\StartingRegions\Pick $pickCommand)
 {
     // possible regions
     $regionIds = array_diff($pickCommand->getRegionIds(), $move->getRegionIds());
     // map region ids by continent
     $mappedRegions = array();
     foreach ($regionIds as $regionId) {
         // get region
         $region = $bot->getMap()->getRegionById($regionId);
         $mappedRegions[$region->getContinentId()][] = $regionId;
     }
     // now return as many different as possible
     $chosenRegions = array();
     foreach ($mappedRegions as $continentId => $regions) {
         $region = $this->pickRegionForContinent($bot, $bot->getMap()->getContinentById($continentId), $regions);
         $chosenRegions[] = $region;
         // remove region id from array
         $regionIds = array_diff($regionIds, array($region));
     }
     // add additional
     $amountToPick = $amountLeft - count($chosenRegions);
     if ($amountToPick > 0) {
         $chosenRegions = array_merge($chosenRegions, $this->pickAdditionalRegions($chosenRegions, $regionIds, $amountToPick));
     }
     // return as command
     for ($i = 0; $i < $amountLeft; $i++) {
         $move->addRegionId($chosenRegions[$i]);
     }
     // ok
     return array($move, 0);
 }
예제 #2
0
 /**
  * @inheritDoc
  */
 public function pickRegions(\Mastercoding\Conquest\Bot\AbstractBot $bot, \Mastercoding\Conquest\Move\PickRegions $move, $amountLeft, \Mastercoding\Conquest\Command\StartingRegions\Pick $pickCommand)
 {
     // choices
     $choices = array_diff($pickCommand->getRegionIds(), $move->getRegionIds());
     // only pick random if amount left is 6, because issues otherwise
     $random = array_rand($choices, $amountLeft);
     foreach ($random as $key) {
         $move->addRegionId($choices[$key]);
     }
     return array($move, 0);
 }