Skip to content

Commit c198807

Browse files
committed
Fixed bountiful resources
1 parent 43dad23 commit c198807

File tree

8 files changed

+79
-12
lines changed

8 files changed

+79
-12
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace App\Console\AfterDeployment;
4+
5+
use App\Flare\Models\Kingdom;
6+
use App\Game\PassiveSkills\Values\PassiveSkillTypeValue;
7+
use Illuminate\Console\Command;
8+
9+
class FixKingdomMaxResourcesBasedOnPassiveSkill extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'fix:kingdom-max-resources-based-on-passive-skill';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = 'Fixes kingdoms to respect bountiful resources';
24+
25+
/**
26+
* Execute the console command.
27+
*/
28+
public function handle()
29+
{
30+
Kingdom::where('npc_owned', false)->chunk(500, function ($kingdoms) {
31+
foreach ($kingdoms as $kingdom) {
32+
$skill = $kingdom->character->passiveSkills->where('passiveSkill.effect_type', PassiveSkillTypeValue::RESOURCE_INCREASE)->first();
33+
34+
35+
if (is_null($skill)) {
36+
return;
37+
}
38+
39+
$kingdom->update([
40+
'max_stone' => $kingdom->max_stone + $skill->resource_increase_amount,
41+
'max_iron' => $kingdom->max_iron + $skill->resource_increase_amount,
42+
'max_wood' => $kingdom->max_wood + $skill->resource_increase_amount,
43+
'max_clay' => $kingdom->max_clas + $skill->resource_increase_amount,
44+
'max_population' => $kingdom->max_population + $skill->resource_increase_amount,
45+
]);
46+
}
47+
});
48+
}
49+
}

app/Flare/GameImporter/Console/Commands/MassImportCustomData.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function handle()
5656
Artisan::call('create:quest-cache');
5757
Artisan::call('generate:monster-cache');
5858
Artisan::call('create:location-data-cache');
59+
Artisan::call('fix:kingdom-max-resources-based-on-passive-skill');
5960

6061
$this->importInformationSection();
6162

app/Flare/Models/CharacterPassiveSkill.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class CharacterPassiveSkill extends Model
4141
'is_max_level',
4242
'current_bonus',
4343
'resource_request_time_reduction',
44+
'resource_increase_amount',
4445
'capital_city_building_request_travel_time_reduction',
4546
'capital_city_unit_request_travel_time_reduction'
4647
];
@@ -70,6 +71,11 @@ public function getCurrentBonusAttribute()
7071
return $this->current_level * $this->passiveSkill->bonus_per_level;
7172
}
7273

