From 32c29c11aed6c4d3a068125e64b9022e7ad12d3f Mon Sep 17 00:00:00 2001 From: root Date: Sun, 19 Jul 2026 21:45:42 +0000 Subject: [PATCH 1/2] Fix 500 on fleet movement page during moon destruction missions MoonDestructionMission was missing the static friendlyStatus property, causing getFriendlyStatus() to throw when FleetController rendered mission type 9 on /fleet/movement. Fixes #1446 Co-authored-by: Cursor --- app/GameMissions/MoonDestructionMission.php | 2 ++ tests/Feature/FleetMovementTest.php | 18 ++++++++++++++++++ tests/Unit/MoonDestructionMissionTest.php | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/app/GameMissions/MoonDestructionMission.php b/app/GameMissions/MoonDestructionMission.php index ad0be977c..9e7d32935 100644 --- a/app/GameMissions/MoonDestructionMission.php +++ b/app/GameMissions/MoonDestructionMission.php @@ -3,6 +3,7 @@ namespace OGame\GameMissions; use Illuminate\Support\Facades\DB; +use OGame\Enums\FleetMissionStatus; use OGame\Enums\FleetSpeedType; use OGame\GameMessages\FleetLostContact; use OGame\GameMessages\MoonDestroyed; @@ -34,6 +35,7 @@ class MoonDestructionMission extends GameMission protected static bool $hasReturnMission = true; protected static bool $blockedByServerAttackBlock = true; protected static FleetSpeedType $fleetSpeedType = FleetSpeedType::war; + protected static FleetMissionStatus $friendlyStatus = FleetMissionStatus::Hostile; public function isMissionPossible(PlanetService $planet, Coordinate $targetCoordinate, PlanetType $targetType, UnitCollection $units): MissionPossibleStatus { diff --git a/tests/Feature/FleetMovementTest.php b/tests/Feature/FleetMovementTest.php index a1d4e2ab0..8b66a8643 100644 --- a/tests/Feature/FleetMovementTest.php +++ b/tests/Feature/FleetMovementTest.php @@ -334,4 +334,22 @@ public function testFleetMovementShowsFleetSlots(): void // Should show fleet slots info $response->assertSee('Fleets'); } + + /** + * Regression test for #1446: /fleet/movement must not 500 when a moon destruction fleet is active. + */ + public function testFleetMovementShowsMoonDestructionMission(): void + { + $this->planetAddUnit('deathstar', 1); + $this->playerSetResearchLevel('computer_technology', 5); + $this->planetAddResources(new Resources(0, 0, 100000, 0)); + + $unitCollection = new UnitCollection(); + $unitCollection->addUnit(ObjectService::getUnitObjectByMachineName('deathstar'), 1); + $this->sendMissionToOtherPlayerMoon($unitCollection, new Resources(0, 0, 0, 0)); + + $response = $this->get('/fleet/movement'); + $response->assertStatus(200); + $response->assertSee('Moon Destruction'); + } } diff --git a/tests/Unit/MoonDestructionMissionTest.php b/tests/Unit/MoonDestructionMissionTest.php index 2285451e9..7c4b4670b 100644 --- a/tests/Unit/MoonDestructionMissionTest.php +++ b/tests/Unit/MoonDestructionMissionTest.php @@ -2,6 +2,7 @@ namespace Tests\Unit; +use OGame\Enums\FleetMissionStatus; use OGame\Factories\PlanetServiceFactory; use OGame\Factories\PlayerServiceFactory; use OGame\GameMissions\MoonDestructionMission; @@ -31,6 +32,11 @@ protected function setUp(): void ); } + public function testFriendlyStatusIsHostile(): void + { + $this->assertSame(FleetMissionStatus::Hostile, MoonDestructionMission::getFriendlyStatus()); + } + /** * @param array $args * @return mixed From ea062f01a9259441ba82630e8f0a5f790b40f271 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 19 Jul 2026 22:42:24 +0000 Subject: [PATCH 2/2] fix: set missionType=9 in moon destruction fleet movement test The class defaults to transport (3), so the regression test was dispatching the wrong mission and never asserted Moon Destruction. Co-authored-by: Cursor --- tests/Feature/FleetMovementTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/Feature/FleetMovementTest.php b/tests/Feature/FleetMovementTest.php index 8b66a8643..617afae5e 100644 --- a/tests/Feature/FleetMovementTest.php +++ b/tests/Feature/FleetMovementTest.php @@ -340,6 +340,8 @@ public function testFleetMovementShowsFleetSlots(): void */ public function testFleetMovementShowsMoonDestructionMission(): void { + $this->missionType = 9; // Moon Destruction + $this->planetAddUnit('deathstar', 1); $this->playerSetResearchLevel('computer_technology', 5); $this->planetAddResources(new Resources(0, 0, 100000, 0)); @@ -351,5 +353,6 @@ public function testFleetMovementShowsMoonDestructionMission(): void $response = $this->get('/fleet/movement'); $response->assertStatus(200); $response->assertSee('Moon Destruction'); + $response->assertSee('hostile', false); } }