From e2c720c3599ec64d3e178625fed5dc06ea368425 Mon Sep 17 00:00:00 2001 From: Adam Balan Date: Wed, 23 Oct 2024 13:21:57 -0600 Subject: [PATCH] Moving transformers around --- app/Admin/Jobs/UpdateKingdomBuilding.php | 2 +- app/Flare/Jobs/MergeDuplicateKingdomUnits.php | 2 +- app/Flare/Providers/ServiceProvider.php | 12 +++--- .../Services/CharacterInventoryService.php | 43 +++++++++++++------ .../ResetCapitalCityWalkingStatus.php | 2 +- .../Api/KingdomInformationController.php | 6 +-- .../CapitalCityUpdateAutoWalkedKingdoms.php | 2 +- .../Kingdoms/Providers/ServiceProvider.php | 8 ++-- .../Kingdoms/Service/KingdomQueueService.php | 2 +- app/Game/Kingdoms/Service/UpdateKingdom.php | 7 +-- .../KingdomAttackLogsTransformer.php | 2 +- .../KingdomBuildingTransformer.php | 2 +- .../Transformers/KingdomTableTransformer.php | 2 +- .../Transformers/KingdomTransformer.php | 2 +- .../Transformers/OtherKingdomTransformer.php | 2 +- .../Transformers/UnitMovementTransformer.php | 2 +- .../Transformers/UnitTransformer.php | 4 +- .../PassiveSkills/Jobs/TrainPassiveSkill.php | 4 +- 18 files changed, 62 insertions(+), 44 deletions(-) rename app/{Flare => Game/Kingdoms}/Transformers/KingdomAttackLogsTransformer.php (99%) rename app/{Flare => Game/Kingdoms}/Transformers/KingdomBuildingTransformer.php (98%) rename app/{Flare => Game/Kingdoms}/Transformers/KingdomTransformer.php (99%) rename app/{Flare => Game/Kingdoms}/Transformers/OtherKingdomTransformer.php (96%) rename app/{Flare => Game/Kingdoms}/Transformers/UnitMovementTransformer.php (98%) rename app/{Flare => Game/Kingdoms}/Transformers/UnitTransformer.php (97%) diff --git a/app/Admin/Jobs/UpdateKingdomBuilding.php b/app/Admin/Jobs/UpdateKingdomBuilding.php index 661d1fc6c..452a157c2 100755 --- a/app/Admin/Jobs/UpdateKingdomBuilding.php +++ b/app/Admin/Jobs/UpdateKingdomBuilding.php @@ -4,7 +4,7 @@ use App\Flare\Models\GameBuilding; use App\Flare\Models\KingdomBuilding; -use App\Flare\Transformers\KingdomTransformer; +use App\Game\Kingdoms\Transformers\KingdomTransformer; use App\Game\Kingdoms\Events\UpdateKingdom; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; diff --git a/app/Flare/Jobs/MergeDuplicateKingdomUnits.php b/app/Flare/Jobs/MergeDuplicateKingdomUnits.php index a14004d57..d7cbcd579 100755 --- a/app/Flare/Jobs/MergeDuplicateKingdomUnits.php +++ b/app/Flare/Jobs/MergeDuplicateKingdomUnits.php @@ -4,7 +4,7 @@ use App\Flare\Models\GameUnit; use App\Flare\Models\Kingdom; -use App\Flare\Transformers\KingdomTransformer; +use App\Game\Kingdoms\Transformers\KingdomTransformer; use App\Game\Kingdoms\Events\UpdateKingdom; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; diff --git a/app/Flare/Providers/ServiceProvider.php b/app/Flare/Providers/ServiceProvider.php index 82bdefe5b..71c64018b 100755 --- a/app/Flare/Providers/ServiceProvider.php +++ b/app/Flare/Providers/ServiceProvider.php @@ -68,13 +68,13 @@ use App\Flare\Transformers\CharacterSheetBaseInfoTransformer; use App\Flare\Transformers\InventoryTransformer; use App\Flare\Transformers\ItemTransformer; -use App\Flare\Transformers\KingdomAttackLogsTransformer; -use App\Flare\Transformers\KingdomBuildingTransformer; -use App\Flare\Transformers\KingdomTransformer; +use App\Game\Kingdoms\Transformers\KingdomAttackLogsTransformer; +use App\Game\Kingdoms\Transformers\KingdomBuildingTransformer; +use App\Game\Kingdoms\Transformers\KingdomTransformer; use App\Flare\Transformers\MarketItemsTransformer; use App\Flare\Transformers\MonsterTransformer; -use App\Flare\Transformers\OtherKingdomTransformer; -use App\Flare\Transformers\UnitTransformer; +use App\Game\Kingdoms\Transformers\OtherKingdomTransformer; +use App\Game\Kingdoms\Transformers\UnitTransformer; use App\Flare\Transformers\UsableItemTransformer; use App\Flare\Values\BaseSkillValue; use App\Flare\Values\BaseStatValue; @@ -468,7 +468,7 @@ public function register() ); }); - $this->app->bind(SiteAccessStatisticService::class, function() { + $this->app->bind(SiteAccessStatisticService::class, function () { return new SiteAccessStatisticService(); }); } diff --git a/app/Game/Character/CharacterInventory/Services/CharacterInventoryService.php b/app/Game/Character/CharacterInventory/Services/CharacterInventoryService.php index a46600606..c8deb1d50 100755 --- a/app/Game/Character/CharacterInventory/Services/CharacterInventoryService.php +++ b/app/Game/Character/CharacterInventory/Services/CharacterInventoryService.php @@ -197,14 +197,14 @@ public function disenchantAllItems(Collection $slots, Character $character): arr $this->updateCharacterSkillsService->updateCharacterCraftingSkills($character->refresh()); - $message = 'Disenchanted all items and gained: '.($maxedOutGoldDust ? 0 .' (You are capped ) ' : number_format($totalGoldDust)).' Gold Dust (with gold dust rushes)'; + $message = 'Disenchanted all items and gained: ' . ($maxedOutGoldDust ? 0 . ' (You are capped ) ' : number_format($totalGoldDust)) . ' Gold Dust (with gold dust rushes)'; if ($totalDisenchantingLevels > 0) { - $message .= ' You also gained: '.$totalDisenchantingLevels.' Skill Levels in Disenchanting.'; + $message .= ' You also gained: ' . $totalDisenchantingLevels . ' Skill Levels in Disenchanting.'; } if ($totalEnchantingLevels > 0) { - $message .= ' You also gained: '.$totalEnchantingLevels.' Skill Levels in Enchanting.'; + $message .= ' You also gained: ' . $totalEnchantingLevels . ' Skill Levels in Enchanting.'; } return $this->successResult([ @@ -224,7 +224,7 @@ public function getCharacterInventorySets(): array $slots = new LeagueCollection($inventorySet->slots, $this->inventoryTransformer); if (is_null($inventorySet->name)) { - $sets['Set '.$index + 1] = [ + $sets['Set ' . $index + 1] = [ 'items' => array_reverse($this->manager->createData($slots)->toArray()), 'equippable' => $inventorySet->can_be_equipped, 'set_id' => $inventorySet->id, @@ -262,7 +262,7 @@ public function getEquippedInventorySetName(): ?string return $equippedSet->name; } - return 'Set '.$this->character->inventorySets->search(function ($set) use ($equippedSet) { + return 'Set ' . $this->character->inventorySets->search(function ($set) use ($equippedSet) { return $set->id === $equippedSet->id; }) + 1; } @@ -322,7 +322,7 @@ public function getUsableSets(): array $indexes[] = [ 'index' => array_search($id, $setIds) + 1, 'id' => $id, - 'name' => is_null($inventorySet->name) ? 'Set '.array_search($id, $setIds) + 1 : $inventorySet->name, + 'name' => is_null($inventorySet->name) ? 'Set ' . array_search($id, $setIds) + 1 : $inventorySet->name, 'equipped' => $inventorySet->is_equipped, ]; } @@ -422,7 +422,7 @@ public function fetchEquipped(): array }); if ($index !== false) { - $this->inventorySetEquippedName = 'Set '.$index + 1; + $this->inventorySetEquippedName = 'Set ' . $index + 1; } } @@ -522,7 +522,7 @@ public function deleteItem(int $slotId): array $this->character = $this->character->refresh(); return $this->successResult([ - 'message' => 'Destroyed '.$name.'.', + 'message' => 'Destroyed ' . $name . '.', 'inventory' => [ 'inventory' => $this->getInventoryForType('inventory'), ], @@ -610,7 +610,7 @@ public function unequipItem(int $inventorySlotId): array event(new UpdateTopBarEvent($character->refresh())); return $this->successResult([ - 'message' => 'Unequipped item: '.$foundItem->item->affix_name, + 'message' => 'Unequipped item: ' . $foundItem->item->affix_name, 'inventory' => [ 'inventory' => $this->getInventoryForType('inventory'), 'equipped' => $this->getInventoryForType('equipped'), @@ -680,7 +680,7 @@ public function destroyAlchemyItem(int $slotId): array event(new UpdateTopBarEvent($character)); return $this->successResult([ - 'message' => 'Destroyed Alchemy Item: '.$name.'.', + 'message' => 'Destroyed Alchemy Item: ' . $name . '.', 'inventory' => [ 'usable_items' => $this->getInventoryForType('usable_items'), ], @@ -735,8 +735,22 @@ protected function fetchType(string $type): string } $acceptedTypes = [ - 'weapon', 'ring', 'shield', 'artifact', 'spell', 'armour', - 'trinket', 'stave', 'hammer', 'bow', 'fan', 'scratch-awl', 'gun', 'mace', 'alchemy', 'quest', + 'weapon', + 'ring', + 'shield', + 'artifact', + 'spell', + 'armour', + 'trinket', + 'stave', + 'hammer', + 'bow', + 'fan', + 'scratch-awl', + 'gun', + 'mace', + 'alchemy', + 'quest', ]; // Spells do not have the tye spell - they are differentiated by damage or healing suffix. @@ -744,6 +758,9 @@ protected function fetchType(string $type): string $type = 'spell'; } - return ! in_array($type, $acceptedTypes) ? throw new Exception('Unknown Item type: '.$type) : $type; + if (!in_array($type, $acceptedTypes)) { + throw new Exception('Unknown Item type: ' . $type); + } + return $type; } } diff --git a/app/Game/Kingdoms/Console/Commands/ResetCapitalCityWalkingStatus.php b/app/Game/Kingdoms/Console/Commands/ResetCapitalCityWalkingStatus.php index 4b258d703..4e3cbd32e 100755 --- a/app/Game/Kingdoms/Console/Commands/ResetCapitalCityWalkingStatus.php +++ b/app/Game/Kingdoms/Console/Commands/ResetCapitalCityWalkingStatus.php @@ -3,7 +3,7 @@ namespace App\Game\Kingdoms\Console\Commands; use App\Flare\Models\Kingdom; -use App\Flare\Transformers\KingdomTransformer; +use App\Game\Kingdoms\Transformers\KingdomTransformer; use App\Game\Kingdoms\Jobs\CapitalCityUpdateAutoWalkedKingdoms; use Illuminate\Console\Command; use League\Fractal\Manager; diff --git a/app/Game/Kingdoms/Controllers/Api/KingdomInformationController.php b/app/Game/Kingdoms/Controllers/Api/KingdomInformationController.php index c4891a9b4..796044ce2 100755 --- a/app/Game/Kingdoms/Controllers/Api/KingdomInformationController.php +++ b/app/Game/Kingdoms/Controllers/Api/KingdomInformationController.php @@ -6,9 +6,9 @@ use App\Flare\Models\Kingdom; use App\Flare\Models\KingdomLog; use App\Flare\Transformers\BasicKingdomTransformer; -use App\Flare\Transformers\KingdomAttackLogsTransformer; -use App\Flare\Transformers\KingdomTransformer; -use App\Flare\Transformers\OtherKingdomTransformer; +use App\Game\Kingdoms\Transformers\KingdomAttackLogsTransformer; +use App\Game\Kingdoms\Transformers\KingdomTransformer; +use App\Game\Kingdoms\Transformers\OtherKingdomTransformer; use App\Game\Kingdoms\Service\UpdateKingdom; use App\Game\Kingdoms\Transformers\KingdomTableTransformer; use App\Http\Controllers\Controller; diff --git a/app/Game/Kingdoms/Jobs/CapitalCityUpdateAutoWalkedKingdoms.php b/app/Game/Kingdoms/Jobs/CapitalCityUpdateAutoWalkedKingdoms.php index ee66337a7..f63fcb797 100755 --- a/app/Game/Kingdoms/Jobs/CapitalCityUpdateAutoWalkedKingdoms.php +++ b/app/Game/Kingdoms/Jobs/CapitalCityUpdateAutoWalkedKingdoms.php @@ -3,7 +3,7 @@ namespace App\Game\Kingdoms\Jobs; use App\Flare\Models\Kingdom; -use App\Flare\Transformers\KingdomTransformer; +use App\Game\Kingdoms\Transformers\KingdomTransformer; use App\Game\Kingdoms\Events\UpdateKingdom; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; diff --git a/app/Game/Kingdoms/Providers/ServiceProvider.php b/app/Game/Kingdoms/Providers/ServiceProvider.php index c717f677a..1f080ceb0 100755 --- a/app/Game/Kingdoms/Providers/ServiceProvider.php +++ b/app/Game/Kingdoms/Providers/ServiceProvider.php @@ -3,10 +3,10 @@ namespace App\Game\Kingdoms\Providers; use App\Flare\Transformers\CapitalCityKingdomBuildingTransformer; -use App\Flare\Transformers\KingdomAttackLogsTransformer; -use App\Flare\Transformers\KingdomBuildingTransformer; -use App\Flare\Transformers\KingdomTransformer; -use App\Flare\Transformers\UnitMovementTransformer; +use App\Game\Kingdoms\Transformers\KingdomAttackLogsTransformer; +use App\Game\Kingdoms\Transformers\KingdomBuildingTransformer; +use App\Game\Kingdoms\Transformers\KingdomTransformer; +use App\Game\Kingdoms\Transformers\UnitMovementTransformer; use App\Game\Kingdoms\Builders\KingdomBuilder; use App\Game\Kingdoms\Console\Commands\DeleteKingdomLogs; use App\Game\Kingdoms\Console\Commands\ResetCapitalCityWalkingStatus; diff --git a/app/Game/Kingdoms/Service/KingdomQueueService.php b/app/Game/Kingdoms/Service/KingdomQueueService.php index 03cdbf0b9..120710dde 100644 --- a/app/Game/Kingdoms/Service/KingdomQueueService.php +++ b/app/Game/Kingdoms/Service/KingdomQueueService.php @@ -7,7 +7,7 @@ use App\Flare\Models\Kingdom; use App\Flare\Models\UnitInQueue; use App\Flare\Models\UnitMovementQueue; -use App\Flare\Transformers\UnitMovementTransformer; +use App\Game\Kingdoms\Transformers\UnitMovementTransformer; use App\Game\Core\Traits\ResponseBuilder; use League\Fractal\Manager; use League\Fractal\Resource\Collection; diff --git a/app/Game/Kingdoms/Service/UpdateKingdom.php b/app/Game/Kingdoms/Service/UpdateKingdom.php index 3aeab5ebf..d57075f11 100755 --- a/app/Game/Kingdoms/Service/UpdateKingdom.php +++ b/app/Game/Kingdoms/Service/UpdateKingdom.php @@ -5,8 +5,8 @@ use App\Flare\Models\Character; use App\Flare\Models\Kingdom; use App\Flare\Models\KingdomLog; -use App\Flare\Transformers\KingdomAttackLogsTransformer; -use App\Flare\Transformers\KingdomTransformer; +use App\Game\Kingdoms\Transformers\KingdomAttackLogsTransformer; +use App\Game\Kingdoms\Transformers\KingdomTransformer; use App\Game\Kingdoms\Events\UpdateKingdom as UpdateKingdomDetails; use App\Game\Kingdoms\Events\UpdateKingdomLogs; use App\Game\Kingdoms\Events\UpdateKingdomQueues; @@ -26,7 +26,8 @@ class UpdateKingdom private Manager $manager; - public function __construct(KingdomTransformer $kingdomTransformer, + public function __construct( + KingdomTransformer $kingdomTransformer, KingdomTableTransformer $kingdomTableTransformer, KingdomAttackLogsTransformer $kingdomAttackLogsTransformer, Manager $manager diff --git a/app/Flare/Transformers/KingdomAttackLogsTransformer.php b/app/Game/Kingdoms/Transformers/KingdomAttackLogsTransformer.php similarity index 99% rename from app/Flare/Transformers/KingdomAttackLogsTransformer.php rename to app/Game/Kingdoms/Transformers/KingdomAttackLogsTransformer.php index 95e9a8970..79cbb8085 100755 --- a/app/Flare/Transformers/KingdomAttackLogsTransformer.php +++ b/app/Game/Kingdoms/Transformers/KingdomAttackLogsTransformer.php @@ -1,6 +1,6 @@ id)->first(); if (is_null($gameBuilding)) { - throw new Exception('Missing Game Building for unit: '.$unit->name); + throw new Exception('Missing Game Building for unit: ' . $unit->name); } return $gameBuilding->required_level; diff --git a/app/Game/PassiveSkills/Jobs/TrainPassiveSkill.php b/app/Game/PassiveSkills/Jobs/TrainPassiveSkill.php index b3b050d68..c9fd0a7a2 100755 --- a/app/Game/PassiveSkills/Jobs/TrainPassiveSkill.php +++ b/app/Game/PassiveSkills/Jobs/TrainPassiveSkill.php @@ -5,7 +5,7 @@ use App\Flare\Models\Character; use App\Flare\Models\CharacterPassiveSkill; use App\Flare\Models\GameBuilding; -use App\Flare\Transformers\KingdomTransformer; +use App\Game\Kingdoms\Transformers\KingdomTransformer; use App\Game\Kingdoms\Events\UpdateKingdom; use App\Game\Messages\Events\ServerMessageEvent; use App\Game\PassiveSkills\Events\UpdatePassiveTree; @@ -147,7 +147,7 @@ public function handle(Manager $manager, KingdomTransformer $kingdomTransformer) $character = $this->character->Refresh(); - event(new ServerMessageEvent($character->user, $newPassive->passiveSkill->name.' skill has gained a new level! Check your character sheet!')); + event(new ServerMessageEvent($character->user, $newPassive->passiveSkill->name . ' skill has gained a new level! Check your character sheet!')); event(new UpdatePassiveTree($character->user, $character->passiveSkills)); }