Skip to content

Commit

Permalink
Moving transformers around
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKyle committed Oct 23, 2024
1 parent 58d41d8 commit e2c720c
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 44 deletions.
2 changes: 1 addition & 1 deletion app/Admin/Jobs/UpdateKingdomBuilding.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/Flare/Jobs/MergeDuplicateKingdomUnits.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions app/Flare/Providers/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -468,7 +468,7 @@ public function register()
);
});

$this->app->bind(SiteAccessStatisticService::class, function() {
$this->app->bind(SiteAccessStatisticService::class, function () {
return new SiteAccessStatisticService();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
];
}
Expand Down Expand Up @@ -422,7 +422,7 @@ public function fetchEquipped(): array
});

if ($index !== false) {
$this->inventorySetEquippedName = 'Set '.$index + 1;
$this->inventorySetEquippedName = 'Set ' . $index + 1;
}
}

Expand Down Expand Up @@ -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'),
],
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
],
Expand Down Expand Up @@ -735,15 +735,32 @@ 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.
if ($type === 'spell-damage' || $type === 'spell-healing') {
$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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions app/Game/Kingdoms/Providers/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/Game/Kingdoms/Service/KingdomQueueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions app/Game/Kingdoms/Service/UpdateKingdom.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Flare\Transformers;
namespace App\Game\Kingdoms\Transformers;

use App\Flare\Models\Character;
use App\Flare\Models\Kingdom;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Flare\Transformers;
namespace App\Game\Kingdoms\Transformers;

use App\Flare\Models\KingdomBuilding;
use App\Game\Kingdoms\Values\BuildingCosts;
Expand Down
2 changes: 1 addition & 1 deletion app/Game/Kingdoms/Transformers/KingdomTableTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Flare\Models\Kingdom;
use App\Flare\Models\UnitMovementQueue;
use App\Flare\Transformers\UnitMovementTransformer;
use App\Game\Kingdoms\Transformers\UnitMovementTransformer;
use League\Fractal\Resource\Collection;
use League\Fractal\TransformerAbstract;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Flare\Transformers;
namespace App\Game\Kingdoms\Transformers;

use App\Flare\Models\GameUnit;
use App\Flare\Models\Kingdom;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Flare\Transformers;
namespace App\Game\Kingdoms\Transformers;

use App\Flare\Models\Kingdom;
use App\Game\Kingdoms\Values\KingdomMaxValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Flare\Transformers;
namespace App\Game\Kingdoms\Transformers;

use App\Flare\Models\Kingdom;
use App\Flare\Models\UnitMovementQueue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Flare\Transformers;
namespace App\Game\Kingdoms\Transformers;

use App\Flare\Models\GameBuildingUnit;
use App\Flare\Models\GameUnit;
Expand Down Expand Up @@ -51,7 +51,7 @@ protected function getRequiredBuildingLevel(GameUnit $unit): int
$gameBuilding = GameBuildingUnit::where('game_unit_id', $unit->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;
Expand Down
4 changes: 2 additions & 2 deletions app/Game/PassiveSkills/Jobs/TrainPassiveSkill.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit e2c720c

Please sign in to comment.