/** * @param Battlefield $battlefield * * @return Cell[] */ public function chooseCells(Battlefield $battlefield) : array { foreach ($battlefield->getCells() as $cell) { if (!$cell->hasFlag(CellModel::FLAG_DEAD_SHIP) || CellModel::isShipDead($cell)) { continue; } return $this->processor->process($cell, $this->chooseStrategy($cell)); } return []; }
private function verifyCellsByStrategy(array $expectedCoordinates, int $strategy) { $cells = static::$strategyProcessor->process(MockFactory::getBattlefieldMock()->getCellByCoordinate('B2'), $strategy); $this->assertCount(count($expectedCoordinates), $cells); $this->assertContainsOnlyInstancesOf(Cell::class, $cells); foreach ($cells as $cell) { $this->assertContains($cell->getCoordinate(), $expectedCoordinates); } }