Skip to content

Commit fcd1055

Browse files
committed
Fixes to how maps get weather we can see a specialty shop or not.
1 parent 9b39143 commit fcd1055

File tree

19 files changed

+91
-127
lines changed

19 files changed

+91
-127
lines changed

app/Game/Maps/Events/UpdateLocationBasedSpecialShops.php

Lines changed: 0 additions & 64 deletions
This file was deleted.

app/Game/Maps/Services/LocationService.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use App\Game\Core\Traits\KingdomCache;
1818
use App\Game\Maps\Events\UpdateLocationBasedCraftingOptions;
1919
use App\Game\Maps\Events\UpdateLocationBasedEventGoals;
20-
use App\Game\Maps\Events\UpdateLocationBasedSpecialShops;
2120
use App\Game\Maps\Services\Common\CanPlayerMassEmbezzle;
2221
use App\Game\Maps\Services\Common\LiveCharacterCount;
2322
use App\Game\Maps\Services\Common\UpdateRaidMonstersForLocation;
@@ -87,6 +86,9 @@ public function getLocationData(Character $character, ?Raid $raid = null): array
8786
'characters_on_map' => $this->getActiveUsersCountForMap($character),
8887
'lockedLocationType' => is_null($lockedLocation) ? null : $lockedLocation->type,
8988
'is_event_based' => $this->isEventBasedUpdate,
89+
'can_access_hell_forged_shop' => $character->map->gameMap->mapType()->isHell(),
90+
'can_access_purgatory_chains_shop' => $character->map->gameMap->mapType()->isPurgatory(),
91+
'can_access_twisted_earth_shop' => $character->map->gameMap->mapType()->isTwistedMemories(),
9092
];
9193
}
9294

@@ -103,9 +105,6 @@ public function locationBasedEvents(Character $character): void
103105
// Update location based crafting options:
104106
event(new UpdateLocationBasedCraftingOptions($character->user));
105107

106-
// Update location based special shops:
107-
event(new UpdateLocationBasedSpecialShops($character->user));
108-
109108
// Update location based event goals
110109
event(new UpdateLocationBasedEventGoals($character->user));
111110

app/Game/Maps/Services/MovementService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ public function updateCharacterPlane(int $mapId, Character $character): array
147147
$this->giveLocationReward($character, $location);
148148
}
149149

150-
return $this->successResult();
150+
return $this->successResult([
151+
'can_access_hell_forged_shop' => $character->map->gameMap->mapType()->isHell(),
152+
'can_access_purgatory_chains_shop' => $character->map->gameMap->mapType()->isPurgatory(),
153+
'can_access_twisted_earth_shop' => $character->map->gameMap->mapType()->isTwistedMemories(),
154+
]);
151155
}
152156

