Skip to content

Commit

Permalink
fix death screen on slay adventurer
Browse files Browse the repository at this point in the history
  • Loading branch information
starknetdev committed Oct 4, 2023
1 parent 07ca8d7 commit e9ad895
Showing 1 changed file with 33 additions and 23 deletions.
56 changes: 33 additions & 23 deletions ui/src/app/lib/utils/syscalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1290,32 +1290,42 @@ export function syscalls({
(event) => event.name === "AdventurerDied"
);
for (let adventurerDiedEvent of adventurerDiedEvents) {
setData("adventurerByIdQuery", {
adventurers: [adventurerDiedEvent.data[0]],
});
const deadAdventurerIndex =
queryData.adventurersByOwnerQuery?.adventurers.findIndex(
(adventurer: any) =>
adventurer.id == adventurerDiedEvent.data[0].id
if (
adventurerDiedEvent.data[1].callerAddress ===
adventurerDiedEvent.data[0].owner
) {
setData("adventurerByIdQuery", {
adventurers: [adventurerDiedEvent.data[0]],
});
const deadAdventurerIndex =
queryData.adventurersByOwnerQuery?.adventurers.findIndex(
(adventurer: any) =>
adventurer.id == adventurerDiedEvent.data[0].id
);
setData(
"adventurersByOwnerQuery",
0,
"health",
deadAdventurerIndex
);
setData("adventurersByOwnerQuery", 0, "health", deadAdventurerIndex);
setAdventurer(adventurerDiedEvent.data[0]);
const killedByBeast = battles.some(
(battle) =>
battle.attacker == "Beast" && battle.adventurerHealth == 0
);
// In a multicall someone can either die from swapping inventory or the death penalty. Here we handle those cases
if (killedByBeast) {
setDeathNotification(
"Multicall",
["You equipped"],
adventurerDiedEvent.data[0]
setAdventurer(adventurerDiedEvent.data[0]);
const killedByBeast = battles.some(
(battle) =>
battle.attacker == "Beast" && battle.adventurerHealth == 0
);
} else {
setDeathNotification("Upgrade", "Death Penalty", []);
// In a multicall someone can either die from swapping inventory or the death penalty. Here we handle those cases
if (killedByBeast) {
setDeathNotification(
"Multicall",
["You equipped"],
adventurerDiedEvent.data[0]
);
} else {
setDeathNotification("Upgrade", "Death Penalty", []);
}
setScreen("start");
setStartOption("create adventurer");
}
setScreen("start");
setStartOption("create adventurer");
}

setData("battlesByBeastQuery", {
Expand Down

1 comment on commit e9ad895

@vercel
Copy link

@vercel vercel bot commented on e9ad895 Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.