Skip to content

Commit 6a62414

Browse files
committed
Fixed issues with faction npc crafting
1 parent 28154c8 commit 6a62414

13 files changed

+196
-9
lines changed

resources/js/game/components/faction-loyalty/faction-npc-tasks.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,20 @@ export default class FactionNpcTasks extends React.Component<
142142
);
143143
}
144144

145+
isCraftingTaskButtonDisabled(fameTask: FameTasks) {
146+
return (
147+
!this.props.can_craft ||
148+
this.state.crafting ||
149+
this.state.must_revive ||
150+
fameTask.current_amount === fameTask.required_amount ||
151+
!this.props.faction_loyalty_npc.currently_helping ||
152+
!(
153+
this.props.faction_loyalty_npc.npc.game_map_id ===
154+
this.props.character_map_id
155+
)
156+
);
157+
}
158+
145159
renderTasks(fameTasks: FameTasks[], bounties: boolean) {
146160
return fameTasks
147161
.filter((fameTask: FameTasks) => {
@@ -188,15 +202,9 @@ export default class FactionNpcTasks extends React.Component<
188202
fameTask.item_id,
189203
);
190204
}}
191-
disabled={
192-
!this.props.can_craft ||
193-
this.state.crafting ||
194-
this.state.must_revive ||
195-
fameTask.current_amount ===
196-
fameTask.required_amount ||
197-
!this.props.faction_loyalty_npc
198-
.currently_helping
199-
}
205+
disabled={this.isCraftingTaskButtonDisabled(
206+
fameTask,
207+
)}
200208
/>
201209
)}
202210
</div>

resources/js/game/components/hooks/definitions/use-character-inventory-visibility.ts

Whitespace-only changes.

resources/js/game/components/hooks/definitions/use-character-sheet-visibility-definition.ts

Whitespace-only changes.

resources/js/game/components/hooks/definitions/use-game-loader-visibility-definition.ts

Whitespace-only changes.

resources/js/game/components/hooks/definitions/use-manage-game-loader-visibility.ts

Whitespace-only changes.

resources/js/game/components/hooks/types/use-character-inventory-visibility-state.ts

Whitespace-only changes.

resources/js/game/components/hooks/types/use-character-sheet-visibility-state.ts

Whitespace-only changes.

resources/js/game/components/hooks/types/use-game-loader-visibility.ts

Whitespace-only changes.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { useEventSystem } from "event-system/hooks/use-event-system";
2+
import { useEffect, useState } from "react";
3+
4+
import UseCharacterInventoryVisibility from "./definitions/use-character-inventory-visibility";
5+
import UseCharacterInventoryVisibilityState from "./types/use-character-inventory-visibility-state";
6+
import { CharacterSheet } from "../character-sheet/event-types/character-sheet";
7+
8+
export const useCharacterInventoryVisibility =
9+
(): UseCharacterInventoryVisibility => {
10+
const eventSystem = useEventSystem();
11+
12+
const [showCharacterInventory, setShowCharacterInventory] =
13+
useState<
14+
UseCharacterInventoryVisibilityState["showCharacterInventory"]
15+
>(false);
16+
17+
const characterInventoryVisibility =
18+
eventSystem.fetchOrCreateEventEmitter<{
19+
[key: string]: boolean;
20+
}>(CharacterSheet.OPEN_INVENTORY_SECTION);
21+
22+
useEffect(() => {
23+
const updateVisibility = (visible: boolean) => {
24+
setShowCharacterInventory(visible);
25+
};
26+
27+
characterInventoryVisibility.on(
28+
CharacterSheet.OPEN_INVENTORY_SECTION,
29+
updateVisibility,
30+
);
31+
32+
return () => {
33+
characterInventoryVisibility.off(
34+
CharacterSheet.OPEN_INVENTORY_SECTION,
35+
updateVisibility,
36+
);
37+
};
38+
}, [characterInventoryVisibility]);
39+
40+
const closeInventory = () => {
41+
characterInventoryVisibility.emit(
42+
CharacterSheet.OPEN_INVENTORY_SECTION,
43+
false,
44+
);
45+
};
46+
47+
return { showCharacterInventory, closeInventory };
48+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { useEventSystem } from "event-system/hooks/use-event-system";
2+
import { useState, useEffect } from "react";
3+
4+
import UseCharacterSheetVisibilityState from "./types/use-character-sheet-visibility-state";
5+
import { CharacterSheet } from "../character-sheet/event-types/character-sheet";
6+
7+
export const useCharacterSheetVisibility =
8+
(): UseCharacterSheetVisibilityState => {
9+
const eventSystem = useEventSystem();
10+
11+
const [showCharacterSheet, setShowCharacterSheet] =
12+
useState<UseCharacterSheetVisibilityState["showCharacterSheet"]>(
13+
false,
14+
);
15+
16+
const characterSheetVisibility = eventSystem.fetchOrCreateEventEmitter<{
17+
[key: string]: boolean;
18+
}>(CharacterSheet.OPEN_CHARACTER_SHEET);
19+
20+
useEffect(() => {
21+
const updateVisibility = (visible: boolean) => {
22+
setShowCharacterSheet(visible);
23+
};
24+
25+
characterSheetVisibility.on(
26+
CharacterSheet.OPEN_CHARACTER_SHEET,
27+
updateVisibility,
28+
);
29+
30+
return () => {
31+
characterSheetVisibility.off(
32+
CharacterSheet.OPEN_CHARACTER_SHEET,
33+
updateVisibility,
34+
);
35+
};
36+
}, [characterSheetVisibility]);
37+
38+
return { showCharacterSheet };
39+
};

0 commit comments

Comments
 (0)