74+
public function getResourceIncreaseAmountAttribute()
75+
{
76+
return $this->current_level * $this->passiveSkill->resource_bonus_per_level;
77+
}
78+
7379
public function getNameAttribute()
7480
{
7581
return $this->passiveSkill->name;

app/Game/Kingdoms/Builders/KingdomBuilder.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Flare\Models\Character;
66
use App\Flare\Models\Kingdom;
77
use App\Game\Messages\Events\ServerMessageEvent;
8+
use App\Game\PassiveSkills\Values\PassiveSkillTypeValue;
89

910
class KingdomBuilder
1011
{
@@ -16,7 +17,7 @@ public function createKingdom(Character $character, string $name, string $color)
1617

1718
$isOnIcePlane = $character->map->gameMap->mapType()->isTheIcePlane();
1819
$characterKingdomCount = $character->kingdoms()->count();
19-
20+
$skill = $character->passiveSkills->where('passiveSkill.effect_type', PassiveSkillTypeValue::RESOURCE_INCREASE)->first();
2021
$protectedUntil = null;
2122

2223
if (! $isOnIcePlane && $characterKingdomCount === 0) {
@@ -32,18 +33,18 @@ public function createKingdom(Character $character, string $name, string $color)
3233
'color' => $color,
3334
'character_id' => $character->id,
3435
'game_map_id' => $character->map->gameMap->id,
35-
'max_stone' => 2000,
36-
'max_wood' => 2000,
37-
'max_clay' => 2000,
38-
'max_iron' => 2000,
36+
'max_stone' => 2000 + $skill->resource_increase_amount,
37+
'max_wood' => 2000 + $skill->resource_increase_amount,
38+
'max_clay' => 2000 + $skill->resource_increase_amount,
39+
'max_iron' => 2000 + $skill->resource_increase_amount,
3940
'max_steel' => 31000,
4041
'current_stone' => 2000,
4142
'current_wood' => 2000,
4243
'current_clay' => 2000,
4344
'current_iron' => 2000,
4445
'current_steel' => 0,
4546
'current_population' => 100,
46-
'max_population' => 100,
47+
'max_population' => 100 + $skill->resource_increase_amount,
4748
'current_morale' => .50,
4849
'max_morale' => 1.0,
4950
'treasury' => 0,

app/Game/Kingdoms/Jobs/UpgradeBuilding.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Flare\Models\BuildingInQueue;
66
use App\Flare\Models\CapitalCityBuildingQueue;
7+
use App\Flare\Models\Character;
78
use App\Flare\Models\Kingdom;
89
use App\Flare\Models\KingdomBuilding;
910
use App\Flare\Models\User;
@@ -12,6 +13,7 @@
1213
use App\Game\Kingdoms\Service\UpdateKingdom;
1314
use App\Game\Kingdoms\Values\CapitalCityQueueStatus;
1415
use App\Game\Messages\Types\KingdomMessageTypes;
16+
use App\Game\PassiveSkills\Values\PassiveSkillTypeValue;
1517
use Exception;
1618
use Facades\App\Flare\Values\UserOnlineValue;
1719
use Facades\App\Game\Messages\Handlers\ServerMessageHandler;
@@ -28,7 +30,9 @@ class UpgradeBuilding implements ShouldQueue
2830
/**
2931
* @var User
3032
*/
31-
protected $user;
33+
protected User $user;
34+
35+
protected Character $character;
3236

3337
protected KingdomBuilding $building;
3438

@@ -53,6 +57,8 @@ public function __construct(KingdomBuilding $building, User $user, int $queueId,
5357
{
5458
$this->user = $user;
5559

60+
$this->character = $user->character;
61+
5662
$this->building = $building;
5763

5864
$this->queueId = $queueId;
@@ -72,6 +78,9 @@ public function handle(UpdateKingdom $updateKingdom, CapitalCityBuildingManageme
7278

7379
$queue = BuildingInQueue::find($this->queueId);
7480

81+
$skill = $this->character->passiveSkills->where('passiveSkill.effect_type', PassiveSkillTypeValue::RESOURCE_INCREASE)->first();
82+
83+
7584
if (is_null($queue)) {
7685
return;
7786
}
@@ -109,7 +118,7 @@ public function handle(UpdateKingdom $updateKingdom, CapitalCityBuildingManageme
109118
}
110119
// @codeCoverageIgnoreEnd
111120

112-
$this->building->kingdom->{'max_' . $type} += 1000;
121+
$this->building->kingdom->{'max_' . $type} += (1000 + $skill->resource_increase_amount);
113122
}
114123

115124
$this->building->kingdom->save();
@@ -133,7 +142,7 @@ public function handle(UpdateKingdom $updateKingdom, CapitalCityBuildingManageme
133142

134143
if ($building->is_farm) {
135144
$building->kingdom->update([
136-
'max_population' => $building->kingdom->max_population + (($building->level * 100) + 100),
145+
'max_population' => $building->kingdom->max_population + (($building->level * 100) + 100) + $skill->resource_increase_amount,
137146
]);
138147
}
139148

app/Game/Maps/Jobs/UpdateMapLocationsJob.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public function handle(LocationService $locationService): void
5656

5757
$raid = Raid::find($this->raidId);
5858

59-
$locationData = $locationService->fetchLocationData($character->map->game_map_id); // $locationService->fetchLocationData($character->map->game_map_id)->merge($locationService->fetchCorruptedLocationData($raid));
60-
dump('Handle of App\Game\Maps\Jobs\UpdateMapLocationsJob, locations is:', $locationData);
59+
$locationData = $locationService->fetchLocationData($character->map->game_map_id)->merge($locationService->fetchCorruptedLocationData($raid));
60+
6161
event(new UpdateMapLocations($character->user, $locationData));
6262
}
6363
}

app/Game/Maps/Services/LocationService.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ public function fetchLocationData(int $gameMapId): Collection
146146
$cachedValue = Cache::get($cacheKey);
147147

148148
if (!is_null($cachedValue)) {
149-
dump('Being called?');
150149
return collect($cachedValue);
151150
}
152151

app/Providers/AppServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Console\AfterDeployment\CreateLocationDataCache;
66
use App\Console\AfterDeployment\FixFactionLoyaltyCraftingTasks;
7+
use App\Console\AfterDeployment\FixKingdomMaxResourcesBasedOnPassiveSkill;
78
use App\Console\AfterDeployment\FixWeaponMasteryTypes;
89
use Illuminate\Support\Facades\Blade;
910
use Illuminate\Support\Facades\Mail;
@@ -96,6 +97,7 @@ public function register(): void
9697
FixFactionLoyaltyCraftingTasks::class,
9798
FixWeaponMasteryTypes::class,
9899
CreateLocationDataCache::class,
100+
FixKingdomMaxResourcesBasedOnPassiveSkill::class,
99101

100102
// Development Commands:
101103
CreateCharacter::class,

0 commit comments

Comments
 (0)