diff --git a/src/Domain/DeploymentZone.php b/src/Domain/DeploymentZone.php new file mode 100644 index 0000000..9e2f993 --- /dev/null +++ b/src/Domain/DeploymentZone.php @@ -0,0 +1,39 @@ + $positions */ + public function __construct( + public string $teamId, + public array $positions, + ) { + if ($teamId === '') { + throw new InvalidArgumentException('Deployment zone team id cannot be empty.'); + } + + if ($positions === []) { + throw new InvalidArgumentException('Deployment zone must contain at least one position.'); + } + + if (!array_is_list($positions)) { // @phpstan-ignore function.alreadyNarrowedType (Runtime guard: PHPDoc is not a runtime contract for JSON-sourced arrays in Plan 4.) + throw new InvalidArgumentException('Deployment zone positions must be a list.'); + } + } + + public function contains(Position $position): bool + { + foreach ($this->positions as $candidate) { + if ($candidate->key() === $position->key()) { + return true; + } + } + + return false; + } +} diff --git a/src/Domain/ObjectiveControl.php b/src/Domain/ObjectiveControl.php new file mode 100644 index 0000000..99914ff --- /dev/null +++ b/src/Domain/ObjectiveControl.php @@ -0,0 +1,46 @@ + $roundsByTeam */ + public function __construct(public array $roundsByTeam) + { + foreach ($roundsByTeam as $teamId => $count) { + if ($teamId === '') { + throw new InvalidArgumentException('Objective control team id cannot be empty.'); + } + if ($count < 0) { + throw new InvalidArgumentException('Objective control count cannot be negative.'); + } + } + } + + public static function empty(): self + { + return new self([]); + } + + public function recordRound(string $controllerTeamId): self + { + if ($controllerTeamId === '') { + throw new InvalidArgumentException('Controller team id cannot be empty.'); + } + + $next = $this->roundsByTeam; + $next[$controllerTeamId] = ($next[$controllerTeamId] ?? 0) + 1; + + return new self($next); + } + + /** @return array{teamId: string, rounds: int} */ + public function forTeam(string $teamId): array + { + return ['teamId' => $teamId, 'rounds' => $this->roundsByTeam[$teamId] ?? 0]; + } +} diff --git a/src/Domain/ObjectiveMarker.php b/src/Domain/ObjectiveMarker.php new file mode 100644 index 0000000..a3d9b23 --- /dev/null +++ b/src/Domain/ObjectiveMarker.php @@ -0,0 +1,24 @@ +id; + } +} diff --git a/src/Domain/VictoryCondition.php b/src/Domain/VictoryCondition.php new file mode 100644 index 0000000..8790875 --- /dev/null +++ b/src/Domain/VictoryCondition.php @@ -0,0 +1,11 @@ +