/** * @see AIService::processCPUTurn * * @param array $coordinatesCollection * @param array $expectedFlags */ private function assertProcessCPUTurnResult(array $coordinatesCollection, array $expectedFlags) { $battlefield = MockFactory::getBattlefieldMock(); foreach ($coordinatesCollection as $flag => $coordinates) { foreach ($coordinates as $coordinate) { $battlefield->getCellByCoordinate($coordinate)->setFlags($flag); } } static::$ai->processCPUTurn($battlefield); foreach ($battlefield->getCells() as $cell) { $this->assertEquals($expectedFlags[$cell->getCoordinate()] ?? CellModel::FLAG_NONE, $cell->getFlags()); } }
/** * @param Battlefield $battlefield * @param Cell $cell - this cell will be attacked if attacker is human * * @return Cell */ protected function processPlayerTurn(Battlefield $battlefield, Cell $cell) : Cell { return PlayerModel::isAIControlled($battlefield->getPlayer()) ? CellModel::switchPhase($cell) : $this->ai->processCPUTurn($battlefield); }