/** * @param Cell $cell * * @return Cell * @throws AIException */ private static function attackCell(Cell $cell) : Cell { if ($cell->hasFlag(CellModel::FLAG_DEAD)) { throw new AIException("cell: {$cell->getId()} already flagged as *DEAD*"); } return CellModel::switchPhase($cell); }
/** * @param Cell $cell * @param int $additionalFlag - additional flag which will be applied with CellModel::FLAG_DEAD * * @return Cell */ public static function switchPhase(Cell $cell, int $additionalFlag = self::FLAG_NONE) : Cell { if (!$cell->hasFlag(CellModel::FLAG_DEAD)) { static::$changedCells[$cell->getId()] = $cell->addFlag($additionalFlag | CellModel::FLAG_DEAD); } return $cell; }