/** * Check if all neighbors are neutral or yours * * @param \Mastercoding\Conquest\Object\Map $map * @param \Mastercoding\Conquest\Object\Region $region */ public static function allYoursOrDifferentContinentNeutral(\Mastercoding\Conquest\Object\map $map, \Mastercoding\Conquest\Object\Region $region) { // neighbors foreach ($region->getNeighbors() as $neighbor) { // not all mine, continue in parent loop if ($neighbor->getOwner() == $map->getYou()) { continue; } // neutral and same continent if ($neighbor->getOwner()->getName() == \Mastercoding\Conquest\Object\Owner\AbstractOwner::NEUTRAL && $neighbor->getContinentId() != $region->getContinentId()) { continue; } // false return false; } return true; }
/** * Check if the path is yours (can you walk it) * * @param \Mastercoding\Conquest\Object\map $map * @param Array $path * @return bool */ public function pathYours(\Mastercoding\Conquest\Object\map $map, array $path) { foreach ($path as $region) { if ($region->getOwner() != $map->getYou()) { return false; } } return true; }