153157
/**

resources/js/game/game.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,11 @@ export default class Game extends React.Component<GameProps, GameState> {
303303
});
304304
}
305305

306-
setMapState(mapData: MapState): void {
307-
this.setState({
308-
map_data: mapData,
309-
});
306+
setMapState(mapData: Partial<MapState>): void {
307+
this.setState((prevState) => ({
308+
...prevState,
309+
...mapData,
310+
}));
310311
}
311312

312313
setCanSeeFactionLoyaltyTab(canSee: boolean, factionId?: number) {
@@ -403,6 +404,10 @@ export default class Game extends React.Component<GameProps, GameState> {
403404
return this.renderLoading();
404405
}
405406

407+
if (this.state.map_data === null) {
408+
return this.renderLoading();
409+
}
410+
406411
if (this.state.show_suggestions_and_bugs) {
407412
return (
408413
<SuggestionsAndBugs
@@ -635,6 +640,18 @@ export default class Game extends React.Component<GameProps, GameState> {
635640
update_show_map_mobile={this.updateMapVisibility.bind(
636641
this,
637642
)}
643+
can_access_hell_forged_shop={
644+
this.state.map_data
645+
.can_access_hell_forged_shop
646+
}
647+
can_access_purgatory_chains_shop={
648+
this.state.map_data
649+
.can_access_purgatory_chains_shop
650+
}
651+
can_access_twisted_earth_shop={
652+
this.state.map_data
653+
.can_access_twisted_earth_shop
654+
}
638655
/>
639656
</ActionTabs>
640657
</BasicCard>

resources/js/game/lib/game/actions/small-actions-manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,21 @@ export default class SmallActionsManager {
140140
});
141141
}
142142

143-
if (props.character.can_access_hell_forged) {
143+
if (props.can_access_hell_forged_shop) {
144144
options.push({
145145
label: "Hell Forged Gear",
146146
value: "hell-forged-gear",
147147
});
148148
}
149149

150-
if (props.character.can_access_purgatory_chains) {
150+
if (props.can_access_purgatory_chains_shop) {
151151
options.push({
152152
label: "Purgatory Chains Gear",
153153
value: "purgatory-chains-gear",
154154
});
155155
}
156156

157-
if (props.character.can_access_twisted_memories) {
157+
if (props.can_access_twisted_earth_shop) {
158158
options.push({
159159
label: "Twisted Earth",
160160
value: "twisted-earth-gear",

resources/js/game/lib/game/ajax/FetchGameData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export default class FetchGameData {
157157
}
158158

159159
setMapData(result: AxiosResponse) {
160+
console.log("setMapData", result.data);
160161
this.component.setState({
161162
map_data: MapStateManager.buildCoreState(
162163
result.data,

resources/js/game/lib/game/event-listeners/game/map-listeners.ts

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ export default class MapListeners implements GameListener {
1818

1919
private updateCraftingTypes?: Channel;
2020

21-
private updateSpecialShopsAccess?: Channel;
22-
2321
private updateSpecialEventGoals?: Channel;
2422

2523
private corruptedLocations?: Channel;
@@ -48,9 +46,6 @@ export default class MapListeners implements GameListener {
4846
this.updateCraftingTypes = echo.private(
4947
"update-location-base-crafting-options-" + this.userId,
5048
);
51-
this.updateSpecialShopsAccess = echo.private(
52-
"update-location-base-shops-" + this.userId,
53-
);
5449
this.updateSpecialEventGoals = echo.private(
5550
"update-location-base-event-goals-" + this.userId,
5651
);
@@ -66,7 +61,6 @@ export default class MapListeners implements GameListener {
6661
this.listenToTraverse();
6762
this.listenToBasePositionUpdate();
6863
this.listForLocationBasedCraftingTypes();
69-
this.listForUpdatesToSpecialShopsAccess();
7064
this.listenForEventGoalUpdates();
7165
this.listenForCorruptedLocationUpdates();
7266
this.listenForPctCommand();
@@ -161,41 +155,6 @@ export default class MapListeners implements GameListener {
161155
);
162156
}
163157

164-
/**
165-
* Listen for when players should see specific special shop buttons.
166-
*
167-
* @private
168-
*/
169-
private listForUpdatesToSpecialShopsAccess() {
170-
if (!this.updateSpecialShopsAccess) {
171-
return;
172-
}
173-
174-
this.updateSpecialShopsAccess.listen(
175-
"Game.Maps.Events.UpdateLocationBasedSpecialShops",
176-
(event: any) => {
177-
if (!this.component) {
178-
return;
179-
}
180-
181-
const character = JSON.parse(
182-
JSON.stringify(this.component.state.character),
183-
);
184-
185-
character.can_access_hell_forged =
186-
event.canAccessHellForgedShop;
187-
character.can_access_purgatory_chains =
188-
event.canAccessPurgatoryChainsShop;
189-
character.can_access_twisted_memories =
190-
event.camAccessTwistedEarthShop;
191-
192-
this.component.setState({
193-
character: character,
194-
});
195-
},
196-
);
197-
}
198-
199158
/**
200159
* Listen for global event goal updates.
201160
*

resources/js/game/sections/game-actions-section/action-section.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ export default class ActionSection extends React.Component<
3838
update_show_map_mobile={
3939
this.props.update_show_map_mobile
4040
}
41+
can_access_hell_forged_shop={
42+
this.props.can_access_hell_forged_shop
43+
}
44+
can_access_purgatory_chains_shop={
45+
this.props.can_access_purgatory_chains_shop
46+
}
47+
can_access_twisted_earth_shop={
48+
this.props.can_access_twisted_earth_shop
49+
}
4150
/>
4251
) : (
4352
<Actions
@@ -55,6 +64,15 @@ export default class ActionSection extends React.Component<
5564
update_show_map_mobile={
5665
this.props.update_show_map_mobile
5766
}
67+
can_access_hell_forged_shop={
68+
this.props.can_access_hell_forged_shop
69+
}
70+
can_access_purgatory_chains_shop={
71+
this.props.can_access_purgatory_chains_shop
72+
}
73+
can_access_twisted_earth_shop={
74+
this.props.can_access_twisted_earth_shop
75+
}
5876
/>
5977
)}
6078
</Fragment>

resources/js/game/sections/game-actions-section/actions.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export default class Actions extends React.Component<
287287
</div>
288288
)}
289289

290-
{this.props.character.can_access_hell_forged && (
290+
{this.props.can_access_hell_forged_shop && (
291291
<div className="w-full">
292292
<SuccessOutlineButton
293293
button_label={"Hell Forged Gear"}
@@ -300,7 +300,7 @@ export default class Actions extends React.Component<
300300
</div>
301301
)}
302302

303-
{this.props.character.can_access_purgatory_chains && (
303+
{this.props.can_access_purgatory_chains_shop && (
304304
<div className="w-full">
305305
<SuccessOutlineButton
306306
button_label={"Purgatory Chains Gear"}
@@ -313,7 +313,7 @@ export default class Actions extends React.Component<
313313
</div>
314314
)}
315315

316-
{this.props.character.can_access_twisted_memories && (
316+
{this.props.can_access_twisted_earth_shop && (
317317
<div className="w-full">
318318
<SuccessOutlineButton
319319
button_label={"Twisted Earth Gear"}

resources/js/game/sections/game-actions-section/types/actions-props.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,10 @@ export default interface ActionsProps {
2424
fame_tasks: FameTasks[] | null;
2525

2626
update_show_map_mobile: (showMap: boolean) => void;
27+
28+
can_access_hell_forged_shop: boolean;
29+
30+
can_access_purgatory_chains_shop: boolean;
31+
32+
can_access_twisted_earth_shop: boolean;
2733
}

0 commit comments

Comments
 (0)