From efad93685403feb2d23855910ec469c4bf820dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Sun, 10 Dec 2023 14:07:23 +0100 Subject: [PATCH 1/4] Some naming and directory refactoring --- .../CancelConstructingCommandHandlerSpec.php | 2 +- .../FinishConstructingCommandHandlerSpec.php | 2 +- ...structingNewBuildingCommandHandlerSpec.php | 4 +- ...artUpgradingBuildingCommandHandlerSpec.php | 2 +- .../Domain/Entity/BuildingSpec.php | 8 +- .../Factory/BuildingTypeEventFactorySpec.php | 4 +- .../Domain/Factory/BuildingFactorySpec.php | 4 +- .../Command/ReturnJourneysCommandSpec.php | 8 +- .../Command/TargetJourneysCommandSpec.php | 8 +- .../ReturnJourneysCommandHandlerSpec.php | 20 ++--- .../StartJourneyCommandHandlerSpec.php | 6 +- .../TargetJourneysCommandHandlerSpec.php | 28 +++---- .../FleetJourney/Domain/Entity/FleetSpec.php | 78 +++++++++---------- .../Domain/Entity/JourneySpec.php | 32 ++++---- .../Domain/Factory/FleetFactorySpec.php | 2 +- .../Domain/Factory/JourneyFactorySpec.php | 4 +- .../FleetJourney/Domain/ShipsGroupSpec.php | 16 ++-- ...nstructedShipsToFleetEventListenerSpec.php | 4 +- ...OnReachingTargetPointEventListenerSpec.php | 2 +- .../FleetJourney/FleetResolverSpec.php | 2 +- .../ExtractResourcesCommandHandlerSpec.php | 4 +- .../ResourceMines/Domain/Entity/MineSpec.php | 2 +- .../Domain/Entity/MinesCollectionSpec.php | 4 +- .../Domain/Factory/MineFactorySpec.php | 2 +- .../UpgradeMineEventListenerSpec.php | 4 +- .../ResourceAvailabilityCheckerSpec.php | 4 +- .../DispatchResourcesCommandHandlerSpec.php | 4 +- .../UseResourceCommandHandlerSpec.php | 4 +- .../Domain/Entity/StorageSpec.php | 2 +- .../Domain/Entity/StoragesCollectionSpec.php | 4 +- .../Domain/Factory/StorageFactorySpec.php | 2 +- ...ingJourneyReturnPointEventListenerSpec.php | 2 +- ...ingJourneyTargetPointEventListenerSpec.php | 12 +-- .../UpgradeStorageEventListenerSpec.php | 4 +- .../CancelJobCommandHandlerSpec.php | 2 +- .../ConstructCannonsCommandHandlerSpec.php | 2 +- .../ConstructShipsCommandHandlerSpec.php | 2 +- .../FinishJobsCommandHandlerSpec.php | 2 +- .../Shipyard/Domain/Entity/JobSpec.php | 2 +- .../Shipyard/Domain/Entity/ShipyardSpec.php | 2 +- .../FinishedConstructionEventFactorySpec.php | 2 +- .../NewShipsHaveBeenConstructedEventSpec.php | 2 +- .../Domain/Factory/ShipyardFactorySpec.php | 2 +- .../UpgradeShipyardEventListenerSpec.php | 2 +- .../Domain/ResourceAmountSpec.php | 2 +- .../SharedKernel/Domain/ResourcesSpec.php | 2 +- .../Bridge/FleetJourneyContextInterface.php | 4 +- .../Bridge/ResourceMinesContextInterface.php | 2 +- .../ResourceStoragesContextInterface.php | 2 +- .../BuildingRepositoryInterface.php | 4 +- .../CancelConstructingCommandHandler.php | 2 +- .../FinishConstructingCommandHandler.php | 2 +- ...tConstructingNewBuildingCommandHandler.php | 4 +- .../StartUpgradingBuildingCommandHandler.php | 2 +- .../Domain/Entity/Building.php | 4 +- .../BuildingHasBeenAlreadyBuiltException.php | 2 +- .../BuildingIsAlreadyUpgradingException.php | 2 +- .../BuildingIsNotUpgradingYetException.php | 2 +- .../BuildingTimeHasNotPassedException.php | 2 +- .../InsufficientResourcesException.php | 2 +- .../Domain/Factory/BuildingFactory.php | 4 +- .../Factory/BuildingFactoryInterface.php | 4 +- .../Command/ReturnJourneysCommand.php | 6 +- .../Command/TargetJourneysCommand.php | 6 +- .../ReturnJourneysCommandHandler.php | 6 +- .../StartJourneyCommandHandler.php | 8 +- .../TargetJourneysCommandHandler.php | 6 +- .../FleetJourney/Domain/Entity/Fleet.php | 24 +++--- .../FleetJourney/Domain/Entity/Journey.php | 12 +-- .../CannotMergeShipGroupsOfDifferentShips.php | 21 +++++ ...ergeShipGroupsOfDifferentTypeException.php | 21 ----- .../JourneyMissionIsNotEligibleException.php | 4 +- .../NoFleetStationingOnPlanetException.php | 2 +- ...ResourcesOnPlanetForFleetLoadException.php | 2 +- .../Exception/NotEnoughShipsException.php | 4 +- .../Domain/Factory/JourneyFactory.php | 8 +- .../Factory/JourneyFactoryInterface.php | 8 +- .../FleetJourney/Domain/ShipsGroup.php | 26 +++---- .../Domain/ShipsGroupInterface.php | 4 +- ...lyConstructedShipsToFleetEventListener.php | 12 +-- ...leetOnReachingTargetPointEventListener.php | 6 +- .../FleetJourney/FleetRepositoryInterface.php | 8 +- .../Component/FleetJourney/FleetResolver.php | 2 +- .../FleetJourney/FleetResolverInterface.php | 2 +- .../ExtractResourcesCommandHandler.php | 2 +- .../ResourceMines/Domain/Entity/Mine.php | 2 +- .../Domain/Entity/MinesCollection.php | 4 +- ...ngSpeedForUnsupportedResourceException.php | 4 +- .../Domain/Factory/MineFactory.php | 2 +- .../Domain/Factory/MineFactoryInterface.php | 2 +- .../UpgradeMineEventListener.php | 4 +- .../ResourceMinesRepositoryInterface.php | 2 +- .../Bridge/ResourceAvailabilityChecker.php | 2 +- .../ResourceAvailabilityCheckerInterface.php | 2 +- .../DispatchResourcesCommandHandler.php | 4 +- .../UseResourceCommandHandler.php | 4 +- .../ResourceStorage/Domain/Entity/Storage.php | 2 +- .../Domain/Entity/StoragesCollection.php | 4 +- ...StorageForUnsupportedResourceException.php | 4 +- ...radeStorageLimitForLowerValueException.php | 2 +- .../CannotUseUnsupportedResourceException.php | 2 +- .../InsufficientResourcesException.php | 2 +- .../Domain/Factory/StorageFactory.php | 2 +- .../Factory/StorageFactoryInterface.php | 2 +- ...eachingJourneyTargetPointEventListener.php | 6 +- .../UpgradeStorageEventListener.php | 4 +- .../ResourceStoragesRepositoryInterface.php | 2 +- .../Shipyard/Domain/Entity/Shipyard.php | 2 +- .../FinishedConstructionEventFactory.php | 2 +- ...ishedConstructionEventFactoryInterface.php | 2 +- .../NewShipsHaveBeenConstructedEvent.php | 8 +- .../InsufficientResourcesException.php | 2 +- .../Domain/Factory/ShipyardFactory.php | 2 +- .../Factory/ShipyardFactoryInterface.php | 2 +- .../UpgradeShipyardEventListener.php | 2 +- .../Shipyard/ShipyardRepositoryInterface.php | 2 +- .../Domain/{ => EntityId}/PlanetId.php | 2 +- .../{ => EntityId}/PlanetIdInterface.php | 2 +- .../{UserId.php => EntityId/PlayerId.php} | 4 +- .../Domain/EntityId/PlayerIdInterface.php | 11 +++ .../Domain/{ => EntityId}/ResourceId.php | 2 +- .../{ => EntityId}/ResourceIdInterface.php | 2 +- .../InvalidResourceAmountException.php | 2 +- .../Domain/FleetMissionType.php} | 10 ++- .../SharedKernel/Domain/ResourceAmount.php | 1 + .../Domain/ResourceAmountInterface.php | 2 + .../SharedKernel/Domain/Resources.php | 3 + .../Domain/ResourcesInterface.php | 2 + .../SharedKernel/Domain/UserIdInterface.php | 11 --- .../SharedKernel/UuidGeneratorInterface.php | 6 ++ 130 files changed, 361 insertions(+), 345 deletions(-) create mode 100644 src/Application/Component/FleetJourney/Domain/Exception/CannotMergeShipGroupsOfDifferentShips.php delete mode 100644 src/Application/Component/FleetJourney/Domain/Exception/CannotMergeShipGroupsOfDifferentTypeException.php rename src/Application/SharedKernel/Domain/{ => EntityId}/PlanetId.php (80%) rename src/Application/SharedKernel/Domain/{ => EntityId}/PlanetIdInterface.php (70%) rename src/Application/SharedKernel/Domain/{UserId.php => EntityId/PlayerId.php} (64%) create mode 100644 src/Application/SharedKernel/Domain/EntityId/PlayerIdInterface.php rename src/Application/SharedKernel/Domain/{ => EntityId}/ResourceId.php (80%) rename src/Application/SharedKernel/Domain/{ => EntityId}/ResourceIdInterface.php (70%) rename src/Application/{Component/FleetJourney/Domain/MissionType.php => SharedKernel/Domain/FleetMissionType.php} (53%) delete mode 100644 src/Application/SharedKernel/Domain/UserIdInterface.php diff --git a/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/CancelConstructingCommandHandlerSpec.php b/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/CancelConstructingCommandHandlerSpec.php index 8b63fba..59b05e0 100644 --- a/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/CancelConstructingCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/CancelConstructingCommandHandlerSpec.php @@ -13,7 +13,7 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Entity\Building; use TheGame\Application\Component\BuildingConstruction\Domain\Event\BuildingConstructionHasBeenCancelledEvent; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/FinishConstructingCommandHandlerSpec.php b/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/FinishConstructingCommandHandlerSpec.php index ee3f442..d485ed0 100644 --- a/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/FinishConstructingCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/FinishConstructingCommandHandlerSpec.php @@ -12,7 +12,7 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Entity\Building; use TheGame\Application\Component\BuildingConstruction\Domain\Event\Factory\BuildingTypeEventFactoryInterface; use TheGame\Application\Component\BuildingConstruction\Domain\Event\ResourceStorageConstructionHasBeenFinishedEvent; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/StartConstructingNewBuildingCommandHandlerSpec.php b/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/StartConstructingNewBuildingCommandHandlerSpec.php index 7d7a9f7..215bd79 100644 --- a/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/StartConstructingNewBuildingCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/StartConstructingNewBuildingCommandHandlerSpec.php @@ -18,8 +18,8 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Factory\BuildingFactoryInterface; use TheGame\Application\Component\ResourceStorage\Bridge\ResourceAvailabilityCheckerInterface; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetId; -use TheGame\Application\SharedKernel\Domain\ResourceId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; use TheGame\Application\SharedKernel\EventBusInterface; diff --git a/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/StartUpgradingBuildingCommandHandlerSpec.php b/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/StartUpgradingBuildingCommandHandlerSpec.php index 217975c..7f33183 100644 --- a/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/StartUpgradingBuildingCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/BuildingConstruction/CommandHandler/StartUpgradingBuildingCommandHandlerSpec.php @@ -16,7 +16,7 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Exception\InsufficientResourcesException; use TheGame\Application\Component\ResourceStorage\Bridge\ResourceAvailabilityCheckerInterface; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/spec/TheGame/Application/Component/BuildingConstruction/Domain/Entity/BuildingSpec.php b/spec/TheGame/Application/Component/BuildingConstruction/Domain/Entity/BuildingSpec.php index eee047f..37325df 100644 --- a/spec/TheGame/Application/Component/BuildingConstruction/Domain/Entity/BuildingSpec.php +++ b/spec/TheGame/Application/Component/BuildingConstruction/Domain/Entity/BuildingSpec.php @@ -11,10 +11,10 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Exception\BuildingIsNotUpgradingYetException; use TheGame\Application\Component\BuildingConstruction\Domain\Exception\BuildingTimeHasNotPassedException; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetId; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; -use TheGame\Application\SharedKernel\Domain\ResourceId; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; final class BuildingSpec extends ObjectBehavior { diff --git a/spec/TheGame/Application/Component/BuildingConstruction/Domain/Event/Factory/BuildingTypeEventFactorySpec.php b/spec/TheGame/Application/Component/BuildingConstruction/Domain/Event/Factory/BuildingTypeEventFactorySpec.php index 0050f60..62ad556 100644 --- a/spec/TheGame/Application/Component/BuildingConstruction/Domain/Event/Factory/BuildingTypeEventFactorySpec.php +++ b/spec/TheGame/Application/Component/BuildingConstruction/Domain/Event/Factory/BuildingTypeEventFactorySpec.php @@ -13,8 +13,8 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Event\ResourceStorageConstructionHasBeenFinishedEvent; use TheGame\Application\Component\BuildingConstruction\Domain\Event\ShipyardConstructionHasBeenFinishedEvent; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetId; -use TheGame\Application\SharedKernel\Domain\ResourceId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; final class BuildingTypeEventFactorySpec extends ObjectBehavior { diff --git a/spec/TheGame/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactorySpec.php b/spec/TheGame/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactorySpec.php index 74415f6..f3b8924 100644 --- a/spec/TheGame/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactorySpec.php +++ b/spec/TheGame/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactorySpec.php @@ -7,8 +7,8 @@ use PhpSpec\ObjectBehavior; use TheGame\Application\Component\BuildingConstruction\Domain\BuildingIdInterface; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; use TheGame\Application\SharedKernel\UuidGeneratorInterface; final class BuildingFactorySpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/FleetJourney/Command/ReturnJourneysCommandSpec.php b/spec/TheGame/Application/Component/FleetJourney/Command/ReturnJourneysCommandSpec.php index 9a1eb20..4592aec 100644 --- a/spec/TheGame/Application/Component/FleetJourney/Command/ReturnJourneysCommandSpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/Command/ReturnJourneysCommandSpec.php @@ -10,12 +10,12 @@ final class ReturnJourneysCommandSpec extends ObjectBehavior { public function let(): void { - $userId = "0cfe1c65-2cac-4138-92bd-fac68027c39b"; - $this->beConstructedWith($userId); + $playerId = "0cfe1c65-2cac-4138-92bd-fac68027c39b"; + $this->beConstructedWith($playerId); } - public function it_has_user_id(): void + public function it_has_player_id(): void { - $this->getUserId()->shouldReturn("0cfe1c65-2cac-4138-92bd-fac68027c39b"); + $this->getPlayerId()->shouldReturn("0cfe1c65-2cac-4138-92bd-fac68027c39b"); } } diff --git a/spec/TheGame/Application/Component/FleetJourney/Command/TargetJourneysCommandSpec.php b/spec/TheGame/Application/Component/FleetJourney/Command/TargetJourneysCommandSpec.php index f1e722d..341f040 100644 --- a/spec/TheGame/Application/Component/FleetJourney/Command/TargetJourneysCommandSpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/Command/TargetJourneysCommandSpec.php @@ -10,12 +10,12 @@ final class TargetJourneysCommandSpec extends ObjectBehavior { public function let(): void { - $userId = "c20f9c5c-09eb-4eba-bf7a-899507264f6a"; - $this->beConstructedWith($userId); + $playerId = "c20f9c5c-09eb-4eba-bf7a-899507264f6a"; + $this->beConstructedWith($playerId); } - public function it_has_user_id(): void + public function it_has_player_id(): void { - $this->getUserId()->shouldReturn("c20f9c5c-09eb-4eba-bf7a-899507264f6a"); + $this->getPlayerId()->shouldReturn("c20f9c5c-09eb-4eba-bf7a-899507264f6a"); } } diff --git a/spec/TheGame/Application/Component/FleetJourney/CommandHandler/ReturnJourneysCommandHandlerSpec.php b/spec/TheGame/Application/Component/FleetJourney/CommandHandler/ReturnJourneysCommandHandlerSpec.php index fe605af..a7f5484 100644 --- a/spec/TheGame/Application/Component/FleetJourney/CommandHandler/ReturnJourneysCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/CommandHandler/ReturnJourneysCommandHandlerSpec.php @@ -11,8 +11,8 @@ use TheGame\Application\Component\FleetJourney\Domain\Event\FleetHasReachedJourneyReturnPointEvent; use TheGame\Application\Component\FleetJourney\Domain\FleetId; use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlayerId; use TheGame\Application\SharedKernel\Domain\GalaxyPoint; -use TheGame\Application\SharedKernel\Domain\UserId; use TheGame\Application\SharedKernel\EventBusInterface; final class ReturnJourneysCommandHandlerSpec extends ObjectBehavior @@ -30,9 +30,9 @@ public function it_returns_journey_of_two_fleets( Fleet $fleet1, Fleet $fleet2, ): void { - $userId = "8e807726-4a48-489e-9706-16061705bb6a"; + $playerId = "8e807726-4a48-489e-9706-16061705bb6a"; - $fleetRepository->findFlyingBackFromJourneyForUser(new UserId($userId)) + $fleetRepository->findFlyingBackFromJourneyForPlayer(new PlayerId($playerId)) ->willReturn([ $fleet1->getWrappedObject(), $fleet2->getWrappedObject(), @@ -60,7 +60,7 @@ public function it_returns_journey_of_two_fleets( $eventBus->dispatch(Argument::type(FleetHasReachedJourneyReturnPointEvent::class)) ->shouldBeCalledTimes(2); - $this->__invoke(new ReturnJourneysCommand($userId)); + $this->__invoke(new ReturnJourneysCommand($playerId)); } public function it_skips_fleet_when_it_has_not_returned_from_journey( @@ -69,9 +69,9 @@ public function it_skips_fleet_when_it_has_not_returned_from_journey( Fleet $fleet1, Fleet $fleet2, ): void { - $userId = "8e807726-4a48-489e-9706-16061705bb6a"; + $playerId = "8e807726-4a48-489e-9706-16061705bb6a"; - $fleetRepository->findFlyingBackFromJourneyForUser(new UserId($userId)) + $fleetRepository->findFlyingBackFromJourneyForPlayer(new PlayerId($playerId)) ->willReturn([ $fleet1->getWrappedObject(), $fleet2->getWrappedObject(), @@ -91,21 +91,21 @@ public function it_skips_fleet_when_it_has_not_returned_from_journey( $eventBus->dispatch(Argument::type(FleetHasReachedJourneyReturnPointEvent::class)) ->shouldBeCalledTimes(1); - $this->__invoke(new ReturnJourneysCommand($userId)); + $this->__invoke(new ReturnJourneysCommand($playerId)); } public function it_does_nothing_when_no_returning_fleet_found( FleetRepositoryInterface $fleetRepository, EventBusInterface $eventBus, ): void { - $userId = "8e807726-4a48-489e-9706-16061705bb6a"; + $playerId = "8e807726-4a48-489e-9706-16061705bb6a"; - $fleetRepository->findFlyingBackFromJourneyForUser(new UserId($userId)) + $fleetRepository->findFlyingBackFromJourneyForPlayer(new PlayerId($playerId)) ->willReturn([]); $eventBus->dispatch(Argument::type(FleetHasReachedJourneyReturnPointEvent::class)) ->shouldNotBeCalled(); - $this->__invoke(new ReturnJourneysCommand($userId)); + $this->__invoke(new ReturnJourneysCommand($playerId)); } } diff --git a/spec/TheGame/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandlerSpec.php b/spec/TheGame/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandlerSpec.php index 48c90b9..59fe201 100644 --- a/spec/TheGame/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandlerSpec.php @@ -15,11 +15,11 @@ use TheGame\Application\Component\FleetJourney\Domain\Exception\JourneyMissionIsNotEligibleException; use TheGame\Application\Component\FleetJourney\Domain\Factory\JourneyFactoryInterface; use TheGame\Application\Component\FleetJourney\Domain\FleetIdInterface; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\Component\FleetJourney\FleetResolverInterface; use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; use TheGame\Application\SharedKernel\EventBusInterface; @@ -91,7 +91,7 @@ public function it_starts_journey( $journeyFactory->createJourney( $fleetId, - MissionType::Transport, + FleetMissionType::Transport, $startGalaxyPoint, $targetGalaxyPointStub, $journeyDuration, diff --git a/spec/TheGame/Application/Component/FleetJourney/CommandHandler/TargetJourneysCommandHandlerSpec.php b/spec/TheGame/Application/Component/FleetJourney/CommandHandler/TargetJourneysCommandHandlerSpec.php index f552829..32d488f 100644 --- a/spec/TheGame/Application/Component/FleetJourney/CommandHandler/TargetJourneysCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/CommandHandler/TargetJourneysCommandHandlerSpec.php @@ -10,10 +10,10 @@ use TheGame\Application\Component\FleetJourney\Domain\Entity\Fleet; use TheGame\Application\Component\FleetJourney\Domain\Event\FleetHasReachedJourneyTargetPointEvent; use TheGame\Application\Component\FleetJourney\Domain\FleetId; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlayerId; use TheGame\Application\SharedKernel\Domain\GalaxyPoint; -use TheGame\Application\SharedKernel\Domain\UserId; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; use TheGame\Application\SharedKernel\EventBusInterface; final class TargetJourneysCommandHandlerSpec extends ObjectBehavior @@ -31,9 +31,9 @@ public function it_reaches_journey_target_for_two_fleets( Fleet $fleet1, Fleet $fleet2, ): void { - $userId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b"; + $playerId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b"; - $fleetRepository->findInJourneyForUser(new UserId($userId)) + $fleetRepository->findInJourneyForPlayer(new PlayerId($playerId)) ->willReturn([ $fleet1->getWrappedObject(), $fleet2->getWrappedObject(), @@ -42,7 +42,7 @@ public function it_reaches_journey_target_for_two_fleets( $fleet1->tryToReachJourneyTargetPoint()->shouldBeCalledOnce(); $fleet1->didReachJourneyTargetPoint()->willReturn(true); $fleet1->getId()->willReturn(new FleetId("dfdd04c6-9243-4775-834c-ad702003ef6b")); - $fleet1->getJourneyMissionType()->willReturn(MissionType::Transport); + $fleet1->getJourneyMissionType()->willReturn(FleetMissionType::Transport); $fleet1->getJourneyTargetPoint()->willReturn(new GalaxyPoint(1, 2, 3)); $fleet1->getResourcesLoad()->willReturn([ "8de65203-ad4c-4ce7-bced-cfeda9107b5d" => 300, @@ -52,14 +52,14 @@ public function it_reaches_journey_target_for_two_fleets( $fleet2->tryToReachJourneyTargetPoint()->shouldBeCalledOnce(); $fleet2->didReachJourneyTargetPoint()->willReturn(true); $fleet2->getId()->willReturn(new FleetId("6da596f9-f66a-4912-9603-06f538621695")); - $fleet2->getJourneyMissionType()->willReturn(MissionType::Stationing); + $fleet2->getJourneyMissionType()->willReturn(FleetMissionType::Stationing); $fleet2->getJourneyTargetPoint()->willReturn(new GalaxyPoint(2, 3, 4)); $fleet2->getResourcesLoad()->willReturn([]); $eventBus->dispatch(Argument::type(FleetHasReachedJourneyTargetPointEvent::class)) ->shouldBeCalledTimes(2); - $command = new TargetJourneysCommand($userId); + $command = new TargetJourneysCommand($playerId); $this->__invoke($command); } @@ -69,9 +69,9 @@ public function it_skips_one_fleet_which_didnt_reach_target_point( Fleet $fleet1, Fleet $fleet2, ): void { - $userId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b"; + $playerId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b"; - $fleetRepository->findInJourneyForUser(new UserId($userId)) + $fleetRepository->findInJourneyForPlayer(new PlayerId($playerId)) ->willReturn([ $fleet1->getWrappedObject(), $fleet2->getWrappedObject(), @@ -80,7 +80,7 @@ public function it_skips_one_fleet_which_didnt_reach_target_point( $fleet1->tryToReachJourneyTargetPoint()->shouldBeCalledOnce(); $fleet1->didReachJourneyTargetPoint()->willReturn(true); $fleet1->getId()->willReturn(new FleetId("dfdd04c6-9243-4775-834c-ad702003ef6b")); - $fleet1->getJourneyMissionType()->willReturn(MissionType::Transport); + $fleet1->getJourneyMissionType()->willReturn(FleetMissionType::Transport); $fleet1->getJourneyTargetPoint()->willReturn(new GalaxyPoint(1, 2, 3)); $fleet1->getResourcesLoad()->willReturn([ "8de65203-ad4c-4ce7-bced-cfeda9107b5d" => 300, @@ -93,7 +93,7 @@ public function it_skips_one_fleet_which_didnt_reach_target_point( $eventBus->dispatch(Argument::type(FleetHasReachedJourneyTargetPointEvent::class)) ->shouldBeCalledOnce(); - $command = new TargetJourneysCommand($userId); + $command = new TargetJourneysCommand($playerId); $this->__invoke($command); } @@ -101,15 +101,15 @@ public function it_does_nothing_when_no_fleet_reaching_target_found( FleetRepositoryInterface $fleetRepository, EventBusInterface $eventBus, ): void { - $userId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b"; + $playerId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b"; - $fleetRepository->findInJourneyForUser(new UserId($userId)) + $fleetRepository->findInJourneyForPlayer(new PlayerId($playerId)) ->willReturn([]); $eventBus->dispatch(Argument::type(FleetHasReachedJourneyTargetPointEvent::class)) ->shouldNotBeCalled(); - $command = new TargetJourneysCommand($userId); + $command = new TargetJourneysCommand($playerId); $this->__invoke($command); } } diff --git a/spec/TheGame/Application/Component/FleetJourney/Domain/Entity/FleetSpec.php b/spec/TheGame/Application/Component/FleetJourney/Domain/Entity/FleetSpec.php index d5dfda8..724d59a 100644 --- a/spec/TheGame/Application/Component/FleetJourney/Domain/Entity/FleetSpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/Domain/Entity/FleetSpec.php @@ -14,12 +14,12 @@ use TheGame\Application\Component\FleetJourney\Domain\Exception\NotEnoughFleetLoadCapacityException; use TheGame\Application\Component\FleetJourney\Domain\Exception\NotEnoughShipsException; use TheGame\Application\Component\FleetJourney\Domain\FleetId; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\Component\FleetJourney\Domain\ShipsGroupInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\GalaxyPoint; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; use TheGame\Application\SharedKernel\Domain\ResourceAmount; -use TheGame\Application\SharedKernel\Domain\ResourceId; use TheGame\Application\SharedKernel\Domain\Resources; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; @@ -89,16 +89,16 @@ public function it_adds_ships_of_new_type( ]); $destroyerType = 'destroyer'; - $destroyerShipsGroup->getType() + $destroyerShipsGroup->getShipName() ->willReturn($destroyerType); - $destroyerShipsGroup->hasType($destroyerType) + $destroyerShipsGroup->hasShip($destroyerType) ->willReturn(true); - $lightFighterShipsGroup->hasType($destroyerType) + $lightFighterShipsGroup->hasShip($destroyerType) ->willReturn(false); - $warshipShipsGroup->hasType($destroyerType) + $warshipShipsGroup->hasShip($destroyerType) ->willReturn(false); $destroyerShipsGroup->hasEnoughShips(10) @@ -125,19 +125,19 @@ public function it_adds_ships_of_known_type( ]); $lightFighterType = 'light-fighter'; - $lightFightersToAdd->getType() + $lightFightersToAdd->getShipName() ->willReturn($lightFighterType); - $lightFightersToAdd->hasType($lightFighterType) + $lightFightersToAdd->hasShip($lightFighterType) ->willReturn(true); - $lightFighterShipsGroup->hasType($lightFighterType) + $lightFighterShipsGroup->hasShip($lightFighterType) ->willReturn(true); $lightFighterShipsGroup->merge($lightFightersToAdd) ->shouldBeCalledOnce(); - $warshipShipsGroup->hasType($lightFighterType) + $warshipShipsGroup->hasShip($lightFighterType) ->willReturn(false); $this->addShips([ @@ -187,8 +187,8 @@ public function it_has_enough_ships_comparing_two_groups_of_ships( ]); $lightFighterType = 'light-fighter'; - $lightFighterShipsGroup->hasType($lightFighterType)->willReturn(true); - $warshipShipsGroup->hasType($lightFighterType)->willReturn(false); + $lightFighterShipsGroup->hasShip($lightFighterType)->willReturn(true); + $warshipShipsGroup->hasShip($lightFighterType)->willReturn(false); $lightFighterShipsGroup->hasEnoughShips(15) ->willReturn(true); @@ -208,9 +208,9 @@ public function it_has_not_enough_ships_comparing_two_groups_of_ships( ]); $lightFighterType = 'light-fighter'; - $warshipShipsGroup->hasType($lightFighterType)->willReturn(false); + $warshipShipsGroup->hasShip($lightFighterType)->willReturn(false); - $lightFighterShipsGroup->hasType($lightFighterType)->willReturn(true); + $lightFighterShipsGroup->hasShip($lightFighterType)->willReturn(true); $lightFighterShipsGroup->hasEnoughShips(15) ->willReturn(false); @@ -227,7 +227,7 @@ public function it_has_not_enough_ships_when_ship_type_has_not_been_found( ]); $lightFighterType = 'light-fighter'; - $warshipShipsGroup->hasType($lightFighterType)->willReturn(false); + $warshipShipsGroup->hasShip($lightFighterType)->willReturn(false); $this->hasEnoughShips([ $lightFighterType => 15, @@ -268,9 +268,9 @@ public function it_hasnt_more_ships_than_input_when_there_is_not_enough_ships( ]); $lightFighterType = 'light-fighter'; - $warshipShipsGroup->hasType($lightFighterType)->willReturn(false); + $warshipShipsGroup->hasShip($lightFighterType)->willReturn(false); - $lightFighterShipsGroup->hasType($lightFighterType)->willReturn(true); + $lightFighterShipsGroup->hasShip($lightFighterType)->willReturn(true); $lightFighterShipsGroup->hasEnoughShips(15)->willReturn(true); $lightFighterShipsGroup->hasMoreShipsThan(15)->willReturn(false); @@ -290,14 +290,14 @@ public function it_has_more_ships_than_input_when_has_enough_of_all_ships_and_at $lightFighterType = 'light-fighter'; $warshipType = 'warship'; - $warshipShipsGroup->hasType($lightFighterType)->willReturn(false); - $warshipShipsGroup->hasType($warshipType)->willReturn(true); + $warshipShipsGroup->hasShip($lightFighterType)->willReturn(false); + $warshipShipsGroup->hasShip($warshipType)->willReturn(true); $warshipShipsGroup->hasEnoughShips(300)->willReturn(true); $warshipShipsGroup->hasMoreShipsThan(300)->willReturn(false); - $lightFighterShipsGroup->hasType($lightFighterType)->willReturn(true); - $lightFighterShipsGroup->hasType($warshipType)->willReturn(false); + $lightFighterShipsGroup->hasShip($lightFighterType)->willReturn(true); + $lightFighterShipsGroup->hasShip($warshipType)->willReturn(false); $lightFighterShipsGroup->hasEnoughShips(15)->willReturn(true); $lightFighterShipsGroup->hasMoreShipsThan(15)->willReturn(true); @@ -319,14 +319,14 @@ public function it_hasnt_more_ships_than_input_when_no_ship_group_has_more_ships $lightFighterType = 'light-fighter'; $warshipType = 'warship'; - $warshipShipsGroup->hasType($lightFighterType)->willReturn(false); - $warshipShipsGroup->hasType($warshipType)->willReturn(true); + $warshipShipsGroup->hasShip($lightFighterType)->willReturn(false); + $warshipShipsGroup->hasShip($warshipType)->willReturn(true); $warshipShipsGroup->hasEnoughShips(300)->willReturn(true); $warshipShipsGroup->hasMoreShipsThan(300)->willReturn(false); - $lightFighterShipsGroup->hasType($lightFighterType)->willReturn(true); - $lightFighterShipsGroup->hasType($warshipType)->willReturn(false); + $lightFighterShipsGroup->hasShip($lightFighterType)->willReturn(true); + $lightFighterShipsGroup->hasShip($warshipType)->willReturn(false); $lightFighterShipsGroup->hasEnoughShips(15)->willReturn(true); $lightFighterShipsGroup->hasMoreShipsThan(15)->willReturn(false); @@ -341,7 +341,7 @@ public function it_throws_exception_when_cannot_split_fleet_having_not_enough_sh ShipsGroupInterface $lightFighterShipsGroup, ): void { $lightFighterType = 'light-fighter'; - $lightFighterShipsGroup->hasType($lightFighterType)->willReturn(true); + $lightFighterShipsGroup->hasShip($lightFighterType)->willReturn(true); $lightFighterShipsGroup->hasEnoughShips(15)->willReturn(false); $this->shouldThrow(NotEnoughShipsException::class)->during('split', [ @@ -360,11 +360,11 @@ public function it_splits_ships( ]); $lightFighterType = 'light-fighter'; - $lightFighterShipsGroup->hasType($lightFighterType)->willReturn(true); + $lightFighterShipsGroup->hasShip($lightFighterType)->willReturn(true); $lightFighterShipsGroup->hasEnoughShips(15)->willReturn(true); $lightFighterShipsGroup->split(15)->willReturn($splitLightFighterShipsGroup); - $splitLightFighterShipsGroup->getType()->willReturn($lightFighterType); + $splitLightFighterShipsGroup->getShipName()->willReturn($lightFighterType); $splitLightFighterShipsGroup->getQuantity()->willReturn(15); $splitResult = $this->split([ @@ -373,7 +373,7 @@ public function it_splits_ships( $splitResult->shouldBeArray(); $splitResult->shouldHaveCount(1); $splitResult[0]->shouldImplement(ShipsGroupInterface::class); - $splitResult[0]->getType()->shouldReturn($lightFighterType); + $splitResult[0]->getShipName()->shouldReturn($lightFighterType); $splitResult[0]->getQuantity()->shouldReturn(15); } @@ -381,7 +381,7 @@ public function it_does_nothing_on_splitting_fleet_when_requested_quantity_is_ze ShipsGroupInterface $lightFighterShipsGroup, ): void { $lightFighterType = 'light-fighter'; - $lightFighterShipsGroup->hasType($lightFighterType)->willReturn(true); + $lightFighterShipsGroup->hasShip($lightFighterType)->willReturn(true); $this->shouldThrow(NotEnoughShipsException::class)->during('split', [ [ @@ -394,7 +394,7 @@ public function it_does_nothing_on_splitting_fleet_when_requested_quantity_is_le ShipsGroupInterface $lightFighterShipsGroup, ): void { $lightFighterType = 'light-fighter'; - $lightFighterShipsGroup->hasType($lightFighterType)->willReturn(true); + $lightFighterShipsGroup->hasShip($lightFighterType)->willReturn(true); $this->shouldThrow(NotEnoughShipsException::class)->during('split', [ [ @@ -416,16 +416,16 @@ public function it_omits_splitting_ships_group_when_requested_zero_ships_for_spl $lightFighterType = 'light-fighter'; $warshipType = 'warship'; - $warshipShipsGroup->hasType($lightFighterType)->willReturn(false); - $warshipShipsGroup->hasType($warshipType)->willReturn(true); + $warshipShipsGroup->hasShip($lightFighterType)->willReturn(false); + $warshipShipsGroup->hasShip($warshipType)->willReturn(true); $warshipShipsGroup->hasEnoughShips(0)->willReturn(true); - $lightFighterShipsGroup->hasType($warshipType)->willReturn(false); - $lightFighterShipsGroup->hasType($lightFighterType)->willReturn(true); + $lightFighterShipsGroup->hasShip($warshipType)->willReturn(false); + $lightFighterShipsGroup->hasShip($lightFighterType)->willReturn(true); $lightFighterShipsGroup->hasEnoughShips(15)->willReturn(true); $lightFighterShipsGroup->split(15)->willReturn($splitLightFighterShipsGroup); - $splitLightFighterShipsGroup->getType()->willReturn($lightFighterType); + $splitLightFighterShipsGroup->getShipName()->willReturn($lightFighterType); $splitLightFighterShipsGroup->getQuantity()->willReturn(15); $splitResult = $this->split([ @@ -435,7 +435,7 @@ public function it_omits_splitting_ships_group_when_requested_zero_ships_for_spl $splitResult->shouldBeArray(); $splitResult->shouldHaveCount(1); $splitResult[0]->shouldImplement(ShipsGroupInterface::class); - $splitResult[0]->getType()->shouldReturn($lightFighterType); + $splitResult[0]->getShipName()->shouldReturn($lightFighterType); $splitResult[0]->getQuantity()->shouldReturn(15); } @@ -507,9 +507,9 @@ public function it_returns_journey_mission_type( $journey->didReachTargetPoint()->willReturn(false); $journey->didReachReturnPoint()->willReturn(false); - $journey->getMissionType()->willReturn(MissionType::Transport); + $journey->getMissionType()->willReturn(FleetMissionType::Transport); - $this->getJourneyMissionType()->shouldReturn(MissionType::Transport); + $this->getJourneyMissionType()->shouldReturn(FleetMissionType::Transport); } public function it_throws_exception_on_returning_journey_start_point_not_being_in_journey(): void diff --git a/spec/TheGame/Application/Component/FleetJourney/Domain/Entity/JourneySpec.php b/spec/TheGame/Application/Component/FleetJourney/Domain/Entity/JourneySpec.php index a6d86eb..2d96e2f 100644 --- a/spec/TheGame/Application/Component/FleetJourney/Domain/Entity/JourneySpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/Domain/Entity/JourneySpec.php @@ -15,17 +15,17 @@ use TheGame\Application\Component\FleetJourney\Domain\Exception\FleetOnFlyBackException; use TheGame\Application\Component\FleetJourney\Domain\FleetId; use TheGame\Application\Component\FleetJourney\Domain\JourneyId; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\SharedKernel\Domain\GalaxyPoint; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; final class JourneySpec extends ObjectBehavior { public function let(): void { - $this->initialize(MissionType::Transport, 50); + $this->initialize(FleetMissionType::Transport, 50); } - private function initialize(MissionType $missionType, int $duration): void + private function initialize(FleetMissionType $missionType, int $duration): void { $journeyId = "35f6e0a6-e9bb-4344-b1f1-299cbaeb1f25"; $fleetId = "282294b8-ba92-46d1-b86a-4768e2a664b9"; @@ -49,7 +49,7 @@ public function it_has_identifier(): void public function it_has_mission_type(): void { - $this->getMissionType()->shouldReturn(MissionType::Transport); + $this->getMissionType()->shouldReturn(FleetMissionType::Transport); } public function it_has_start_point(): void @@ -99,7 +99,7 @@ public function it_knows_the_default_value_of_real_time_for_reaching_the_return_ public function it_does_plan_to_station_on_the_target_point(): void { - $this->initialize(MissionType::Stationing, 50); + $this->initialize(FleetMissionType::Stationing, 50); $this->doesPlanToStationOnTarget()->shouldReturn(true); } @@ -111,7 +111,7 @@ public function it_doesnt_plan_to_station_on_the_target_point(): void public function it_does_attack(): void { - $this->initialize(MissionType::Attack, 50); + $this->initialize(FleetMissionType::Attack, 50); $this->doesAttack()->shouldReturn(true); } @@ -128,7 +128,7 @@ public function it_does_transport_resources(): void public function it_doesnt_transport_resources(): void { - $this->initialize(MissionType::Attack, 50); + $this->initialize(FleetMissionType::Attack, 50); $this->doesTransportResources()->shouldReturn(false); } @@ -140,7 +140,7 @@ public function it_doesnt_do_flyback_by_default(): void public function it_does_flyback_after_reaching_target_point(): void { - $this->initialize(MissionType::Transport, 0); + $this->initialize(FleetMissionType::Transport, 0); $this->reachTargetPoint(); $this->doesFlyBack()->shouldReturn(true); @@ -148,7 +148,7 @@ public function it_does_flyback_after_reaching_target_point(): void public function it_does_not_flyback_after_reaching_return_point(): void { - $this->initialize(MissionType::Transport, 0); + $this->initialize(FleetMissionType::Transport, 0); $this->reachTargetPoint(); $this->reachReturnPoint(); @@ -163,7 +163,7 @@ public function it_does_not_flyback_after_cancelling_journey(): void public function it_did_reach_target_point(): void { - $this->initialize(MissionType::Transport, 0); + $this->initialize(FleetMissionType::Transport, 0); $this->didReachTargetPoint()->shouldReturn(true); } @@ -175,7 +175,7 @@ public function it_didnt_reach_target_point_yet(): void public function it_throws_exception_when_cant_reach_target_point_on_flyback(): void { - $this->initialize(MissionType::Transport, 0); + $this->initialize(FleetMissionType::Transport, 0); $this->reachTargetPoint(); $this->shouldThrow(FleetOnFlyBackException::class) @@ -190,7 +190,7 @@ public function it_throws_exception_when_reaching_target_point_but_flying_time_d public function it_reaches_target_point_and_station_on_planet(): void { - $this->initialize(MissionType::Stationing, 0); + $this->initialize(FleetMissionType::Stationing, 0); $this->reachTargetPoint(); $now = new DateTimeImmutable(); @@ -200,7 +200,7 @@ public function it_reaches_target_point_and_station_on_planet(): void public function it_reaches_target_point_and_turns_around(): void { - $this->initialize(MissionType::Transport, 0); + $this->initialize(FleetMissionType::Transport, 0); $this->reachTargetPoint(); $this->doesFlyBack()->shouldReturn(true); @@ -208,7 +208,7 @@ public function it_reaches_target_point_and_turns_around(): void public function it_did_reach_return_point(): void { - $this->initialize(MissionType::Transport, 0); + $this->initialize(FleetMissionType::Transport, 0); $this->didReachReturnPoint()->shouldReturn(true); } @@ -248,7 +248,7 @@ public function it_is_not_cancelled(): void public function it_throws_exception_when_cancelling_fleet_on_flyback(): void { - $this->initialize(MissionType::Transport, 0); + $this->initialize(FleetMissionType::Transport, 0); $this->reachTargetPoint(); $this->shouldThrow(CannotCancelFleetJourneyOnFlyBackException::class) @@ -257,7 +257,7 @@ public function it_throws_exception_when_cancelling_fleet_on_flyback(): void public function it_throws_exception_when_cancelling_fleet_which_did_reach_target_point(): void { - $this->initialize(MissionType::Transport, 0); + $this->initialize(FleetMissionType::Transport, 0); $this->shouldThrow(CannotCancelFleetJourneyOnReachingTargetPointException::class) ->during('cancel', []); diff --git a/spec/TheGame/Application/Component/FleetJourney/Domain/Factory/FleetFactorySpec.php b/spec/TheGame/Application/Component/FleetJourney/Domain/Factory/FleetFactorySpec.php index 9ecc71c..506b31d 100644 --- a/spec/TheGame/Application/Component/FleetJourney/Domain/Factory/FleetFactorySpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/Domain/Factory/FleetFactorySpec.php @@ -8,9 +8,9 @@ use TheGame\Application\Component\FleetJourney\Domain\Entity\Fleet; use TheGame\Application\Component\FleetJourney\Domain\FleetId; use TheGame\Application\Component\FleetJourney\Domain\ShipsGroup; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\GalaxyPoint; use TheGame\Application\SharedKernel\Domain\ResourceAmount; -use TheGame\Application\SharedKernel\Domain\ResourceId; use TheGame\Application\SharedKernel\Domain\Resources; use TheGame\Application\SharedKernel\UuidGeneratorInterface; diff --git a/spec/TheGame/Application/Component/FleetJourney/Domain/Factory/JourneyFactorySpec.php b/spec/TheGame/Application/Component/FleetJourney/Domain/Factory/JourneyFactorySpec.php index 32fe717..dabc7bb 100644 --- a/spec/TheGame/Application/Component/FleetJourney/Domain/Factory/JourneyFactorySpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/Domain/Factory/JourneyFactorySpec.php @@ -9,8 +9,8 @@ use TheGame\Application\Component\FleetJourney\Domain\Entity\Journey; use TheGame\Application\Component\FleetJourney\Domain\FleetId; use TheGame\Application\Component\FleetJourney\Domain\JourneyId; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\SharedKernel\Domain\GalaxyPoint; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; use TheGame\Application\SharedKernel\UuidGeneratorInterface; final class JourneyFactorySpec extends ObjectBehavior @@ -34,7 +34,7 @@ public function it_creates_journey( $createdJourney = $this->createJourney( $fleetId, - MissionType::Transport, + FleetMissionType::Transport, $startGalaxyPoint, $targetGalaxyPoint, $journeyDuration, diff --git a/spec/TheGame/Application/Component/FleetJourney/Domain/ShipsGroupSpec.php b/spec/TheGame/Application/Component/FleetJourney/Domain/ShipsGroupSpec.php index e936abb..e9159a1 100644 --- a/spec/TheGame/Application/Component/FleetJourney/Domain/ShipsGroupSpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/Domain/ShipsGroupSpec.php @@ -5,7 +5,7 @@ namespace spec\TheGame\Application\Component\FleetJourney\Domain; use PhpSpec\ObjectBehavior; -use TheGame\Application\Component\FleetJourney\Domain\Exception\CannotMergeShipGroupsOfDifferentTypeException; +use TheGame\Application\Component\FleetJourney\Domain\Exception\CannotMergeShipGroupsOfDifferentShips; use TheGame\Application\Component\FleetJourney\Domain\Exception\NotEnoughShipsException; use TheGame\Application\Component\FleetJourney\Domain\ShipsGroupInterface; @@ -23,7 +23,7 @@ public function let(): void public function it_has_type(): void { - $this->getType()->shouldReturn("light-fighter"); + $this->getShipName()->shouldReturn("light-fighter"); } public function it_has_quantity(): void @@ -33,12 +33,12 @@ public function it_has_quantity(): void public function it_checks_the_correct_type(): void { - $this->hasType("light-fighter")->shouldReturn(true); + $this->hasShip("light-fighter")->shouldReturn(true); } public function it_checks_the_incorrect_type(): void { - $this->hasType("warship")->shouldReturn(false); + $this->hasShip("warship")->shouldReturn(false); } public function it_checks_whether_has_more_ships_than_quantity(): void @@ -64,7 +64,7 @@ public function it_checks_whether_has_enough_ships_but_has_not(): void public function it_merges_ships( ShipsGroupInterface $shipsGroup, ): void { - $shipsGroup->getType()->willReturn('light-fighter'); + $shipsGroup->getShipName()->willReturn('light-fighter'); $shipsGroup->getQuantity()->willReturn(15); $shipsGroup->setEmpty()->shouldBeCalledOnce(); @@ -75,15 +75,15 @@ public function it_merges_ships( public function it_throws_exception_on_merging_ships_of_unsupported_type( ShipsGroupInterface $shipsGroup, ): void { - $shipsGroup->getType()->willReturn('warship'); + $shipsGroup->getShipName()->willReturn('warship'); - $this->shouldThrow(CannotMergeShipGroupsOfDifferentTypeException::class)->during('merge', [$shipsGroup]); + $this->shouldThrow(CannotMergeShipGroupsOfDifferentShips::class)->during('merge', [$shipsGroup]); } public function it_splits_into_second_group(): void { $secondGroup = $this->split(5); - $secondGroup->getType()->shouldReturn('light-fighter'); + $secondGroup->getShipName()->shouldReturn('light-fighter'); $secondGroup->getQuantity()->shouldReturn(5); $secondGroup->getSpeed()->shouldReturn(35); $secondGroup->getUnitLoadCapacity()->shouldReturn(20); diff --git a/spec/TheGame/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListenerSpec.php b/spec/TheGame/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListenerSpec.php index 6f429df..1d0d1e3 100644 --- a/spec/TheGame/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListenerSpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListenerSpec.php @@ -12,8 +12,8 @@ use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface; use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface; use TheGame\Application\Component\Shipyard\Domain\Event\NewShipsHaveBeenConstructedEvent; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; use TheGame\Application\SharedKernel\Domain\Resources; final class AddNewlyConstructedShipsToFleetEventListenerSpec extends ObjectBehavior @@ -71,7 +71,7 @@ public function it_creates_a_fleet_and_adds_group_of_ships_to_them( $fleetRepository->findStationingOnPlanet(new PlanetId($planetId)) ->willReturn(null); - $navigator->getPlanetPoint(new PlanetId($planetId)) + $navigator->getPlanetPosition(new PlanetId($planetId)) ->willReturn($planetGalaxyPoint); $fleetFactory->create( diff --git a/spec/TheGame/Application/Component/FleetJourney/EventListener/StationFleetOnReachingTargetPointEventListenerSpec.php b/spec/TheGame/Application/Component/FleetJourney/EventListener/StationFleetOnReachingTargetPointEventListenerSpec.php index cfe7d65..861cb0a 100644 --- a/spec/TheGame/Application/Component/FleetJourney/EventListener/StationFleetOnReachingTargetPointEventListenerSpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/EventListener/StationFleetOnReachingTargetPointEventListenerSpec.php @@ -10,8 +10,8 @@ use TheGame\Application\Component\FleetJourney\Domain\FleetId; use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface; use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\GalaxyPoint; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; final class StationFleetOnReachingTargetPointEventListenerSpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/FleetJourney/FleetResolverSpec.php b/spec/TheGame/Application/Component/FleetJourney/FleetResolverSpec.php index 36c0bc2..a087e7e 100644 --- a/spec/TheGame/Application/Component/FleetJourney/FleetResolverSpec.php +++ b/spec/TheGame/Application/Component/FleetJourney/FleetResolverSpec.php @@ -16,8 +16,8 @@ use TheGame\Application\Component\FleetJourney\Domain\ShipsGroupInterface; use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface; use TheGame\Application\Component\ResourceStorage\Bridge\ResourceAvailabilityCheckerInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; final class FleetResolverSpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/ResourceMines/CommandHandler/ExtractResourcesCommandHandlerSpec.php b/spec/TheGame/Application/Component/ResourceMines/CommandHandler/ExtractResourcesCommandHandlerSpec.php index 7104766..d970041 100644 --- a/spec/TheGame/Application/Component/ResourceMines/CommandHandler/ExtractResourcesCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/ResourceMines/CommandHandler/ExtractResourcesCommandHandlerSpec.php @@ -10,9 +10,9 @@ use TheGame\Application\Component\ResourceMines\Domain\Entity\MinesCollection; use TheGame\Application\Component\ResourceMines\Domain\Event\ResourceHasBeenExtractedEvent; use TheGame\Application\Component\ResourceMines\ResourceMinesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmountInterface; -use TheGame\Application\SharedKernel\Domain\ResourceId; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/spec/TheGame/Application/Component/ResourceMines/Domain/Entity/MineSpec.php b/spec/TheGame/Application/Component/ResourceMines/Domain/Entity/MineSpec.php index 40ff5b8..b80f18c 100644 --- a/spec/TheGame/Application/Component/ResourceMines/Domain/Entity/MineSpec.php +++ b/spec/TheGame/Application/Component/ResourceMines/Domain/Entity/MineSpec.php @@ -8,8 +8,8 @@ use PhpSpec\ObjectBehavior; use TheGame\Application\Component\ResourceMines\Domain\MineId; use TheGame\Application\Component\ResourceMines\Domain\MineIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmount; -use TheGame\Application\SharedKernel\Domain\ResourceId; final class MineSpec extends ObjectBehavior { diff --git a/spec/TheGame/Application/Component/ResourceMines/Domain/Entity/MinesCollectionSpec.php b/spec/TheGame/Application/Component/ResourceMines/Domain/Entity/MinesCollectionSpec.php index 0b8be33..1f5e22f 100644 --- a/spec/TheGame/Application/Component/ResourceMines/Domain/Entity/MinesCollectionSpec.php +++ b/spec/TheGame/Application/Component/ResourceMines/Domain/Entity/MinesCollectionSpec.php @@ -8,9 +8,9 @@ use TheGame\Application\Component\ResourceMines\Domain\Entity\Mine; use TheGame\Application\Component\ResourceMines\Domain\Exception\CannotUpgradeMiningSpeedForUnsupportedResourceException; use TheGame\Application\Component\ResourceMines\Domain\MinesCollectionId; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmountInterface; -use TheGame\Application\SharedKernel\Domain\ResourceId; final class MinesCollectionSpec extends ObjectBehavior { diff --git a/spec/TheGame/Application/Component/ResourceMines/Domain/Factory/MineFactorySpec.php b/spec/TheGame/Application/Component/ResourceMines/Domain/Factory/MineFactorySpec.php index 753141d..5762daa 100644 --- a/spec/TheGame/Application/Component/ResourceMines/Domain/Factory/MineFactorySpec.php +++ b/spec/TheGame/Application/Component/ResourceMines/Domain/Factory/MineFactorySpec.php @@ -8,7 +8,7 @@ use TheGame\Application\Component\Balance\Bridge\ResourceMinesContextInterface; use TheGame\Application\Component\ResourceMines\Domain\Entity\Mine; use TheGame\Application\Component\ResourceMines\Domain\MineIdInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; use TheGame\Application\SharedKernel\UuidGeneratorInterface; final class MineFactorySpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/ResourceMines/EventListener/UpgradeMineEventListenerSpec.php b/spec/TheGame/Application/Component/ResourceMines/EventListener/UpgradeMineEventListenerSpec.php index 24409a4..7090591 100644 --- a/spec/TheGame/Application/Component/ResourceMines/EventListener/UpgradeMineEventListenerSpec.php +++ b/spec/TheGame/Application/Component/ResourceMines/EventListener/UpgradeMineEventListenerSpec.php @@ -11,8 +11,8 @@ use TheGame\Application\Component\ResourceMines\Domain\Entity\MinesCollection; use TheGame\Application\Component\ResourceMines\Domain\Factory\MineFactoryInterface; use TheGame\Application\Component\ResourceMines\ResourceMinesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; -use TheGame\Application\SharedKernel\Domain\ResourceId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; final class UpgradeMineEventListenerSpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityCheckerSpec.php b/spec/TheGame/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityCheckerSpec.php index 8a77704..bdb5294 100644 --- a/spec/TheGame/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityCheckerSpec.php +++ b/spec/TheGame/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityCheckerSpec.php @@ -7,9 +7,9 @@ use PhpSpec\ObjectBehavior; use TheGame\Application\Component\ResourceStorage\Domain\Entity\StoragesCollection; use TheGame\Application\Component\ResourceStorage\ResourceStoragesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmount; -use TheGame\Application\SharedKernel\Domain\ResourceId; use TheGame\Application\SharedKernel\Domain\Resources; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/spec/TheGame/Application/Component/ResourceStorage/CommandHandler/DispatchResourcesCommandHandlerSpec.php b/spec/TheGame/Application/Component/ResourceStorage/CommandHandler/DispatchResourcesCommandHandlerSpec.php index 27b7799..35ac2d8 100644 --- a/spec/TheGame/Application/Component/ResourceStorage/CommandHandler/DispatchResourcesCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/ResourceStorage/CommandHandler/DispatchResourcesCommandHandlerSpec.php @@ -13,9 +13,9 @@ use TheGame\Application\Component\ResourceStorage\Domain\Event\StorageAmountHasChangedEvent; use TheGame\Application\Component\ResourceStorage\Domain\Factory\StorageFactoryInterface; use TheGame\Application\Component\ResourceStorage\ResourceStoragesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmount; -use TheGame\Application\SharedKernel\Domain\ResourceId; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/spec/TheGame/Application/Component/ResourceStorage/CommandHandler/UseResourceCommandHandlerSpec.php b/spec/TheGame/Application/Component/ResourceStorage/CommandHandler/UseResourceCommandHandlerSpec.php index 99b10e1..fc35f3c 100644 --- a/spec/TheGame/Application/Component/ResourceStorage/CommandHandler/UseResourceCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/ResourceStorage/CommandHandler/UseResourceCommandHandlerSpec.php @@ -11,9 +11,9 @@ use TheGame\Application\Component\ResourceStorage\Domain\Event\StorageAmountHasChangedEvent; use TheGame\Application\Component\ResourceStorage\Domain\Exception\InsufficientResourcesException; use TheGame\Application\Component\ResourceStorage\ResourceStoragesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmount; -use TheGame\Application\SharedKernel\Domain\ResourceId; use TheGame\Application\SharedKernel\Domain\Resources; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/spec/TheGame/Application/Component/ResourceStorage/Domain/Entity/StorageSpec.php b/spec/TheGame/Application/Component/ResourceStorage/Domain/Entity/StorageSpec.php index 0a0f8ba..3ddf932 100644 --- a/spec/TheGame/Application/Component/ResourceStorage/Domain/Entity/StorageSpec.php +++ b/spec/TheGame/Application/Component/ResourceStorage/Domain/Entity/StorageSpec.php @@ -9,8 +9,8 @@ use TheGame\Application\Component\ResourceStorage\Domain\Exception\CannotUseUnsupportedResourceException; use TheGame\Application\Component\ResourceStorage\Domain\Exception\InsufficientResourcesException; use TheGame\Application\Component\ResourceStorage\Domain\StorageId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmountInterface; -use TheGame\Application\SharedKernel\Domain\ResourceId; final class StorageSpec extends ObjectBehavior { diff --git a/spec/TheGame/Application/Component/ResourceStorage/Domain/Entity/StoragesCollectionSpec.php b/spec/TheGame/Application/Component/ResourceStorage/Domain/Entity/StoragesCollectionSpec.php index 9ceb551..099a451 100644 --- a/spec/TheGame/Application/Component/ResourceStorage/Domain/Entity/StoragesCollectionSpec.php +++ b/spec/TheGame/Application/Component/ResourceStorage/Domain/Entity/StoragesCollectionSpec.php @@ -12,9 +12,9 @@ use TheGame\Application\Component\ResourceStorage\Domain\Exception\InsufficientResourcesException; use TheGame\Application\Component\ResourceStorage\Domain\StorageCollectionId; use TheGame\Application\Component\ResourceStorage\Domain\StorageId; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmountInterface; -use TheGame\Application\SharedKernel\Domain\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; final class StoragesCollectionSpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/ResourceStorage/Domain/Factory/StorageFactorySpec.php b/spec/TheGame/Application/Component/ResourceStorage/Domain/Factory/StorageFactorySpec.php index dc23537..a6e767e 100644 --- a/spec/TheGame/Application/Component/ResourceStorage/Domain/Factory/StorageFactorySpec.php +++ b/spec/TheGame/Application/Component/ResourceStorage/Domain/Factory/StorageFactorySpec.php @@ -7,7 +7,7 @@ use PhpSpec\ObjectBehavior; use TheGame\Application\Component\ResourceStorage\Domain\Entity\Storage; use TheGame\Application\Component\ResourceStorage\Domain\StorageIdInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; use TheGame\Application\SharedKernel\UuidGeneratorInterface; final class StorageFactorySpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyReturnPointEventListenerSpec.php b/spec/TheGame/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyReturnPointEventListenerSpec.php index cf47baa..305f60e 100644 --- a/spec/TheGame/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyReturnPointEventListenerSpec.php +++ b/spec/TheGame/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyReturnPointEventListenerSpec.php @@ -10,8 +10,8 @@ use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface; use TheGame\Application\Component\ResourceStorage\Command\DispatchResourcesCommand; use TheGame\Application\SharedKernel\CommandBusInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; final class UnloadResourcesAfterReachingJourneyReturnPointEventListenerSpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyTargetPointEventListenerSpec.php b/spec/TheGame/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyTargetPointEventListenerSpec.php index 191846f..fe405c3 100644 --- a/spec/TheGame/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyTargetPointEventListenerSpec.php +++ b/spec/TheGame/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyTargetPointEventListenerSpec.php @@ -7,12 +7,12 @@ use PhpSpec\ObjectBehavior; use Prophecy\Argument; use TheGame\Application\Component\FleetJourney\Domain\Event\FleetHasReachedJourneyTargetPointEvent; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface; use TheGame\Application\Component\ResourceStorage\Command\DispatchResourcesCommand; use TheGame\Application\SharedKernel\CommandBusInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; final class UnloadResourcesAfterReachingJourneyTargetPointEventListenerSpec extends ObjectBehavior @@ -48,7 +48,7 @@ public function it_dispatches_resources_from_fleet_transporting_and_reaching_tar ->shouldBeCalledTimes(2); $event = new FleetHasReachedJourneyTargetPointEvent( - MissionType::Transport->value, + FleetMissionType::Transport->value, $fleetId, $targetCoordinates, $resourcesLoad @@ -77,7 +77,7 @@ public function it_dispatches_resources_from_fleet_stationing_and_reaching_targe ->shouldBeCalledTimes(2); $event = new FleetHasReachedJourneyTargetPointEvent( - MissionType::Stationing->value, + FleetMissionType::Stationing->value, $fleetId, $targetCoordinates, $resourcesLoad @@ -95,7 +95,7 @@ public function it_does_nothing_when_mission_is_attack(): void ]; $event = new FleetHasReachedJourneyTargetPointEvent( - MissionType::Attack->value, + FleetMissionType::Attack->value, $fleetId, $targetCoordinates, $resourcesLoad @@ -116,7 +116,7 @@ public function it_throws_exception_when_dispatching_resources_on_non_existing_p ->willReturn(null); $event = new FleetHasReachedJourneyTargetPointEvent( - MissionType::Transport->value, + FleetMissionType::Transport->value, $fleetId, $targetCoordinates, $resourcesLoad diff --git a/spec/TheGame/Application/Component/ResourceStorage/EventListener/UpgradeStorageEventListenerSpec.php b/spec/TheGame/Application/Component/ResourceStorage/EventListener/UpgradeStorageEventListenerSpec.php index 70904d4..dd49809 100644 --- a/spec/TheGame/Application/Component/ResourceStorage/EventListener/UpgradeStorageEventListenerSpec.php +++ b/spec/TheGame/Application/Component/ResourceStorage/EventListener/UpgradeStorageEventListenerSpec.php @@ -11,8 +11,8 @@ use TheGame\Application\Component\ResourceStorage\Domain\Entity\StoragesCollection; use TheGame\Application\Component\ResourceStorage\Domain\Factory\StorageFactoryInterface; use TheGame\Application\Component\ResourceStorage\ResourceStoragesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; -use TheGame\Application\SharedKernel\Domain\ResourceId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; final class UpgradeStorageEventListenerSpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/Shipyard/CommandHandler/CancelJobCommandHandlerSpec.php b/spec/TheGame/Application/Component/Shipyard/CommandHandler/CancelJobCommandHandlerSpec.php index 63a1121..8fcf241 100644 --- a/spec/TheGame/Application/Component/Shipyard/CommandHandler/CancelJobCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/Shipyard/CommandHandler/CancelJobCommandHandlerSpec.php @@ -13,7 +13,7 @@ use TheGame\Application\Component\Shipyard\Domain\ShipyardId; use TheGame\Application\Component\Shipyard\Exception\ShipyardHasNotBeenFoundException; use TheGame\Application\Component\Shipyard\ShipyardRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; use TheGame\Application\SharedKernel\EventBusInterface; diff --git a/spec/TheGame/Application/Component/Shipyard/CommandHandler/ConstructCannonsCommandHandlerSpec.php b/spec/TheGame/Application/Component/Shipyard/CommandHandler/ConstructCannonsCommandHandlerSpec.php index 3b4597a..9716256 100644 --- a/spec/TheGame/Application/Component/Shipyard/CommandHandler/ConstructCannonsCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/Shipyard/CommandHandler/ConstructCannonsCommandHandlerSpec.php @@ -17,7 +17,7 @@ use TheGame\Application\Component\Shipyard\Domain\ShipyardId; use TheGame\Application\Component\Shipyard\Exception\ShipyardHasNotBeenFoundException; use TheGame\Application\Component\Shipyard\ShipyardRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; use TheGame\Application\SharedKernel\EventBusInterface; diff --git a/spec/TheGame/Application/Component/Shipyard/CommandHandler/ConstructShipsCommandHandlerSpec.php b/spec/TheGame/Application/Component/Shipyard/CommandHandler/ConstructShipsCommandHandlerSpec.php index fa626e1..ebb90e5 100644 --- a/spec/TheGame/Application/Component/Shipyard/CommandHandler/ConstructShipsCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/Shipyard/CommandHandler/ConstructShipsCommandHandlerSpec.php @@ -17,7 +17,7 @@ use TheGame\Application\Component\Shipyard\Domain\ShipyardId; use TheGame\Application\Component\Shipyard\Exception\ShipyardHasNotBeenFoundException; use TheGame\Application\Component\Shipyard\ShipyardRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; use TheGame\Application\SharedKernel\EventBusInterface; diff --git a/spec/TheGame/Application/Component/Shipyard/CommandHandler/FinishJobsCommandHandlerSpec.php b/spec/TheGame/Application/Component/Shipyard/CommandHandler/FinishJobsCommandHandlerSpec.php index 580ff10..9d50b43 100644 --- a/spec/TheGame/Application/Component/Shipyard/CommandHandler/FinishJobsCommandHandlerSpec.php +++ b/spec/TheGame/Application/Component/Shipyard/CommandHandler/FinishJobsCommandHandlerSpec.php @@ -15,7 +15,7 @@ use TheGame\Application\Component\Shipyard\Domain\ShipyardId; use TheGame\Application\Component\Shipyard\Exception\ShipyardHasNotBeenFoundException; use TheGame\Application\Component\Shipyard\ShipyardRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\EventBusInterface; final class FinishJobsCommandHandlerSpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/Shipyard/Domain/Entity/JobSpec.php b/spec/TheGame/Application/Component/Shipyard/Domain/Entity/JobSpec.php index b930078..049fb3a 100644 --- a/spec/TheGame/Application/Component/Shipyard/Domain/Entity/JobSpec.php +++ b/spec/TheGame/Application/Component/Shipyard/Domain/Entity/JobSpec.php @@ -8,8 +8,8 @@ use TheGame\Application\Component\Shipyard\Domain\ConstructibleUnit; use TheGame\Application\Component\Shipyard\Domain\JobId; use TheGame\Application\Component\Shipyard\Domain\ValueObject\Ship; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmount; -use TheGame\Application\SharedKernel\Domain\ResourceId; use TheGame\Application\SharedKernel\Domain\Resources; final class JobSpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/Shipyard/Domain/Entity/ShipyardSpec.php b/spec/TheGame/Application/Component/Shipyard/Domain/Entity/ShipyardSpec.php index ee7c616..6a0422f 100644 --- a/spec/TheGame/Application/Component/Shipyard/Domain/Entity/ShipyardSpec.php +++ b/spec/TheGame/Application/Component/Shipyard/Domain/Entity/ShipyardSpec.php @@ -14,7 +14,7 @@ use TheGame\Application\Component\Shipyard\Domain\Exception\ShipyardJobNotFoundException; use TheGame\Application\Component\Shipyard\Domain\JobIdInterface; use TheGame\Application\Component\Shipyard\Domain\ShipyardId; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; final class ShipyardSpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactorySpec.php b/spec/TheGame/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactorySpec.php index 589ba70..5a59a76 100644 --- a/spec/TheGame/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactorySpec.php +++ b/spec/TheGame/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactorySpec.php @@ -10,7 +10,7 @@ use TheGame\Application\Component\Shipyard\Domain\Event\NewCannonsHaveBeenConstructedEvent; use TheGame\Application\Component\Shipyard\Domain\Event\NewShipsHaveBeenConstructedEvent; use TheGame\Application\Component\Shipyard\Domain\FinishedJobsSummaryEntryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; final class FinishedConstructionEventFactorySpec extends ObjectBehavior { diff --git a/spec/TheGame/Application/Component/Shipyard/Domain/Event/NewShipsHaveBeenConstructedEventSpec.php b/spec/TheGame/Application/Component/Shipyard/Domain/Event/NewShipsHaveBeenConstructedEventSpec.php index d7b93c6..e533fc3 100644 --- a/spec/TheGame/Application/Component/Shipyard/Domain/Event/NewShipsHaveBeenConstructedEventSpec.php +++ b/spec/TheGame/Application/Component/Shipyard/Domain/Event/NewShipsHaveBeenConstructedEventSpec.php @@ -24,7 +24,7 @@ public function it_has_planet_id(): void public function it_has_ship_type(): void { - $this->getType() + $this->getName() ->shouldReturn('light-fighter'); } diff --git a/spec/TheGame/Application/Component/Shipyard/Domain/Factory/ShipyardFactorySpec.php b/spec/TheGame/Application/Component/Shipyard/Domain/Factory/ShipyardFactorySpec.php index b88f627..155e07f 100644 --- a/spec/TheGame/Application/Component/Shipyard/Domain/Factory/ShipyardFactorySpec.php +++ b/spec/TheGame/Application/Component/Shipyard/Domain/Factory/ShipyardFactorySpec.php @@ -7,7 +7,7 @@ use PhpSpec\ObjectBehavior; use TheGame\Application\Component\BuildingConstruction\Domain\BuildingId; use TheGame\Application\Component\Shipyard\Domain\ShipyardId; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\UuidGeneratorInterface; final class ShipyardFactorySpec extends ObjectBehavior diff --git a/spec/TheGame/Application/Component/Shipyard/EventListener/UpgradeShipyardEventListenerSpec.php b/spec/TheGame/Application/Component/Shipyard/EventListener/UpgradeShipyardEventListenerSpec.php index a48fdb7..f4cfcb2 100644 --- a/spec/TheGame/Application/Component/Shipyard/EventListener/UpgradeShipyardEventListenerSpec.php +++ b/spec/TheGame/Application/Component/Shipyard/EventListener/UpgradeShipyardEventListenerSpec.php @@ -12,7 +12,7 @@ use TheGame\Application\Component\Shipyard\Domain\Factory\ShipyardFactoryInterface; use TheGame\Application\Component\Shipyard\Exception\ShipyardHasNotBeenFoundException; use TheGame\Application\Component\Shipyard\ShipyardRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; final class UpgradeShipyardEventListenerSpec extends ObjectBehavior { diff --git a/spec/TheGame/Application/SharedKernel/Domain/ResourceAmountSpec.php b/spec/TheGame/Application/SharedKernel/Domain/ResourceAmountSpec.php index 5143896..3027cd1 100644 --- a/spec/TheGame/Application/SharedKernel/Domain/ResourceAmountSpec.php +++ b/spec/TheGame/Application/SharedKernel/Domain/ResourceAmountSpec.php @@ -5,9 +5,9 @@ namespace spec\TheGame\Application\SharedKernel\Domain; use PhpSpec\ObjectBehavior; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\Exception\InvalidResourceAmountException; use TheGame\Application\SharedKernel\Domain\ResourceAmountInterface; -use TheGame\Application\SharedKernel\Domain\ResourceId; final class ResourceAmountSpec extends ObjectBehavior { diff --git a/spec/TheGame/Application/SharedKernel/Domain/ResourcesSpec.php b/spec/TheGame/Application/SharedKernel/Domain/ResourcesSpec.php index 97ec2b1..c71d828 100644 --- a/spec/TheGame/Application/SharedKernel/Domain/ResourcesSpec.php +++ b/spec/TheGame/Application/SharedKernel/Domain/ResourcesSpec.php @@ -5,8 +5,8 @@ namespace spec\TheGame\Application\SharedKernel\Domain; use PhpSpec\ObjectBehavior; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmount; -use TheGame\Application\SharedKernel\Domain\ResourceId; final class ResourcesSpec extends ObjectBehavior { diff --git a/src/Application/Component/Balance/Bridge/FleetJourneyContextInterface.php b/src/Application/Component/Balance/Bridge/FleetJourneyContextInterface.php index 73c6909..2bf8717 100644 --- a/src/Application/Component/Balance/Bridge/FleetJourneyContextInterface.php +++ b/src/Application/Component/Balance/Bridge/FleetJourneyContextInterface.php @@ -9,9 +9,9 @@ interface FleetJourneyContextInterface { - public function getShipBaseSpeed(string $shipType): int; + public function getShipBaseSpeed(string $shipName): int; - public function getShipLoadCapacity(string $type): int; + public function getShipLoadCapacity(string $shipName): int; public function calculateJourneyDuration( int $speed, diff --git a/src/Application/Component/Balance/Bridge/ResourceMinesContextInterface.php b/src/Application/Component/Balance/Bridge/ResourceMinesContextInterface.php index 9c9c0d3..0bf66cc 100644 --- a/src/Application/Component/Balance/Bridge/ResourceMinesContextInterface.php +++ b/src/Application/Component/Balance/Bridge/ResourceMinesContextInterface.php @@ -4,7 +4,7 @@ namespace TheGame\Application\Component\Balance\Bridge; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; interface ResourceMinesContextInterface { diff --git a/src/Application/Component/Balance/Bridge/ResourceStoragesContextInterface.php b/src/Application/Component/Balance/Bridge/ResourceStoragesContextInterface.php index a8b10f8..39f9a8f 100644 --- a/src/Application/Component/Balance/Bridge/ResourceStoragesContextInterface.php +++ b/src/Application/Component/Balance/Bridge/ResourceStoragesContextInterface.php @@ -4,7 +4,7 @@ namespace TheGame\Application\Component\Balance\Bridge; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; interface ResourceStoragesContextInterface { diff --git a/src/Application/Component/BuildingConstruction/BuildingRepositoryInterface.php b/src/Application/Component/BuildingConstruction/BuildingRepositoryInterface.php index d6c044b..5031310 100644 --- a/src/Application/Component/BuildingConstruction/BuildingRepositoryInterface.php +++ b/src/Application/Component/BuildingConstruction/BuildingRepositoryInterface.php @@ -7,8 +7,8 @@ use TheGame\Application\Component\BuildingConstruction\Domain\BuildingIdInterface; use TheGame\Application\Component\BuildingConstruction\Domain\Entity\Building; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; interface BuildingRepositoryInterface { diff --git a/src/Application/Component/BuildingConstruction/CommandHandler/CancelConstructingCommandHandler.php b/src/Application/Component/BuildingConstruction/CommandHandler/CancelConstructingCommandHandler.php index ff5d870..3fd084c 100644 --- a/src/Application/Component/BuildingConstruction/CommandHandler/CancelConstructingCommandHandler.php +++ b/src/Application/Component/BuildingConstruction/CommandHandler/CancelConstructingCommandHandler.php @@ -9,7 +9,7 @@ use TheGame\Application\Component\BuildingConstruction\Command\CancelConstructingCommand; use TheGame\Application\Component\BuildingConstruction\Domain\BuildingId; use TheGame\Application\Component\BuildingConstruction\Domain\Event\BuildingConstructionHasBeenCancelledEvent; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/src/Application/Component/BuildingConstruction/CommandHandler/FinishConstructingCommandHandler.php b/src/Application/Component/BuildingConstruction/CommandHandler/FinishConstructingCommandHandler.php index 9abcff6..3e560ab 100644 --- a/src/Application/Component/BuildingConstruction/CommandHandler/FinishConstructingCommandHandler.php +++ b/src/Application/Component/BuildingConstruction/CommandHandler/FinishConstructingCommandHandler.php @@ -8,7 +8,7 @@ use TheGame\Application\Component\BuildingConstruction\Command\FinishConstructingCommand; use TheGame\Application\Component\BuildingConstruction\Domain\BuildingId; use TheGame\Application\Component\BuildingConstruction\Domain\Event\Factory\BuildingTypeEventFactoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/src/Application/Component/BuildingConstruction/CommandHandler/StartConstructingNewBuildingCommandHandler.php b/src/Application/Component/BuildingConstruction/CommandHandler/StartConstructingNewBuildingCommandHandler.php index 6980713..cd9f8f5 100644 --- a/src/Application/Component/BuildingConstruction/CommandHandler/StartConstructingNewBuildingCommandHandler.php +++ b/src/Application/Component/BuildingConstruction/CommandHandler/StartConstructingNewBuildingCommandHandler.php @@ -14,8 +14,8 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Factory\BuildingFactoryInterface; use TheGame\Application\Component\ResourceStorage\Bridge\ResourceAvailabilityCheckerInterface; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetId; -use TheGame\Application\SharedKernel\Domain\ResourceId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\EventBusInterface; final class StartConstructingNewBuildingCommandHandler diff --git a/src/Application/Component/BuildingConstruction/CommandHandler/StartUpgradingBuildingCommandHandler.php b/src/Application/Component/BuildingConstruction/CommandHandler/StartUpgradingBuildingCommandHandler.php index bc4a87c..2ce39b3 100644 --- a/src/Application/Component/BuildingConstruction/CommandHandler/StartUpgradingBuildingCommandHandler.php +++ b/src/Application/Component/BuildingConstruction/CommandHandler/StartUpgradingBuildingCommandHandler.php @@ -12,7 +12,7 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Event\BuildingConstructionHasBeenStartedEvent; use TheGame\Application\Component\BuildingConstruction\Domain\Exception\InsufficientResourcesException; use TheGame\Application\Component\ResourceStorage\Bridge\ResourceAvailabilityCheckerInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/src/Application/Component/BuildingConstruction/Domain/Entity/Building.php b/src/Application/Component/BuildingConstruction/Domain/Entity/Building.php index ebe2303..7c54a0e 100644 --- a/src/Application/Component/BuildingConstruction/Domain/Entity/Building.php +++ b/src/Application/Component/BuildingConstruction/Domain/Entity/Building.php @@ -11,8 +11,8 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Exception\BuildingIsNotUpgradingYetException; use TheGame\Application\Component\BuildingConstruction\Domain\Exception\BuildingTimeHasNotPassedException; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; class Building { diff --git a/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingHasBeenAlreadyBuiltException.php b/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingHasBeenAlreadyBuiltException.php index 1c22d95..17731ef 100644 --- a/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingHasBeenAlreadyBuiltException.php +++ b/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingHasBeenAlreadyBuiltException.php @@ -6,7 +6,7 @@ use DomainException; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; final class BuildingHasBeenAlreadyBuiltException extends DomainException { diff --git a/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingIsAlreadyUpgradingException.php b/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingIsAlreadyUpgradingException.php index 98b487a..d116fcf 100644 --- a/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingIsAlreadyUpgradingException.php +++ b/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingIsAlreadyUpgradingException.php @@ -6,7 +6,7 @@ use DomainException; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; final class BuildingIsAlreadyUpgradingException extends DomainException { diff --git a/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingIsNotUpgradingYetException.php b/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingIsNotUpgradingYetException.php index d1bcc48..4a26ee4 100644 --- a/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingIsNotUpgradingYetException.php +++ b/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingIsNotUpgradingYetException.php @@ -6,7 +6,7 @@ use DomainException; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; final class BuildingIsNotUpgradingYetException extends DomainException { diff --git a/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingTimeHasNotPassedException.php b/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingTimeHasNotPassedException.php index 3321bb1..127e37d 100644 --- a/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingTimeHasNotPassedException.php +++ b/src/Application/Component/BuildingConstruction/Domain/Exception/BuildingTimeHasNotPassedException.php @@ -6,7 +6,7 @@ use DomainException; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; final class BuildingTimeHasNotPassedException extends DomainException { diff --git a/src/Application/Component/BuildingConstruction/Domain/Exception/InsufficientResourcesException.php b/src/Application/Component/BuildingConstruction/Domain/Exception/InsufficientResourcesException.php index afbfc3a..3dd7126 100644 --- a/src/Application/Component/BuildingConstruction/Domain/Exception/InsufficientResourcesException.php +++ b/src/Application/Component/BuildingConstruction/Domain/Exception/InsufficientResourcesException.php @@ -6,7 +6,7 @@ use DomainException; use TheGame\Application\Component\BuildingConstruction\Domain\BuildingIdInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; final class InsufficientResourcesException extends DomainException { diff --git a/src/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactory.php b/src/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactory.php index 1d009db..937b2a2 100644 --- a/src/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactory.php +++ b/src/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactory.php @@ -6,8 +6,8 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Entity\Building; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; use TheGame\Application\SharedKernel\UuidGeneratorInterface; final class BuildingFactory implements BuildingFactoryInterface diff --git a/src/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactoryInterface.php b/src/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactoryInterface.php index f75704c..cfe037e 100644 --- a/src/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactoryInterface.php +++ b/src/Application/Component/BuildingConstruction/Domain/Factory/BuildingFactoryInterface.php @@ -6,8 +6,8 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Entity\Building; use TheGame\Application\SharedKernel\Domain\BuildingType; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; interface BuildingFactoryInterface { diff --git a/src/Application/Component/FleetJourney/Command/ReturnJourneysCommand.php b/src/Application/Component/FleetJourney/Command/ReturnJourneysCommand.php index 163ac8c..a5381ce 100644 --- a/src/Application/Component/FleetJourney/Command/ReturnJourneysCommand.php +++ b/src/Application/Component/FleetJourney/Command/ReturnJourneysCommand.php @@ -9,12 +9,12 @@ final class ReturnJourneysCommand implements CommandInterface { public function __construct( - private readonly string $userId, + private readonly string $playerId, ) { } - public function getUserId(): string + public function getPlayerId(): string { - return $this->userId; + return $this->playerId; } } diff --git a/src/Application/Component/FleetJourney/Command/TargetJourneysCommand.php b/src/Application/Component/FleetJourney/Command/TargetJourneysCommand.php index 2c4b78a..557d172 100644 --- a/src/Application/Component/FleetJourney/Command/TargetJourneysCommand.php +++ b/src/Application/Component/FleetJourney/Command/TargetJourneysCommand.php @@ -9,12 +9,12 @@ final class TargetJourneysCommand implements CommandInterface { public function __construct( - private readonly string $userId, + private readonly string $playerId, ) { } - public function getUserId(): string + public function getPlayerId(): string { - return $this->userId; + return $this->playerId; } } diff --git a/src/Application/Component/FleetJourney/CommandHandler/ReturnJourneysCommandHandler.php b/src/Application/Component/FleetJourney/CommandHandler/ReturnJourneysCommandHandler.php index 021b432..59a95b3 100644 --- a/src/Application/Component/FleetJourney/CommandHandler/ReturnJourneysCommandHandler.php +++ b/src/Application/Component/FleetJourney/CommandHandler/ReturnJourneysCommandHandler.php @@ -7,7 +7,7 @@ use TheGame\Application\Component\FleetJourney\Command\ReturnJourneysCommand; use TheGame\Application\Component\FleetJourney\Domain\Event\FleetHasReachedJourneyReturnPointEvent; use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\UserId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlayerId; use TheGame\Application\SharedKernel\EventBusInterface; final class ReturnJourneysCommandHandler @@ -20,8 +20,8 @@ public function __construct( public function __invoke(ReturnJourneysCommand $command): void { - $userId = new UserId($command->getUserId()); - $fleets = $this->fleetRepository->findFlyingBackFromJourneyForUser($userId); + $playerId = new PlayerId($command->getPlayerId()); + $fleets = $this->fleetRepository->findFlyingBackFromJourneyForPlayer($playerId); foreach ($fleets as $fleet) { $fleet->tryToReachJourneyReturnPoint(); if ($fleet->didReturnFromJourney() === false) { diff --git a/src/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandler.php b/src/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandler.php index 2938cd4..2611f3b 100644 --- a/src/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandler.php +++ b/src/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandler.php @@ -10,11 +10,11 @@ use TheGame\Application\Component\FleetJourney\Domain\Exception\CannotTakeJourneyToOutOfBoundGalaxyPointException; use TheGame\Application\Component\FleetJourney\Domain\Exception\JourneyMissionIsNotEligibleException; use TheGame\Application\Component\FleetJourney\Domain\Factory\JourneyFactoryInterface; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\Component\FleetJourney\FleetResolverInterface; use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\GalaxyPoint; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; use TheGame\Application\SharedKernel\Domain\Resources; use TheGame\Application\SharedKernel\EventBusInterface; @@ -44,9 +44,9 @@ public function __invoke(StartJourneyCommand $command): void ); $startGalaxyPoint = $fleetTakingJourney->getStationingGalaxyPoint(); - $missionType = MissionType::from($command->getMissionType()); + $missionType = FleetMissionType::from($command->getMissionType()); $isMissionEligible = $this->galaxyNavigator->isMissionEligible( - $missionType->value, + $missionType, $startGalaxyPoint, $targetGalaxyPoint, ); diff --git a/src/Application/Component/FleetJourney/CommandHandler/TargetJourneysCommandHandler.php b/src/Application/Component/FleetJourney/CommandHandler/TargetJourneysCommandHandler.php index 4fe118e..7f23151 100644 --- a/src/Application/Component/FleetJourney/CommandHandler/TargetJourneysCommandHandler.php +++ b/src/Application/Component/FleetJourney/CommandHandler/TargetJourneysCommandHandler.php @@ -7,7 +7,7 @@ use TheGame\Application\Component\FleetJourney\Command\TargetJourneysCommand; use TheGame\Application\Component\FleetJourney\Domain\Event\FleetHasReachedJourneyTargetPointEvent; use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\UserId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlayerId; use TheGame\Application\SharedKernel\EventBusInterface; final class TargetJourneysCommandHandler @@ -20,8 +20,8 @@ public function __construct( public function __invoke(TargetJourneysCommand $command): void { - $userId = new UserId($command->getUserId()); - $fleets = $this->fleetRepository->findInJourneyForUser($userId); + $playerId = new PlayerId($command->getPlayerId()); + $fleets = $this->fleetRepository->findInJourneyForPlayer($playerId); foreach ($fleets as $fleet) { $fleet->tryToReachJourneyTargetPoint(); if ($fleet->didReachJourneyTargetPoint() === false) { diff --git a/src/Application/Component/FleetJourney/Domain/Entity/Fleet.php b/src/Application/Component/FleetJourney/Domain/Entity/Fleet.php index 9626315..92f8ac9 100644 --- a/src/Application/Component/FleetJourney/Domain/Entity/Fleet.php +++ b/src/Application/Component/FleetJourney/Domain/Entity/Fleet.php @@ -11,9 +11,9 @@ use TheGame\Application\Component\FleetJourney\Domain\Exception\NotEnoughFleetLoadCapacityException; use TheGame\Application\Component\FleetJourney\Domain\Exception\NotEnoughShipsException; use TheGame\Application\Component\FleetJourney\Domain\FleetIdInterface; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\Component\FleetJourney\Domain\ShipsGroupInterface; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; class Fleet @@ -58,7 +58,7 @@ public function addShips(array $ships): void foreach ($ships as $shipsToAdd) { foreach ($this->ships as $currentGroup) { - if ($currentGroup->hasType($shipsToAdd->getType())) { + if ($currentGroup->hasShip($shipsToAdd->getShipName())) { $currentGroup->merge($shipsToAdd); continue 2; @@ -93,20 +93,20 @@ public function hasEnoughShips( return false; } - foreach ($shipsToCompare as $shipType => $quantity) { - $shipTypeFound = false; + foreach ($shipsToCompare as $shipName => $quantity) { + $shipNameFound = false; foreach ($this->ships as $shipGroup) { - if ($shipGroup->hasType($shipType) === false) { + if ($shipGroup->hasShip($shipName) === false) { continue; } - $shipTypeFound = true; + $shipNameFound = true; if ($shipGroup->hasEnoughShips($quantity) === false) { return false; } } - if ($shipTypeFound === false) { + if ($shipNameFound === false) { return false; } } @@ -126,9 +126,9 @@ public function hasMoreShipsThan( return false; } - foreach ($shipsToCompare as $shipType => $quantity) { + foreach ($shipsToCompare as $shipName => $quantity) { foreach ($this->ships as $shipGroup) { - if ($shipGroup->hasType($shipType) === false) { + if ($shipGroup->hasShip($shipName) === false) { continue; } @@ -153,13 +153,13 @@ public function split( } $splitShips = []; - foreach ($shipsToSplit as $shipType => $quantity) { + foreach ($shipsToSplit as $shipName => $quantity) { if ($quantity <= 0) { continue; } foreach ($this->ships as $shipGroup) { - if ($shipGroup->hasType($shipType) === false) { + if ($shipGroup->hasShip($shipName) === false) { continue; } @@ -201,7 +201,7 @@ public function startJourney(Journey $journey): void $this->currentJourney = $journey; } - public function getJourneyMissionType(): MissionType + public function getJourneyMissionType(): FleetMissionType { if ($this->isDuringJourney() === false) { throw new FleetNotInJourneyYetException($this->fleetId); diff --git a/src/Application/Component/FleetJourney/Domain/Entity/Journey.php b/src/Application/Component/FleetJourney/Domain/Entity/Journey.php index a2bbacb..cce5426 100644 --- a/src/Application/Component/FleetJourney/Domain/Entity/Journey.php +++ b/src/Application/Component/FleetJourney/Domain/Entity/Journey.php @@ -15,8 +15,8 @@ use TheGame\Application\Component\FleetJourney\Domain\Exception\FleetOnFlyBackException; use TheGame\Application\Component\FleetJourney\Domain\FleetIdInterface; use TheGame\Application\Component\FleetJourney\Domain\JourneyIdInterface; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; class Journey { @@ -39,7 +39,7 @@ class Journey public function __construct( private readonly JourneyIdInterface $journeyId, private readonly FleetIdInterface $fleetId, - private readonly MissionType $missionType, + private readonly FleetMissionType $missionType, private readonly GalaxyPointInterface $startPoint, private readonly GalaxyPointInterface $targetPoint, private readonly int $duration, @@ -62,7 +62,7 @@ public function getId(): JourneyIdInterface return $this->journeyId; } - public function getMissionType(): MissionType + public function getMissionType(): FleetMissionType { return $this->missionType; } @@ -109,17 +109,17 @@ public function getReturnsAt(): DateTimeInterface public function doesPlanToStationOnTarget(): bool { - return $this->missionType === MissionType::Stationing; + return $this->missionType === FleetMissionType::Stationing; } public function doesAttack(): bool { - return $this->missionType === MissionType::Attack; + return $this->missionType === FleetMissionType::Attack; } public function doesTransportResources(): bool { - return $this->missionType === MissionType::Transport; + return $this->missionType === FleetMissionType::Transport; } public function doesFlyBack(): bool diff --git a/src/Application/Component/FleetJourney/Domain/Exception/CannotMergeShipGroupsOfDifferentShips.php b/src/Application/Component/FleetJourney/Domain/Exception/CannotMergeShipGroupsOfDifferentShips.php new file mode 100644 index 0000000..6567770 --- /dev/null +++ b/src/Application/Component/FleetJourney/Domain/Exception/CannotMergeShipGroupsOfDifferentShips.php @@ -0,0 +1,21 @@ +uuidGenerator->generateNewJourneyId(); diff --git a/src/Application/Component/FleetJourney/Domain/Factory/JourneyFactoryInterface.php b/src/Application/Component/FleetJourney/Domain/Factory/JourneyFactoryInterface.php index 21ba802..b6b1923 100644 --- a/src/Application/Component/FleetJourney/Domain/Factory/JourneyFactoryInterface.php +++ b/src/Application/Component/FleetJourney/Domain/Factory/JourneyFactoryInterface.php @@ -6,16 +6,16 @@ use TheGame\Application\Component\FleetJourney\Domain\Entity\Journey; use TheGame\Application\Component\FleetJourney\Domain\FleetIdInterface; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; interface JourneyFactoryInterface { public function createJourney( - FleetIdInterface $fleetId, - MissionType $missionType, + FleetIdInterface $fleetId, + FleetMissionType $missionType, GalaxyPointInterface $startGalaxyPoint, GalaxyPointInterface $targetGalaxyPoint, - int $journeyDuration, + int $journeyDuration, ): Journey; } diff --git a/src/Application/Component/FleetJourney/Domain/ShipsGroup.php b/src/Application/Component/FleetJourney/Domain/ShipsGroup.php index e6758a0..056b964 100644 --- a/src/Application/Component/FleetJourney/Domain/ShipsGroup.php +++ b/src/Application/Component/FleetJourney/Domain/ShipsGroup.php @@ -4,22 +4,22 @@ namespace TheGame\Application\Component\FleetJourney\Domain; -use TheGame\Application\Component\FleetJourney\Domain\Exception\CannotMergeShipGroupsOfDifferentTypeException; +use TheGame\Application\Component\FleetJourney\Domain\Exception\CannotMergeShipGroupsOfDifferentShips; use TheGame\Application\Component\FleetJourney\Domain\Exception\NotEnoughShipsException; final class ShipsGroup implements ShipsGroupInterface { public function __construct( - private readonly string $type, - private int $quantity, - private readonly int $speed, - private readonly int $unitLoadCapacity, + private readonly string $shipName, + private int $quantity, + private readonly int $speed, + private readonly int $unitLoadCapacity, ) { } - public function getType(): string + public function getShipName(): string { - return $this->type; + return $this->shipName; } public function getQuantity(): int @@ -27,9 +27,9 @@ public function getQuantity(): int return $this->quantity; } - public function hasType(string $type): bool + public function hasShip(string $name): bool { - return $this->type === $type; + return $this->shipName === $name; } public function hasMoreShipsThan(int $quantity): bool @@ -44,8 +44,8 @@ public function hasEnoughShips(int $quantity): bool public function merge(ShipsGroupInterface $shipGroup): void { - if ($this->type !== $shipGroup->getType()) { - throw new CannotMergeShipGroupsOfDifferentTypeException($this->type, $shipGroup->getType()); + if ($this->shipName !== $shipGroup->getShipName()) { + throw new CannotMergeShipGroupsOfDifferentShips($this->shipName, $shipGroup->getShipName()); } $this->quantity += $shipGroup->getQuantity(); @@ -55,13 +55,13 @@ public function merge(ShipsGroupInterface $shipGroup): void public function split(int $quantity): ShipsGroupInterface { if ($this->hasEnoughShips($quantity) === false) { - throw new NotEnoughShipsException($this->type); + throw new NotEnoughShipsException($this->shipName); } $this->quantity -= $quantity; return new ShipsGroup( - $this->type, + $this->shipName, $quantity, $this->speed, $this->unitLoadCapacity, diff --git a/src/Application/Component/FleetJourney/Domain/ShipsGroupInterface.php b/src/Application/Component/FleetJourney/Domain/ShipsGroupInterface.php index 1538758..25323cb 100644 --- a/src/Application/Component/FleetJourney/Domain/ShipsGroupInterface.php +++ b/src/Application/Component/FleetJourney/Domain/ShipsGroupInterface.php @@ -6,11 +6,11 @@ interface ShipsGroupInterface { - public function getType(): string; + public function getShipName(): string; public function getQuantity(): int; - public function hasType(string $type): bool; + public function hasShip(string $name): bool; public function merge(ShipsGroupInterface $shipGroup): void; diff --git a/src/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListener.php b/src/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListener.php index 00002c1..f1cdc80 100644 --- a/src/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListener.php +++ b/src/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListener.php @@ -10,7 +10,7 @@ use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface; use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface; use TheGame\Application\Component\Shipyard\Domain\Event\NewShipsHaveBeenConstructedEvent; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\Resources; final class AddNewlyConstructedShipsToFleetEventListener @@ -30,18 +30,18 @@ public function __invoke(NewShipsHaveBeenConstructedEvent $event): void if ($fleetCurrentlyStationingOnPlanet === null) { $fleetCurrentlyStationingOnPlanet = $this->fleetFactory->create( [], - $this->navigator->getPlanetPoint($planetId), + $this->navigator->getPlanetPosition($planetId), new Resources(), ); } - $shipType = $event->getType(); + $shipName = $event->getName(); $fleetCurrentlyStationingOnPlanet->addShips([ new ShipsGroup( - $shipType, + $shipName, $event->getQuantity(), - $this->fleetJourneyContext->getShipBaseSpeed($shipType), - $this->fleetJourneyContext->getShipLoadCapacity($shipType), + $this->fleetJourneyContext->getShipBaseSpeed($shipName), + $this->fleetJourneyContext->getShipLoadCapacity($shipName), ), ]); } diff --git a/src/Application/Component/FleetJourney/EventListener/StationFleetOnReachingTargetPointEventListener.php b/src/Application/Component/FleetJourney/EventListener/StationFleetOnReachingTargetPointEventListener.php index 7edf564..0b074a7 100644 --- a/src/Application/Component/FleetJourney/EventListener/StationFleetOnReachingTargetPointEventListener.php +++ b/src/Application/Component/FleetJourney/EventListener/StationFleetOnReachingTargetPointEventListener.php @@ -6,10 +6,10 @@ use TheGame\Application\Component\FleetJourney\Domain\Event\FleetHasReachedJourneyTargetPointEvent; use TheGame\Application\Component\FleetJourney\Domain\FleetId; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface; use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface; use TheGame\Application\SharedKernel\Domain\GalaxyPoint; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; final class StationFleetOnReachingTargetPointEventListener @@ -22,8 +22,8 @@ public function __construct( public function __invoke(FleetHasReachedJourneyTargetPointEvent $event): void { - $mission = MissionType::from($event->getMission()); - if ($mission !== MissionType::Stationing) { + $mission = FleetMissionType::from($event->getMission()); + if ($mission !== FleetMissionType::Stationing) { return; } diff --git a/src/Application/Component/FleetJourney/FleetRepositoryInterface.php b/src/Application/Component/FleetJourney/FleetRepositoryInterface.php index 9ea4fed..9f5944b 100644 --- a/src/Application/Component/FleetJourney/FleetRepositoryInterface.php +++ b/src/Application/Component/FleetJourney/FleetRepositoryInterface.php @@ -6,8 +6,8 @@ use TheGame\Application\Component\FleetJourney\Domain\Entity\Fleet; use TheGame\Application\Component\FleetJourney\Domain\FleetIdInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; -use TheGame\Application\SharedKernel\Domain\UserIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlayerIdInterface; interface FleetRepositoryInterface { @@ -16,8 +16,8 @@ public function find(FleetIdInterface $fleetId): ?Fleet; public function findStationingOnPlanet(PlanetIdInterface $planetId): ?Fleet; /** @return array */ - public function findFlyingBackFromJourneyForUser(UserIdInterface $userId): array; + public function findFlyingBackFromJourneyForPlayer(PlayerIdInterface $playerId): array; /** @return array */ - public function findInJourneyForUser(UserIdInterface $userId): array; + public function findInJourneyForPlayer(PlayerIdInterface $playerId): array; } diff --git a/src/Application/Component/FleetJourney/FleetResolver.php b/src/Application/Component/FleetJourney/FleetResolver.php index ffa8a68..57a5b86 100644 --- a/src/Application/Component/FleetJourney/FleetResolver.php +++ b/src/Application/Component/FleetJourney/FleetResolver.php @@ -12,8 +12,8 @@ use TheGame\Application\Component\FleetJourney\Domain\Exception\NotEnoughShipsException; use TheGame\Application\Component\FleetJourney\Domain\Factory\FleetFactoryInterface; use TheGame\Application\Component\ResourceStorage\Bridge\ResourceAvailabilityCheckerInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; final class FleetResolver implements FleetResolverInterface diff --git a/src/Application/Component/FleetJourney/FleetResolverInterface.php b/src/Application/Component/FleetJourney/FleetResolverInterface.php index 77989b7..5ac1ede 100644 --- a/src/Application/Component/FleetJourney/FleetResolverInterface.php +++ b/src/Application/Component/FleetJourney/FleetResolverInterface.php @@ -5,8 +5,8 @@ namespace TheGame\Application\Component\FleetJourney; use TheGame\Application\Component\FleetJourney\Domain\Entity\Fleet; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; interface FleetResolverInterface diff --git a/src/Application/Component/ResourceMines/CommandHandler/ExtractResourcesCommandHandler.php b/src/Application/Component/ResourceMines/CommandHandler/ExtractResourcesCommandHandler.php index d81d19d..d340b18 100644 --- a/src/Application/Component/ResourceMines/CommandHandler/ExtractResourcesCommandHandler.php +++ b/src/Application/Component/ResourceMines/CommandHandler/ExtractResourcesCommandHandler.php @@ -7,7 +7,7 @@ use TheGame\Application\Component\ResourceMines\Command\ExtractResourcesCommand; use TheGame\Application\Component\ResourceMines\Domain\Event\ResourceHasBeenExtractedEvent; use TheGame\Application\Component\ResourceMines\ResourceMinesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/src/Application/Component/ResourceMines/Domain/Entity/Mine.php b/src/Application/Component/ResourceMines/Domain/Entity/Mine.php index bb12b6b..b764ba5 100644 --- a/src/Application/Component/ResourceMines/Domain/Entity/Mine.php +++ b/src/Application/Component/ResourceMines/Domain/Entity/Mine.php @@ -7,9 +7,9 @@ use DateTimeImmutable; use DateTimeInterface; use TheGame\Application\Component\ResourceMines\Domain\MineIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; use TheGame\Application\SharedKernel\Domain\ResourceAmount; use TheGame\Application\SharedKernel\Domain\ResourceAmountInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; class Mine { diff --git a/src/Application/Component/ResourceMines/Domain/Entity/MinesCollection.php b/src/Application/Component/ResourceMines/Domain/Entity/MinesCollection.php index 098a3a0..d5bc854 100644 --- a/src/Application/Component/ResourceMines/Domain/Entity/MinesCollection.php +++ b/src/Application/Component/ResourceMines/Domain/Entity/MinesCollection.php @@ -8,9 +8,9 @@ use Doctrine\Common\Collections\Collection; use TheGame\Application\Component\ResourceMines\Domain\Exception\CannotUpgradeMiningSpeedForUnsupportedResourceException; use TheGame\Application\Component\ResourceMines\Domain\MinesCollectionIdInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; use TheGame\Application\SharedKernel\Domain\ResourceAmountInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; class MinesCollection { diff --git a/src/Application/Component/ResourceMines/Domain/Exception/CannotUpgradeMiningSpeedForUnsupportedResourceException.php b/src/Application/Component/ResourceMines/Domain/Exception/CannotUpgradeMiningSpeedForUnsupportedResourceException.php index 1f57e70..79294b5 100644 --- a/src/Application/Component/ResourceMines/Domain/Exception/CannotUpgradeMiningSpeedForUnsupportedResourceException.php +++ b/src/Application/Component/ResourceMines/Domain/Exception/CannotUpgradeMiningSpeedForUnsupportedResourceException.php @@ -5,8 +5,8 @@ namespace TheGame\Application\Component\ResourceMines\Domain\Exception; use DomainException; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; final class CannotUpgradeMiningSpeedForUnsupportedResourceException extends DomainException { diff --git a/src/Application/Component/ResourceMines/Domain/Factory/MineFactory.php b/src/Application/Component/ResourceMines/Domain/Factory/MineFactory.php index 10a92a4..9d1b9ff 100644 --- a/src/Application/Component/ResourceMines/Domain/Factory/MineFactory.php +++ b/src/Application/Component/ResourceMines/Domain/Factory/MineFactory.php @@ -7,7 +7,7 @@ use DateTimeImmutable; use TheGame\Application\Component\Balance\Bridge\ResourceMinesContextInterface; use TheGame\Application\Component\ResourceMines\Domain\Entity\Mine; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; use TheGame\Application\SharedKernel\UuidGeneratorInterface; final class MineFactory implements MineFactoryInterface diff --git a/src/Application/Component/ResourceMines/Domain/Factory/MineFactoryInterface.php b/src/Application/Component/ResourceMines/Domain/Factory/MineFactoryInterface.php index be807b5..ca63d69 100644 --- a/src/Application/Component/ResourceMines/Domain/Factory/MineFactoryInterface.php +++ b/src/Application/Component/ResourceMines/Domain/Factory/MineFactoryInterface.php @@ -5,7 +5,7 @@ namespace TheGame\Application\Component\ResourceMines\Domain\Factory; use TheGame\Application\Component\ResourceMines\Domain\Entity\Mine; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; interface MineFactoryInterface { diff --git a/src/Application/Component/ResourceMines/EventListener/UpgradeMineEventListener.php b/src/Application/Component/ResourceMines/EventListener/UpgradeMineEventListener.php index 5ff34bd..3561026 100644 --- a/src/Application/Component/ResourceMines/EventListener/UpgradeMineEventListener.php +++ b/src/Application/Component/ResourceMines/EventListener/UpgradeMineEventListener.php @@ -8,8 +8,8 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Event\ResourceMineConstructionHasBeenFinishedEvent; use TheGame\Application\Component\ResourceMines\Domain\Factory\MineFactoryInterface; use TheGame\Application\Component\ResourceMines\ResourceMinesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; -use TheGame\Application\SharedKernel\Domain\ResourceId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; final class UpgradeMineEventListener diff --git a/src/Application/Component/ResourceMines/ResourceMinesRepositoryInterface.php b/src/Application/Component/ResourceMines/ResourceMinesRepositoryInterface.php index c355532..7baf1ac 100644 --- a/src/Application/Component/ResourceMines/ResourceMinesRepositoryInterface.php +++ b/src/Application/Component/ResourceMines/ResourceMinesRepositoryInterface.php @@ -5,7 +5,7 @@ namespace TheGame\Application\Component\ResourceMines; use TheGame\Application\Component\ResourceMines\Domain\Entity\MinesCollection; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; interface ResourceMinesRepositoryInterface { diff --git a/src/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityChecker.php b/src/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityChecker.php index 65f23eb..7609ab8 100644 --- a/src/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityChecker.php +++ b/src/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityChecker.php @@ -5,7 +5,7 @@ namespace TheGame\Application\Component\ResourceStorage\Bridge; use TheGame\Application\Component\ResourceStorage\ResourceStoragesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/src/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityCheckerInterface.php b/src/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityCheckerInterface.php index c614832..48f3a26 100644 --- a/src/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityCheckerInterface.php +++ b/src/Application/Component/ResourceStorage/Bridge/ResourceAvailabilityCheckerInterface.php @@ -4,7 +4,7 @@ namespace TheGame\Application\Component\ResourceStorage\Bridge; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; interface ResourceAvailabilityCheckerInterface diff --git a/src/Application/Component/ResourceStorage/CommandHandler/DispatchResourcesCommandHandler.php b/src/Application/Component/ResourceStorage/CommandHandler/DispatchResourcesCommandHandler.php index ea27f26..3c2a5f0 100644 --- a/src/Application/Component/ResourceStorage/CommandHandler/DispatchResourcesCommandHandler.php +++ b/src/Application/Component/ResourceStorage/CommandHandler/DispatchResourcesCommandHandler.php @@ -9,9 +9,9 @@ use TheGame\Application\Component\ResourceStorage\Domain\Event\StorageAmountHasChangedEvent; use TheGame\Application\Component\ResourceStorage\Domain\Factory\StorageFactoryInterface; use TheGame\Application\Component\ResourceStorage\ResourceStoragesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmount; -use TheGame\Application\SharedKernel\Domain\ResourceId; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/src/Application/Component/ResourceStorage/CommandHandler/UseResourceCommandHandler.php b/src/Application/Component/ResourceStorage/CommandHandler/UseResourceCommandHandler.php index 852462f..62610e7 100644 --- a/src/Application/Component/ResourceStorage/CommandHandler/UseResourceCommandHandler.php +++ b/src/Application/Component/ResourceStorage/CommandHandler/UseResourceCommandHandler.php @@ -8,9 +8,9 @@ use TheGame\Application\Component\ResourceStorage\Domain\Event\StorageAmountHasChangedEvent; use TheGame\Application\Component\ResourceStorage\Domain\Exception\InsufficientResourcesException; use TheGame\Application\Component\ResourceStorage\ResourceStoragesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Domain\ResourceAmount; -use TheGame\Application\SharedKernel\Domain\ResourceId; use TheGame\Application\SharedKernel\Domain\Resources; use TheGame\Application\SharedKernel\EventBusInterface; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; diff --git a/src/Application/Component/ResourceStorage/Domain/Entity/Storage.php b/src/Application/Component/ResourceStorage/Domain/Entity/Storage.php index 2bb7f37..3d3a7b8 100644 --- a/src/Application/Component/ResourceStorage/Domain/Entity/Storage.php +++ b/src/Application/Component/ResourceStorage/Domain/Entity/Storage.php @@ -8,8 +8,8 @@ use TheGame\Application\Component\ResourceStorage\Domain\Exception\CannotUseUnsupportedResourceException; use TheGame\Application\Component\ResourceStorage\Domain\Exception\InsufficientResourcesException; use TheGame\Application\Component\ResourceStorage\Domain\StorageIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; use TheGame\Application\SharedKernel\Domain\ResourceAmountInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; class Storage { diff --git a/src/Application/Component/ResourceStorage/Domain/Entity/StoragesCollection.php b/src/Application/Component/ResourceStorage/Domain/Entity/StoragesCollection.php index c062c7e..db74f59 100644 --- a/src/Application/Component/ResourceStorage/Domain/Entity/StoragesCollection.php +++ b/src/Application/Component/ResourceStorage/Domain/Entity/StoragesCollection.php @@ -11,9 +11,9 @@ use TheGame\Application\Component\ResourceStorage\Domain\Exception\CannotUseUnsupportedResourceException; use TheGame\Application\Component\ResourceStorage\Domain\Exception\InsufficientResourcesException; use TheGame\Application\Component\ResourceStorage\Domain\StoragesCollectionIdInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; use TheGame\Application\SharedKernel\Domain\ResourceAmountInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; class StoragesCollection diff --git a/src/Application/Component/ResourceStorage/Domain/Exception/CannotUpgradeStorageForUnsupportedResourceException.php b/src/Application/Component/ResourceStorage/Domain/Exception/CannotUpgradeStorageForUnsupportedResourceException.php index e146dcf..543b8f7 100644 --- a/src/Application/Component/ResourceStorage/Domain/Exception/CannotUpgradeStorageForUnsupportedResourceException.php +++ b/src/Application/Component/ResourceStorage/Domain/Exception/CannotUpgradeStorageForUnsupportedResourceException.php @@ -5,8 +5,8 @@ namespace TheGame\Application\Component\ResourceStorage\Domain\Exception; use DomainException; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; final class CannotUpgradeStorageForUnsupportedResourceException extends DomainException { diff --git a/src/Application/Component/ResourceStorage/Domain/Exception/CannotUpgradeStorageLimitForLowerValueException.php b/src/Application/Component/ResourceStorage/Domain/Exception/CannotUpgradeStorageLimitForLowerValueException.php index 592c604..09c730c 100644 --- a/src/Application/Component/ResourceStorage/Domain/Exception/CannotUpgradeStorageLimitForLowerValueException.php +++ b/src/Application/Component/ResourceStorage/Domain/Exception/CannotUpgradeStorageLimitForLowerValueException.php @@ -6,7 +6,7 @@ use DomainException; use TheGame\Application\Component\ResourceStorage\Domain\StorageIdInterface; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; final class CannotUpgradeStorageLimitForLowerValueException extends DomainException { diff --git a/src/Application/Component/ResourceStorage/Domain/Exception/CannotUseUnsupportedResourceException.php b/src/Application/Component/ResourceStorage/Domain/Exception/CannotUseUnsupportedResourceException.php index 4e23a09..75364c2 100644 --- a/src/Application/Component/ResourceStorage/Domain/Exception/CannotUseUnsupportedResourceException.php +++ b/src/Application/Component/ResourceStorage/Domain/Exception/CannotUseUnsupportedResourceException.php @@ -6,7 +6,7 @@ use DomainException; use TheGame\Application\Component\ResourceStorage\Domain\StorageIdInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\ResourceAmountInterface; final class CannotUseUnsupportedResourceException extends DomainException diff --git a/src/Application/Component/ResourceStorage/Domain/Exception/InsufficientResourcesException.php b/src/Application/Component/ResourceStorage/Domain/Exception/InsufficientResourcesException.php index 660166c..72c47bf 100644 --- a/src/Application/Component/ResourceStorage/Domain/Exception/InsufficientResourcesException.php +++ b/src/Application/Component/ResourceStorage/Domain/Exception/InsufficientResourcesException.php @@ -6,7 +6,7 @@ use DomainException; use TheGame\Application\Component\ResourceStorage\Domain\StorageIdInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\ResourceAmountInterface; final class InsufficientResourcesException extends DomainException diff --git a/src/Application/Component/ResourceStorage/Domain/Factory/StorageFactory.php b/src/Application/Component/ResourceStorage/Domain/Factory/StorageFactory.php index 622cfbe..e0b43c0 100644 --- a/src/Application/Component/ResourceStorage/Domain/Factory/StorageFactory.php +++ b/src/Application/Component/ResourceStorage/Domain/Factory/StorageFactory.php @@ -5,7 +5,7 @@ namespace TheGame\Application\Component\ResourceStorage\Domain\Factory; use TheGame\Application\Component\ResourceStorage\Domain\Entity\Storage; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; use TheGame\Application\SharedKernel\UuidGeneratorInterface; final class StorageFactory implements StorageFactoryInterface diff --git a/src/Application/Component/ResourceStorage/Domain/Factory/StorageFactoryInterface.php b/src/Application/Component/ResourceStorage/Domain/Factory/StorageFactoryInterface.php index eaa324a..902058c 100644 --- a/src/Application/Component/ResourceStorage/Domain/Factory/StorageFactoryInterface.php +++ b/src/Application/Component/ResourceStorage/Domain/Factory/StorageFactoryInterface.php @@ -5,7 +5,7 @@ namespace TheGame\Application\Component\ResourceStorage\Domain\Factory; use TheGame\Application\Component\ResourceStorage\Domain\Entity\Storage; -use TheGame\Application\SharedKernel\Domain\ResourceIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; interface StorageFactoryInterface { diff --git a/src/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyTargetPointEventListener.php b/src/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyTargetPointEventListener.php index c4e43f3..311445b 100644 --- a/src/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyTargetPointEventListener.php +++ b/src/Application/Component/ResourceStorage/EventListener/UnloadResourcesAfterReachingJourneyTargetPointEventListener.php @@ -5,11 +5,11 @@ namespace TheGame\Application\Component\ResourceStorage\EventListener; use TheGame\Application\Component\FleetJourney\Domain\Event\FleetHasReachedJourneyTargetPointEvent; -use TheGame\Application\Component\FleetJourney\Domain\MissionType; use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface; use TheGame\Application\Component\ResourceStorage\Command\DispatchResourcesCommand; use TheGame\Application\SharedKernel\CommandBusInterface; use TheGame\Application\SharedKernel\Domain\GalaxyPoint; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; final class UnloadResourcesAfterReachingJourneyTargetPointEventListener @@ -22,8 +22,8 @@ public function __construct( public function __invoke(FleetHasReachedJourneyTargetPointEvent $event): void { - $mission = MissionType::from($event->getMission()); - if ($mission !== MissionType::Stationing && $mission != MissionType::Transport) { + $mission = FleetMissionType::from($event->getMission()); + if ($mission !== FleetMissionType::Attack) { return; } diff --git a/src/Application/Component/ResourceStorage/EventListener/UpgradeStorageEventListener.php b/src/Application/Component/ResourceStorage/EventListener/UpgradeStorageEventListener.php index ddcb920..7448f03 100644 --- a/src/Application/Component/ResourceStorage/EventListener/UpgradeStorageEventListener.php +++ b/src/Application/Component/ResourceStorage/EventListener/UpgradeStorageEventListener.php @@ -8,8 +8,8 @@ use TheGame\Application\Component\BuildingConstruction\Domain\Event\ResourceStorageConstructionHasBeenFinishedEvent; use TheGame\Application\Component\ResourceStorage\Domain\Factory\StorageFactoryInterface; use TheGame\Application\Component\ResourceStorage\ResourceStoragesRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; -use TheGame\Application\SharedKernel\Domain\ResourceId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId; use TheGame\Application\SharedKernel\Exception\InconsistentModelException; final class UpgradeStorageEventListener diff --git a/src/Application/Component/ResourceStorage/ResourceStoragesRepositoryInterface.php b/src/Application/Component/ResourceStorage/ResourceStoragesRepositoryInterface.php index 2f55d46..5c23e69 100644 --- a/src/Application/Component/ResourceStorage/ResourceStoragesRepositoryInterface.php +++ b/src/Application/Component/ResourceStorage/ResourceStoragesRepositoryInterface.php @@ -5,7 +5,7 @@ namespace TheGame\Application\Component\ResourceStorage; use TheGame\Application\Component\ResourceStorage\Domain\Entity\StoragesCollection; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; interface ResourceStoragesRepositoryInterface { diff --git a/src/Application/Component/Shipyard/Domain/Entity/Shipyard.php b/src/Application/Component/Shipyard/Domain/Entity/Shipyard.php index 5ad414b..ee64177 100644 --- a/src/Application/Component/Shipyard/Domain/Entity/Shipyard.php +++ b/src/Application/Component/Shipyard/Domain/Entity/Shipyard.php @@ -13,7 +13,7 @@ use TheGame\Application\Component\Shipyard\Domain\FinishedJobsSummaryInterface; use TheGame\Application\Component\Shipyard\Domain\JobIdInterface; use TheGame\Application\Component\Shipyard\Domain\ShipyardIdInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\ResourcesInterface; class Shipyard diff --git a/src/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactory.php b/src/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactory.php index 9332b04..371c462 100644 --- a/src/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactory.php +++ b/src/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactory.php @@ -9,7 +9,7 @@ use TheGame\Application\Component\Shipyard\Domain\Event\NewShipsHaveBeenConstructedEvent; use TheGame\Application\Component\Shipyard\Domain\Event\NewUnitsHaveBeenConstructedEvent; use TheGame\Application\Component\Shipyard\Domain\FinishedJobsSummaryEntryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\EventInterface; final class FinishedConstructionEventFactory implements FinishedConstructionEventFactoryInterface diff --git a/src/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactoryInterface.php b/src/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactoryInterface.php index fa58e73..7afa11d 100644 --- a/src/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactoryInterface.php +++ b/src/Application/Component/Shipyard/Domain/Event/Factory/FinishedConstructionEventFactoryInterface.php @@ -5,7 +5,7 @@ namespace TheGame\Application\Component\Shipyard\Domain\Event\Factory; use TheGame\Application\Component\Shipyard\Domain\FinishedJobsSummaryEntryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\EventInterface; interface FinishedConstructionEventFactoryInterface diff --git a/src/Application/Component/Shipyard/Domain/Event/NewShipsHaveBeenConstructedEvent.php b/src/Application/Component/Shipyard/Domain/Event/NewShipsHaveBeenConstructedEvent.php index 11d8c26..ff30fa2 100644 --- a/src/Application/Component/Shipyard/Domain/Event/NewShipsHaveBeenConstructedEvent.php +++ b/src/Application/Component/Shipyard/Domain/Event/NewShipsHaveBeenConstructedEvent.php @@ -10,8 +10,8 @@ final class NewShipsHaveBeenConstructedEvent implements EventInterface { public function __construct( private readonly string $planetId, - private readonly string $type, - private readonly int $quantity, + private readonly string $name, + private readonly int $quantity, ) { } @@ -20,9 +20,9 @@ public function getPlanetId(): string return $this->planetId; } - public function getType(): string + public function getName(): string { - return $this->type; + return $this->name; } public function getQuantity(): int diff --git a/src/Application/Component/Shipyard/Domain/Exception/InsufficientResourcesException.php b/src/Application/Component/Shipyard/Domain/Exception/InsufficientResourcesException.php index 4463fdc..8b1177d 100644 --- a/src/Application/Component/Shipyard/Domain/Exception/InsufficientResourcesException.php +++ b/src/Application/Component/Shipyard/Domain/Exception/InsufficientResourcesException.php @@ -5,7 +5,7 @@ namespace TheGame\Application\Component\Shipyard\Domain\Exception; use DomainException; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; final class InsufficientResourcesException extends DomainException { diff --git a/src/Application/Component/Shipyard/Domain/Factory/ShipyardFactory.php b/src/Application/Component/Shipyard/Domain/Factory/ShipyardFactory.php index 1ef5977..f4ed09a 100644 --- a/src/Application/Component/Shipyard/Domain/Factory/ShipyardFactory.php +++ b/src/Application/Component/Shipyard/Domain/Factory/ShipyardFactory.php @@ -7,7 +7,7 @@ use DateTimeImmutable; use TheGame\Application\Component\BuildingConstruction\Domain\BuildingIdInterface; use TheGame\Application\Component\Shipyard\Domain\Entity\Shipyard; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\UuidGeneratorInterface; final class ShipyardFactory implements ShipyardFactoryInterface diff --git a/src/Application/Component/Shipyard/Domain/Factory/ShipyardFactoryInterface.php b/src/Application/Component/Shipyard/Domain/Factory/ShipyardFactoryInterface.php index 6654a45..42acc2e 100644 --- a/src/Application/Component/Shipyard/Domain/Factory/ShipyardFactoryInterface.php +++ b/src/Application/Component/Shipyard/Domain/Factory/ShipyardFactoryInterface.php @@ -6,7 +6,7 @@ use TheGame\Application\Component\BuildingConstruction\Domain\BuildingIdInterface; use TheGame\Application\Component\Shipyard\Domain\Entity\Shipyard; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; interface ShipyardFactoryInterface { diff --git a/src/Application/Component/Shipyard/EventListener/UpgradeShipyardEventListener.php b/src/Application/Component/Shipyard/EventListener/UpgradeShipyardEventListener.php index 6c296fe..008dfa5 100644 --- a/src/Application/Component/Shipyard/EventListener/UpgradeShipyardEventListener.php +++ b/src/Application/Component/Shipyard/EventListener/UpgradeShipyardEventListener.php @@ -10,7 +10,7 @@ use TheGame\Application\Component\Shipyard\Domain\Factory\ShipyardFactoryInterface; use TheGame\Application\Component\Shipyard\Exception\ShipyardHasNotBeenFoundException; use TheGame\Application\Component\Shipyard\ShipyardRepositoryInterface; -use TheGame\Application\SharedKernel\Domain\PlanetId; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; final class UpgradeShipyardEventListener { diff --git a/src/Application/Component/Shipyard/ShipyardRepositoryInterface.php b/src/Application/Component/Shipyard/ShipyardRepositoryInterface.php index b46a290..af41f15 100644 --- a/src/Application/Component/Shipyard/ShipyardRepositoryInterface.php +++ b/src/Application/Component/Shipyard/ShipyardRepositoryInterface.php @@ -7,7 +7,7 @@ use TheGame\Application\Component\BuildingConstruction\Domain\BuildingIdInterface; use TheGame\Application\Component\Shipyard\Domain\Entity\Shipyard; use TheGame\Application\Component\Shipyard\Domain\ShipyardIdInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; interface ShipyardRepositoryInterface { diff --git a/src/Application/SharedKernel/Domain/PlanetId.php b/src/Application/SharedKernel/Domain/EntityId/PlanetId.php similarity index 80% rename from src/Application/SharedKernel/Domain/PlanetId.php rename to src/Application/SharedKernel/Domain/EntityId/PlanetId.php index 1c21dfb..9431f00 100644 --- a/src/Application/SharedKernel/Domain/PlanetId.php +++ b/src/Application/SharedKernel/Domain/EntityId/PlanetId.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace TheGame\Application\SharedKernel\Domain; +namespace TheGame\Application\SharedKernel\Domain\EntityId; final class PlanetId implements PlanetIdInterface { diff --git a/src/Application/SharedKernel/Domain/PlanetIdInterface.php b/src/Application/SharedKernel/Domain/EntityId/PlanetIdInterface.php similarity index 70% rename from src/Application/SharedKernel/Domain/PlanetIdInterface.php rename to src/Application/SharedKernel/Domain/EntityId/PlanetIdInterface.php index 759d713..61a2c54 100644 --- a/src/Application/SharedKernel/Domain/PlanetIdInterface.php +++ b/src/Application/SharedKernel/Domain/EntityId/PlanetIdInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace TheGame\Application\SharedKernel\Domain; +namespace TheGame\Application\SharedKernel\Domain\EntityId; use TheGame\Application\SharedKernel\UuidInterface; diff --git a/src/Application/SharedKernel/Domain/UserId.php b/src/Application/SharedKernel/Domain/EntityId/PlayerId.php similarity index 64% rename from src/Application/SharedKernel/Domain/UserId.php rename to src/Application/SharedKernel/Domain/EntityId/PlayerId.php index 599ab36..f2c5981 100644 --- a/src/Application/SharedKernel/Domain/UserId.php +++ b/src/Application/SharedKernel/Domain/EntityId/PlayerId.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace TheGame\Application\SharedKernel\Domain; +namespace TheGame\Application\SharedKernel\Domain\EntityId; -final class UserId implements UserIdInterface +final class PlayerId implements PlayerIdInterface { public function __construct( private readonly string $id diff --git a/src/Application/SharedKernel/Domain/EntityId/PlayerIdInterface.php b/src/Application/SharedKernel/Domain/EntityId/PlayerIdInterface.php new file mode 100644 index 0000000..2f5edf3 --- /dev/null +++ b/src/Application/SharedKernel/Domain/EntityId/PlayerIdInterface.php @@ -0,0 +1,11 @@ + */ diff --git a/src/Application/SharedKernel/Domain/ResourcesInterface.php b/src/Application/SharedKernel/Domain/ResourcesInterface.php index e21ae3e..96c1ea5 100644 --- a/src/Application/SharedKernel/Domain/ResourcesInterface.php +++ b/src/Application/SharedKernel/Domain/ResourcesInterface.php @@ -4,6 +4,8 @@ namespace TheGame\Application\SharedKernel\Domain; +use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface; + interface ResourcesInterface { public function add(ResourcesInterface $resources): void; diff --git a/src/Application/SharedKernel/Domain/UserIdInterface.php b/src/Application/SharedKernel/Domain/UserIdInterface.php deleted file mode 100644 index 8ece966..0000000 --- a/src/Application/SharedKernel/Domain/UserIdInterface.php +++ /dev/null @@ -1,11 +0,0 @@ - Date: Sun, 10 Dec 2023 14:08:22 +0100 Subject: [PATCH 2/4] Introduce Galaxy and Player components --- .../Balance/Bridge/GalaxyContextInterface.php | 14 +++ .../Component/Galaxy/Bridge/Navigator.php | 74 ++++++++++++ .../Galaxy/Bridge/NavigatorInterface.php | 9 +- .../Component/Galaxy/Domain/Entity/Planet.php | 39 +++++++ .../Galaxy/Domain/Entity/SolarSystem.php | 107 ++++++++++++++++++ .../Event/PlanetHasBeenColonizedEvent.php | 27 +++++ .../PlanetAlreadyColonizedException.php | 25 ++++ .../Exception/PlanetNotColonizedException.php | 23 ++++ .../Galaxy/Domain/Factory/PlanetFactory.php | 30 +++++ .../Domain/Factory/PlanetFactoryInterface.php | 17 +++ .../Domain/Factory/SolarSystemFactory.php | 28 +++++ .../Factory/SolarSystemFactoryInterface.php | 15 +++ .../Component/Galaxy/Domain/SolarSystemId.php | 20 ++++ .../Galaxy/Domain/SolarSystemIdInterface.php | 12 ++ .../EventListener/ColonizePlanetListener.php | 61 ++++++++++ .../Galaxy/SolarSystemRepositoryInterface.php | 16 +++ .../Player/Bridge/PlayerContextInterface.php | 12 ++ .../Component/Player/Domain/Entity/Player.php | 10 ++ 18 files changed, 534 insertions(+), 5 deletions(-) create mode 100644 src/Application/Component/Balance/Bridge/GalaxyContextInterface.php create mode 100644 src/Application/Component/Galaxy/Bridge/Navigator.php create mode 100644 src/Application/Component/Galaxy/Domain/Entity/Planet.php create mode 100644 src/Application/Component/Galaxy/Domain/Entity/SolarSystem.php create mode 100644 src/Application/Component/Galaxy/Domain/Event/PlanetHasBeenColonizedEvent.php create mode 100644 src/Application/Component/Galaxy/Domain/Exception/PlanetAlreadyColonizedException.php create mode 100644 src/Application/Component/Galaxy/Domain/Exception/PlanetNotColonizedException.php create mode 100644 src/Application/Component/Galaxy/Domain/Factory/PlanetFactory.php create mode 100644 src/Application/Component/Galaxy/Domain/Factory/PlanetFactoryInterface.php create mode 100644 src/Application/Component/Galaxy/Domain/Factory/SolarSystemFactory.php create mode 100644 src/Application/Component/Galaxy/Domain/Factory/SolarSystemFactoryInterface.php create mode 100644 src/Application/Component/Galaxy/Domain/SolarSystemId.php create mode 100644 src/Application/Component/Galaxy/Domain/SolarSystemIdInterface.php create mode 100644 src/Application/Component/Galaxy/EventListener/ColonizePlanetListener.php create mode 100644 src/Application/Component/Galaxy/SolarSystemRepositoryInterface.php create mode 100644 src/Application/Component/Player/Bridge/PlayerContextInterface.php create mode 100644 src/Application/Component/Player/Domain/Entity/Player.php diff --git a/src/Application/Component/Balance/Bridge/GalaxyContextInterface.php b/src/Application/Component/Balance/Bridge/GalaxyContextInterface.php new file mode 100644 index 0000000..04f3e24 --- /dev/null +++ b/src/Application/Component/Balance/Bridge/GalaxyContextInterface.php @@ -0,0 +1,14 @@ +solarSystemRepository->findByGalaxyPoint($galaxyPoint); + + return $solarSystem->getPlanetId($galaxyPoint->getPlanet()); + } + + public function getPlanetPosition(PlanetIdInterface $planetId): int + { + $solarSystem = $this->solarSystemRepository->findByPlanetId($planetId); + + return $solarSystem->getPlanetPosition($planetId); + } + + public function isWithinBoundaries(GalaxyPointInterface $galaxyPoint): bool + { + if ($galaxyPoint->getGalaxy() < 1 || $galaxyPoint->getSolarSystem() < 1 || $galaxyPoint->getPlanet() < 1) { + return false; + } + + return $this->galaxyContext->getMaxGalaxyNumber() >= $galaxyPoint->getGalaxy() + && $this->galaxyContext->getMaxSolarSystem() >= $galaxyPoint->getSolarSystem() + && $this->galaxyContext->getMaxPlanetPosition() >= $galaxyPoint->getSolarSystem(); + } + + public function isMissionEligible( + FleetMissionType $missionType, + GalaxyPointInterface $planetFrom, + GalaxyPointInterface $planetTo + ): bool { + $startingSolarSystem = $this->solarSystemRepository->findByGalaxyPoint($planetFrom); + $targetSolarSystem = $this->solarSystemRepository->findByGalaxyPoint($planetTo); + + $startPlanetOwner = $startingSolarSystem->getPlayerId($planetFrom->getPlanet()); + $targetPlanetOwner = $targetSolarSystem->getPlayerId($planetTo->getPlanet()); + $samePlayerOwnsPlanets = $startPlanetOwner->getUuid() === $targetPlanetOwner->getUuid(); + + if ($missionType === FleetMissionType::Attack && $samePlayerOwnsPlanets) { + return false; + } + + $isTargetColonized = $targetSolarSystem->isColonized($planetTo->getPlanet()); + if ($missionType === FleetMissionType::Colonization && $isTargetColonized) { + return false; + } + + if ($missionType === FleetMissionType::Stationing && $samePlayerOwnsPlanets === false) { + return false; + } + + return true; + } +} diff --git a/src/Application/Component/Galaxy/Bridge/NavigatorInterface.php b/src/Application/Component/Galaxy/Bridge/NavigatorInterface.php index 2ca36ae..024aee4 100644 --- a/src/Application/Component/Galaxy/Bridge/NavigatorInterface.php +++ b/src/Application/Component/Galaxy/Bridge/NavigatorInterface.php @@ -4,21 +4,20 @@ namespace TheGame\Application\Component\Galaxy\Bridge; +use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; -use TheGame\Application\SharedKernel\Domain\PlanetIdInterface; +use TheGame\Application\SharedKernel\Domain\FleetMissionType; interface NavigatorInterface { public function getPlanetId(GalaxyPointInterface $galaxyPoint): ?PlanetIdInterface; - public function getPlanetPoint(PlanetIdInterface $planetId): GalaxyPointInterface; + public function getPlanetPosition(PlanetIdInterface $planetId): int; public function isWithinBoundaries(GalaxyPointInterface $galaxyPoint): bool; - public function isColonized(GalaxyPointInterface $galaxyPoint): bool; - public function isMissionEligible( - string $missionType, + FleetMissionType $missionType, GalaxyPointInterface $planetFrom, GalaxyPointInterface $planetTo, ): bool; diff --git a/src/Application/Component/Galaxy/Domain/Entity/Planet.php b/src/Application/Component/Galaxy/Domain/Entity/Planet.php new file mode 100644 index 0000000..04ebdcc --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/Entity/Planet.php @@ -0,0 +1,39 @@ +planetId; + } + + public function getPlayerId(): PlayerIdInterface + { + return $this->playerId; + } + + public function isOnPosition(int $position): bool + { + return $this->position === $position; + } + + public function getPosition(): int + { + return $this->position; + } +} diff --git a/src/Application/Component/Galaxy/Domain/Entity/SolarSystem.php b/src/Application/Component/Galaxy/Domain/Entity/SolarSystem.php new file mode 100644 index 0000000..7813593 --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/Entity/SolarSystem.php @@ -0,0 +1,107 @@ +solarSystemId; + } + + public function getGalaxyNumber(): int + { + return $this->galaxyNumber; + } + + public function getSolarSystemNumber(): int + { + return $this->solarSystemNumber; + } + + public function getPlayerId(int $planetPosition): PlayerIdInterface + { + foreach ($this->planets as $planet) { + if ($planet->isOnPosition($planetPosition)) { + return $planet->getPlayerId(); + } + } + + throw new PlanetNotColonizedException( + new GalaxyPoint($this->galaxyNumber, $this->solarSystemNumber, $planetPosition) + ); + } + + public function getPlanetId(int $planetPosition): PlanetIdInterface + { + foreach ($this->planets as $planet) { + if ($planet->isOnPosition($planetPosition)) { + return $planet->getId(); + } + } + + throw new PlanetNotColonizedException( + new GalaxyPoint($this->galaxyNumber, $this->solarSystemNumber, $planetPosition) + ); + } + + public function getPlanetPosition(PlanetIdInterface $planetId): int + { + foreach ($this->planets as $planet) { + if ($planet->getId()->getUuid() === $planetId->getUuid()) { + return $planet->getPosition(); + } + } + + throw new PlanetNotColonizedException( + new GalaxyPoint($this->galaxyNumber, $this->solarSystemNumber, $planetPosition) + ); + } + + public function isColonized(int $planetPosition): bool + { + foreach ($this->planets as $planet) { + if ($planet->isOnPosition($planetPosition)) { + return true; + } + } + + return false; + } + + public function colonize(Planet $planetToColonize): void + { + foreach ($this->planets as $planet) { + if ($planet->isOnPosition($planetToColonize->getPosition())) { + throw new PlanetAlreadyColonizedException( + new GalaxyPoint( + $this->galaxyNumber, $this->solarSystemNumber, $planetToColonize->getPosition(), + ), + $planetToColonize->getPlayerId() + ); + } + } + + $this->planets[] = $planetToColonize; + } +} diff --git a/src/Application/Component/Galaxy/Domain/Event/PlanetHasBeenColonizedEvent.php b/src/Application/Component/Galaxy/Domain/Event/PlanetHasBeenColonizedEvent.php new file mode 100644 index 0000000..fcb53c8 --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/Event/PlanetHasBeenColonizedEvent.php @@ -0,0 +1,27 @@ +playerId; + } + + public function getCoordinates(): string + { + return $this->coordinates; + } +} diff --git a/src/Application/Component/Galaxy/Domain/Exception/PlanetAlreadyColonizedException.php b/src/Application/Component/Galaxy/Domain/Exception/PlanetAlreadyColonizedException.php new file mode 100644 index 0000000..9fec025 --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/Exception/PlanetAlreadyColonizedException.php @@ -0,0 +1,25 @@ +getUuid(), + $galaxyPoint->format(), + ); + + parent::__construct($message); + } +} diff --git a/src/Application/Component/Galaxy/Domain/Exception/PlanetNotColonizedException.php b/src/Application/Component/Galaxy/Domain/Exception/PlanetNotColonizedException.php new file mode 100644 index 0000000..d264987 --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/Exception/PlanetNotColonizedException.php @@ -0,0 +1,23 @@ +format(), + ); + + parent::__construct($message); + } +} diff --git a/src/Application/Component/Galaxy/Domain/Factory/PlanetFactory.php b/src/Application/Component/Galaxy/Domain/Factory/PlanetFactory.php new file mode 100644 index 0000000..92d709d --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/Factory/PlanetFactory.php @@ -0,0 +1,30 @@ +uuidGenerator->generateNewPlanetId(), + $playerId, + $galaxyPoint->getPlanet(), + ); + } +} diff --git a/src/Application/Component/Galaxy/Domain/Factory/PlanetFactoryInterface.php b/src/Application/Component/Galaxy/Domain/Factory/PlanetFactoryInterface.php new file mode 100644 index 0000000..082aa87 --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/Factory/PlanetFactoryInterface.php @@ -0,0 +1,17 @@ +uuidGenerator->generateNewSolarSystemId(), + $galaxyNumber, + $solarSystemNumber, + ); + } +} diff --git a/src/Application/Component/Galaxy/Domain/Factory/SolarSystemFactoryInterface.php b/src/Application/Component/Galaxy/Domain/Factory/SolarSystemFactoryInterface.php new file mode 100644 index 0000000..58e3af1 --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/Factory/SolarSystemFactoryInterface.php @@ -0,0 +1,15 @@ +id; + } +} diff --git a/src/Application/Component/Galaxy/Domain/SolarSystemIdInterface.php b/src/Application/Component/Galaxy/Domain/SolarSystemIdInterface.php new file mode 100644 index 0000000..cb84c69 --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/SolarSystemIdInterface.php @@ -0,0 +1,12 @@ +getMission() !== FleetMissionType::Colonization->value) { + return; + } + + $targetPoint = GalaxyPoint::fromString($event->getTargetGalaxyPoint()); + + $solarSystem = $this->solarSystemRepository->findByGalaxyPoint($targetPoint); + if ($solarSystem === null) { + $solarSystem = $this->solarSystemFactory->create( + $targetPoint->getGalaxy(), + $targetPoint->getSolarSystem() + ); + } + + $playerId = $this->playerContext->getCurrentPlayerId(); + if ($solarSystem->isColonized($targetPoint->getPlanet()) === true) { + throw new PlanetAlreadyColonizedException($targetPoint, $playerId); + } + + $planet = $this->planetFactory->create($playerId, $targetPoint); + $solarSystem->colonize($planet); + + $this->eventBus->dispatch( + new PlanetHasBeenColonizedEvent( + $playerId->getUuid(), + $event->getTargetGalaxyPoint(), + ) + ); + } +} diff --git a/src/Application/Component/Galaxy/SolarSystemRepositoryInterface.php b/src/Application/Component/Galaxy/SolarSystemRepositoryInterface.php new file mode 100644 index 0000000..2874e46 --- /dev/null +++ b/src/Application/Component/Galaxy/SolarSystemRepositoryInterface.php @@ -0,0 +1,16 @@ + Date: Sun, 10 Dec 2023 22:17:55 +0100 Subject: [PATCH 3/4] Add ShipClass enumeration --- .../Bridge/FleetJourneyContextInterface.php | 2 ++ .../StartJourneyCommandHandler.php | 28 ++++++++++++++++--- .../FleetJourney/Domain/Entity/Fleet.php | 12 ++++++++ .../Domain/MissionEligibilityChecker.php | 23 +++++++++++++++ .../MissionEligibilityCheckerInterface.php | 16 +++++++++++ .../FleetJourney/Domain/ShipClass.php | 14 ++++++++++ .../FleetJourney/Domain/ShipsGroup.php | 13 +++++++-- .../Domain/ShipsGroupInterface.php | 2 ++ ...lyConstructedShipsToFleetEventListener.php | 3 ++ 9 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 src/Application/Component/FleetJourney/Domain/MissionEligibilityChecker.php create mode 100644 src/Application/Component/FleetJourney/Domain/MissionEligibilityCheckerInterface.php create mode 100644 src/Application/Component/FleetJourney/Domain/ShipClass.php diff --git a/src/Application/Component/Balance/Bridge/FleetJourneyContextInterface.php b/src/Application/Component/Balance/Bridge/FleetJourneyContextInterface.php index 2bf8717..ec77012 100644 --- a/src/Application/Component/Balance/Bridge/FleetJourneyContextInterface.php +++ b/src/Application/Component/Balance/Bridge/FleetJourneyContextInterface.php @@ -9,6 +9,8 @@ interface FleetJourneyContextInterface { + public function getShipClass(string $shipName): string; + public function getShipBaseSpeed(string $shipName): int; public function getShipLoadCapacity(string $shipName): int; diff --git a/src/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandler.php b/src/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandler.php index 2611f3b..d7d8a30 100644 --- a/src/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandler.php +++ b/src/Application/Component/FleetJourney/CommandHandler/StartJourneyCommandHandler.php @@ -6,15 +6,18 @@ use TheGame\Application\Component\Balance\Bridge\FleetJourneyContextInterface; use TheGame\Application\Component\FleetJourney\Command\StartJourneyCommand; +use TheGame\Application\Component\FleetJourney\Domain\Entity\Fleet; use TheGame\Application\Component\FleetJourney\Domain\Event\FleetHasStartedJourneyEvent; use TheGame\Application\Component\FleetJourney\Domain\Exception\CannotTakeJourneyToOutOfBoundGalaxyPointException; use TheGame\Application\Component\FleetJourney\Domain\Exception\JourneyMissionIsNotEligibleException; use TheGame\Application\Component\FleetJourney\Domain\Factory\JourneyFactoryInterface; +use TheGame\Application\Component\FleetJourney\Domain\MissionEligibilityCheckerInterface; use TheGame\Application\Component\FleetJourney\FleetResolverInterface; use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface; use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId; use TheGame\Application\SharedKernel\Domain\GalaxyPoint; use TheGame\Application\SharedKernel\Domain\FleetMissionType; +use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; use TheGame\Application\SharedKernel\Domain\Resources; use TheGame\Application\SharedKernel\EventBusInterface; @@ -22,6 +25,7 @@ final class StartJourneyCommandHandler { public function __construct( private readonly NavigatorInterface $galaxyNavigator, + private readonly MissionEligibilityCheckerInterface $missionEligibilityChecker, private readonly FleetResolverInterface $fleetResolver, private readonly JourneyFactoryInterface $journeyFactory, private readonly FleetJourneyContextInterface $journeyContext, @@ -45,10 +49,8 @@ public function __invoke(StartJourneyCommand $command): void $startGalaxyPoint = $fleetTakingJourney->getStationingGalaxyPoint(); $missionType = FleetMissionType::from($command->getMissionType()); - $isMissionEligible = $this->galaxyNavigator->isMissionEligible( - $missionType, - $startGalaxyPoint, - $targetGalaxyPoint, + $isMissionEligible = $this->isMissionEligible( + $missionType, $startGalaxyPoint, $targetGalaxyPoint, $fleetTakingJourney, ); if ($isMissionEligible === false) { throw new JourneyMissionIsNotEligibleException($missionType, $targetGalaxyPoint); @@ -84,4 +86,22 @@ public function __invoke(StartJourneyCommand $command): void ) ); } + + private function isMissionEligible( + FleetMissionType $missionType, + GalaxyPointInterface $startGalaxyPoint, + GalaxyPointInterface $targetGalaxyPoint, + Fleet $fleet, + ): bool { + $galaxyMissionEligible = $this->$this->galaxyNavigator->isMissionEligible( + $missionType, + $startGalaxyPoint, + $targetGalaxyPoint, + ); + $fleetMissionEligible = $this->missionEligibilityChecker->isEligible( + $missionType, $fleet, + ); + + return $galaxyMissionEligible && $fleetMissionEligible; + } } diff --git a/src/Application/Component/FleetJourney/Domain/Entity/Fleet.php b/src/Application/Component/FleetJourney/Domain/Entity/Fleet.php index 92f8ac9..9096db6 100644 --- a/src/Application/Component/FleetJourney/Domain/Entity/Fleet.php +++ b/src/Application/Component/FleetJourney/Domain/Entity/Fleet.php @@ -11,6 +11,7 @@ use TheGame\Application\Component\FleetJourney\Domain\Exception\NotEnoughFleetLoadCapacityException; use TheGame\Application\Component\FleetJourney\Domain\Exception\NotEnoughShipsException; use TheGame\Application\Component\FleetJourney\Domain\FleetIdInterface; +use TheGame\Application\Component\FleetJourney\Domain\ShipClass; use TheGame\Application\Component\FleetJourney\Domain\ShipsGroupInterface; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; use TheGame\Application\SharedKernel\Domain\FleetMissionType; @@ -49,6 +50,17 @@ public function merge(Fleet $fleet): void $this->addShips($fleet->ships); } + public function containsShipsOfClass(ShipClass $class): bool + { + foreach ($this->ships as $shipsGroup) { + if ($shipsGroup->getShipClass() === $class) { + return $shipsGroup->getQuantity() > 0; + } + } + + return false; + } + /** @param array $ships */ public function addShips(array $ships): void { diff --git a/src/Application/Component/FleetJourney/Domain/MissionEligibilityChecker.php b/src/Application/Component/FleetJourney/Domain/MissionEligibilityChecker.php new file mode 100644 index 0000000..cd15cc8 --- /dev/null +++ b/src/Application/Component/FleetJourney/Domain/MissionEligibilityChecker.php @@ -0,0 +1,23 @@ +containsShipsOfClass(ShipClass::Colonization); + if ($missionType === FleetMissionType::Colonization && $containsColonizationShip === false) { + return false; + } + + return true; + } +} diff --git a/src/Application/Component/FleetJourney/Domain/MissionEligibilityCheckerInterface.php b/src/Application/Component/FleetJourney/Domain/MissionEligibilityCheckerInterface.php new file mode 100644 index 0000000..81b65c3 --- /dev/null +++ b/src/Application/Component/FleetJourney/Domain/MissionEligibilityCheckerInterface.php @@ -0,0 +1,16 @@ +shipName; } + public function getShipClass(): ShipClass + { + return $this->shipClass; + } + public function getQuantity(): int { return $this->quantity; @@ -62,6 +68,7 @@ public function split(int $quantity): ShipsGroupInterface return new ShipsGroup( $this->shipName, + $this->shipClass, $quantity, $this->speed, $this->unitLoadCapacity, diff --git a/src/Application/Component/FleetJourney/Domain/ShipsGroupInterface.php b/src/Application/Component/FleetJourney/Domain/ShipsGroupInterface.php index 25323cb..947f2d2 100644 --- a/src/Application/Component/FleetJourney/Domain/ShipsGroupInterface.php +++ b/src/Application/Component/FleetJourney/Domain/ShipsGroupInterface.php @@ -8,6 +8,8 @@ interface ShipsGroupInterface { public function getShipName(): string; + public function getShipClass(): ShipClass; + public function getQuantity(): int; public function hasShip(string $name): bool; diff --git a/src/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListener.php b/src/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListener.php index f1cdc80..2ff8732 100644 --- a/src/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListener.php +++ b/src/Application/Component/FleetJourney/EventListener/AddNewlyConstructedShipsToFleetEventListener.php @@ -6,6 +6,7 @@ use TheGame\Application\Component\Balance\Bridge\FleetJourneyContextInterface; use TheGame\Application\Component\FleetJourney\Domain\Factory\FleetFactoryInterface; +use TheGame\Application\Component\FleetJourney\Domain\ShipClass; use TheGame\Application\Component\FleetJourney\Domain\ShipsGroup; use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface; use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface; @@ -36,9 +37,11 @@ public function __invoke(NewShipsHaveBeenConstructedEvent $event): void } $shipName = $event->getName(); + $shipClass = $this->fleetJourneyContext->getShipClass($shipName); $fleetCurrentlyStationingOnPlanet->addShips([ new ShipsGroup( $shipName, + ShipClass::from($shipClass), $event->getQuantity(), $this->fleetJourneyContext->getShipBaseSpeed($shipName), $this->fleetJourneyContext->getShipLoadCapacity($shipName), From 0c2fc176378a7f13012aa8ae5e22500fd3ffba2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Mon, 11 Dec 2023 09:19:41 +0100 Subject: [PATCH 4/4] Generate planet stats during colonization process --- .../Component/Galaxy/Domain/Entity/Planet.php | 7 ++ .../Galaxy/Domain/Factory/PlanetFactory.php | 9 ++- .../Domain/Factory/PlanetFactoryInterface.php | 1 + .../Component/Galaxy/Domain/PlanetBiome.php | 18 +++++ .../Component/Galaxy/Domain/PlanetStats.php | 36 ++++++++++ .../Galaxy/Domain/PlanetStatsRandomizer.php | 71 +++++++++++++++++++ .../Domain/PlanetStatsRandomizerInterface.php | 10 +++ .../EventListener/ColonizePlanetListener.php | 5 +- 8 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 src/Application/Component/Galaxy/Domain/PlanetBiome.php create mode 100644 src/Application/Component/Galaxy/Domain/PlanetStats.php create mode 100644 src/Application/Component/Galaxy/Domain/PlanetStatsRandomizer.php create mode 100644 src/Application/Component/Galaxy/Domain/PlanetStatsRandomizerInterface.php diff --git a/src/Application/Component/Galaxy/Domain/Entity/Planet.php b/src/Application/Component/Galaxy/Domain/Entity/Planet.php index 04ebdcc..4491e92 100644 --- a/src/Application/Component/Galaxy/Domain/Entity/Planet.php +++ b/src/Application/Component/Galaxy/Domain/Entity/Planet.php @@ -4,6 +4,7 @@ namespace TheGame\Application\Component\Galaxy\Domain\Entity; +use TheGame\Application\Component\Galaxy\Domain\PlanetStats; use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface; use TheGame\Application\SharedKernel\Domain\EntityId\PlayerIdInterface; @@ -12,6 +13,7 @@ class Planet public function __construct( protected readonly PlanetIdInterface $planetId, protected readonly PlayerIdInterface $playerId, + protected readonly PlanetStats $planetStats, protected readonly int $position, ) { @@ -36,4 +38,9 @@ public function getPosition(): int { return $this->position; } + + public function getStats(): PlanetStats + { + return $this->planetStats; + } } diff --git a/src/Application/Component/Galaxy/Domain/Factory/PlanetFactory.php b/src/Application/Component/Galaxy/Domain/Factory/PlanetFactory.php index 92d709d..080bfd7 100644 --- a/src/Application/Component/Galaxy/Domain/Factory/PlanetFactory.php +++ b/src/Application/Component/Galaxy/Domain/Factory/PlanetFactory.php @@ -5,6 +5,8 @@ namespace TheGame\Application\Component\Galaxy\Domain\Factory; use TheGame\Application\Component\Galaxy\Domain\Entity\Planet; +use TheGame\Application\Component\Galaxy\Domain\PlanetStatsRandomizer; +use TheGame\Application\Component\Galaxy\Domain\PlanetStatsRandomizerInterface; use TheGame\Application\SharedKernel\Domain\EntityId\PlayerIdInterface; use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface; use TheGame\Application\SharedKernel\UuidGeneratorInterface; @@ -13,6 +15,7 @@ final class PlanetFactory implements PlanetFactoryInterface { public function __construct( private readonly UuidGeneratorInterface $uuidGenerator, + private readonly PlanetStatsRandomizerInterface $planetStatsRandomizer, ) { } @@ -20,11 +23,15 @@ public function __construct( public function create( PlayerIdInterface $playerId, GalaxyPointInterface $galaxyPoint, + int $maxPlanetPosition, ): Planet { + $planetPosition = $galaxyPoint->getPlanet(); + return new Planet( $this->uuidGenerator->generateNewPlanetId(), $playerId, - $galaxyPoint->getPlanet(), + $this->planetStatsRandomizer->randomize($planetPosition, $maxPlanetPosition), + $planetPosition, ); } } diff --git a/src/Application/Component/Galaxy/Domain/Factory/PlanetFactoryInterface.php b/src/Application/Component/Galaxy/Domain/Factory/PlanetFactoryInterface.php index 082aa87..a69efbe 100644 --- a/src/Application/Component/Galaxy/Domain/Factory/PlanetFactoryInterface.php +++ b/src/Application/Component/Galaxy/Domain/Factory/PlanetFactoryInterface.php @@ -13,5 +13,6 @@ interface PlanetFactoryInterface public function create( PlayerIdInterface $playerId, GalaxyPointInterface $galaxyPoint, + int $maxPlanetPosition, ): Planet; } diff --git a/src/Application/Component/Galaxy/Domain/PlanetBiome.php b/src/Application/Component/Galaxy/Domain/PlanetBiome.php new file mode 100644 index 0000000..1f97547 --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/PlanetBiome.php @@ -0,0 +1,18 @@ +biome; + } + + public function getSize(): int + { + return $this->size; + } + + public function getMinTemperature(): int + { + return $this->minTemperature; + } + + public function getMaxTemperature(): int + { + return $this->maxTemperature; + } +} diff --git a/src/Application/Component/Galaxy/Domain/PlanetStatsRandomizer.php b/src/Application/Component/Galaxy/Domain/PlanetStatsRandomizer.php new file mode 100644 index 0000000..1937f44 --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/PlanetStatsRandomizer.php @@ -0,0 +1,71 @@ +randomizeFieldsNumber($planetPosition, $maxPosition); + [$minTemperature, $maxTemperature] = $this->randomizeTemperature($planetPosition, $maxPosition); + + return new PlanetStats( + $biome, $fieldsNumber, $minTemperature, $maxTemperature + ); + } + + private function randomizeFieldsNumber(int $planetPosition, int $maxPosition): int + { + $pivot = $planetPosition / $maxPosition; + $statsMetadata = [ + [0.15, 45, 95], + [0.3, 45, 120], + [0.4, 120, 165], + [0.6, 120, 185], + [0.8, 150, 185], + [0.9, 185, 265], + [1.0, 235, 265], + ]; + + $minFieldsNumber = $maxFieldsNumber = 0; + foreach ($statsMetadata as $metadata) { + $pivotBound = $metadata[0]; + $minFieldsNumberBound = $metadata[1]; + $maxFieldsNumberBound = $metadata[2]; + + if ($pivot < $pivotBound) { + $minFieldsNumber = $minFieldsNumberBound; + $maxFieldsNumber = $maxFieldsNumberBound; + break; + } + } + + return rand($minFieldsNumber, $maxFieldsNumber); + } + + /** @return int[] */ + private function randomizeTemperature(int $planetPosition, int $maxPosition): array + { + $minPivot = ($planetPosition / $maxPosition) * 100; + $maxPivot = 100; + + $lowerBounds = [-45, 145]; + $higherBounds = [-5, 275]; + + $randPivot = rand($minPivot, $maxPivot) / 100; + $lowerTemperature = $lowerBounds[0] + $randPivot * $lowerBounds[1]-$lowerBounds[0]; + + $randPivot = rand($minPivot, $maxPivot) / 100; + $higherTemperature = $higherBounds[0] + $randPivot * $higherBounds[1]-$higherBounds[0]; + + if ($lowerTemperature > $higherTemperature) { + return [$higherTemperature, $lowerTemperature]; + } + + return [$lowerTemperature, $higherTemperature]; + } +} diff --git a/src/Application/Component/Galaxy/Domain/PlanetStatsRandomizerInterface.php b/src/Application/Component/Galaxy/Domain/PlanetStatsRandomizerInterface.php new file mode 100644 index 0000000..1c0b252 --- /dev/null +++ b/src/Application/Component/Galaxy/Domain/PlanetStatsRandomizerInterface.php @@ -0,0 +1,10 @@ +planetFactory->create($playerId, $targetPoint); + $maxPlanetPosition = $this->galaxyContext->getMaxPlanetPosition(); + $planet = $this->planetFactory->create($playerId, $targetPoint, $maxPlanetPosition); $solarSystem->colonize($planet); $this->eventBus->dispatch(