From 12f5c0bd3a2b0689df1f3a9df7dcff4b80757aa2 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Sun, 5 Jul 2026 20:23:28 -0500 Subject: [PATCH] test: cover scenario to match flow with ability and objective --- tests/Unit/Domain/ScenarioTest.php | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/Unit/Domain/ScenarioTest.php b/tests/Unit/Domain/ScenarioTest.php index 18dad5b..0c160bc 100644 --- a/tests/Unit/Domain/ScenarioTest.php +++ b/tests/Unit/Domain/ScenarioTest.php @@ -6,6 +6,7 @@ namespace BattleForge\Tests\Unit\Domain; use BattleForge\Domain\Archetype; use BattleForge\Domain\Battlefield; +use BattleForge\Domain\CombatEngine; use BattleForge\Domain\DeploymentZone; use BattleForge\Domain\MatchState; use BattleForge\Domain\ObjectiveMarker; @@ -167,6 +168,40 @@ final class ScenarioTest extends TestCase self::assertSame($original->id, $fromMatch->id); } + public function testStartingAMatchWithAbilityAndObjectivePlaysThrough(): void + { + $units = [ + new UnitState('alpha-1', 'alpha', new Position(0, 0), 10, 10, 4, 2, 4, 2, false, Archetype::Striker, ['area_damage']), + new UnitState('alpha-2', 'alpha', new Position(1, 0), 9, 9, 3, 2, 4, 2, false, Archetype::Support, ['heal', 'buff']), + new UnitState('alpha-3', 'alpha', new Position(2, 0), 10, 10, 4, 3, 3, 2, false, Archetype::Defender), + new UnitState('bravo-1', 'bravo', new Position(7, 7), 7, 7, 4, 2, 5, 2, false, Archetype::Scout), + new UnitState('bravo-2', 'bravo', new Position(6, 7), 10, 10, 4, 2, 4, 2, false, Archetype::Striker), + new UnitState('bravo-3', 'bravo', new Position(5, 7), 10, 10, 4, 3, 3, 2, false, Archetype::Defender), + ]; + $scenario = new Scenario( + id: 'demo', + name: 'Demo', + battlefield: new Battlefield(8, 8), + units: $units, + deploymentZones: [ + 'alpha' => new DeploymentZone('alpha', [new Position(0, 0), new Position(1, 0), new Position(2, 0)]), + 'bravo' => new DeploymentZone('bravo', [new Position(7, 7), new Position(6, 7), new Position(5, 7)]), + ], + objectives: ['objective-1' => new ObjectiveMarker('objective-1', new Position(0, 0))], + victoryCondition: VictoryCondition::HoldObjective, + holdRoundsRequired: 2, + ); + + $match = $scenario->startMatch('alpha'); + $engine = new CombatEngine(); + $end1 = $engine->endTurn($match); + $end2 = $engine->endTurn($end1); + + self::assertSame('alpha', $end2->activeTeamId); + self::assertSame(['alpha' => 1], $end2->objectiveControl); + self::assertNull($end2->winnerTeamId); + } + /** @return list */ private function validUnitSet(): array {