diff --git a/ui/src/app/components/adventurer/DeathDialog.tsx b/ui/src/app/components/adventurer/DeathDialog.tsx
index e82e2511f..1f097ea5c 100644
--- a/ui/src/app/components/adventurer/DeathDialog.tsx
+++ b/ui/src/app/components/adventurer/DeathDialog.tsx
@@ -37,7 +37,11 @@ export const DeathDialog = () => {
adventurersByXPdata?.adventurers ?? []
);
+ console.log(adventurersByXPdata);
+ console.log(rank);
+
const ordinalRank = getOrdinalSuffix(rank + 1 ?? 0);
+ console.log(ordinalRank);
return (
<>
@@ -56,11 +60,16 @@ export const DeathDialog = () => {
{deathMessage}
-
- {adventurer?.name} died level {adventurer?.level} with {""}
- {adventurer?.xp} XP, a valiant effort! Make sure to share your
- score. Continue the journey with another adventurer:{" "}
-
+
+
+ {adventurer?.name} died at {ordinalRank} on the leaderboard with{" "}
+ {adventurer?.xp} XP, a valiant effort!
+
{" "}
+
+ Make sure to share your score. Continue the journey with another
+ adventurer.
+
+
- {/*
- {" "}
- {`${items.length}/${19}`}
- */}
{" "}
diff --git a/ui/src/app/components/adventurer/InventoryDisplay.tsx b/ui/src/app/components/adventurer/InventoryDisplay.tsx
new file mode 100644
index 000000000..c7acae021
--- /dev/null
+++ b/ui/src/app/components/adventurer/InventoryDisplay.tsx
@@ -0,0 +1,145 @@
+import LootIcon from "../icons/LootIcon";
+import Efficacyicon from "../icons/EfficacyIcon";
+import { Item } from "@/app/types";
+import {
+ getItemData,
+ processItemName,
+ calculateLevel,
+ getKeyFromValue,
+} from "@/app/lib/utils";
+import { MdClose } from "react-icons/md";
+import { Button } from "../buttons/Button";
+import useUIStore from "@/app/hooks/useUIStore";
+import { GameData } from "../GameData";
+import { useContracts } from "@/app/hooks/useContracts";
+import useAdventurerStore from "@/app/hooks/useAdventurerStore";
+import useTransactionCartStore from "@/app/hooks/useTransactionCartStore";
+
+interface InventoryDisplayProps {
+ itemsOwnedInSlot: Item[];
+ itemSlot: string;
+ setShowInventoryItems: (showInventoryItems: boolean) => void;
+ equipItems: string[];
+}
+
+export const InventoryDisplay = ({
+ itemsOwnedInSlot,
+ itemSlot,
+ setShowInventoryItems,
+ equipItems,
+}: InventoryDisplayProps) => {
+ return (
+
+ {itemsOwnedInSlot.length > 0 ? (
+
+ {itemsOwnedInSlot.map((item, index) => (
+
+ ))}
+
+ ) : (
+
No items to equip.
+ )}
+
setShowInventoryItems(false)}>
+
+
+
+ );
+};
+
+interface InventoryCardProps {
+ itemSlot: string;
+ item: Item;
+ equipItems: string[];
+}
+
+export const InventoryCard = ({
+ itemSlot,
+ item,
+ equipItems,
+}: InventoryCardProps) => {
+ const { adventurer } = useAdventurerStore();
+ const { tier, type, slot } = getItemData(item?.item ?? "");
+ const itemName = processItemName(item);
+
+ const setEquipItems = useUIStore((state) => state.setEquipItems);
+ const addToCalls = useTransactionCartStore((state) => state.addToCalls);
+ const removeEntrypointFromCalls = useTransactionCartStore(
+ (state) => state.removeEntrypointFromCalls
+ );
+
+ const { gameContract } = useContracts();
+ const gameData = new GameData();
+
+ const handleEquipItems = (item: string) => {
+ const formattedNewEquipItems = handleCheckSameSlot(slot, equipItems);
+ console.log(equipItems);
+ const newEquipItems = [
+ ...formattedNewEquipItems,
+ getKeyFromValue(gameData.ITEMS, item) ?? "",
+ ];
+ setEquipItems(newEquipItems);
+ if (gameContract) {
+ const equipItemTx = {
+ contractAddress: gameContract?.address,
+ entrypoint: "equip",
+ calldata: [
+ adventurer?.id?.toString() ?? "",
+ "0",
+ newEquipItems.length.toString(),
+ ...newEquipItems,
+ ],
+ metadata: `Equipping ${item}!`,
+ };
+ removeEntrypointFromCalls(equipItemTx.entrypoint);
+ addToCalls(equipItemTx);
+ }
+ };
+
+ const itemId = getKeyFromValue(gameData.ITEMS, item?.item ?? "") ?? "";
+
+ const handleCheckSameSlot = (itemSlot: string, equipItems: string[]) => {
+ return equipItems.filter((item) => {
+ const itemName = gameData.ITEMS[parseInt(item)];
+ const { slot } = getItemData(itemName ?? "");
+ return slot !== itemSlot;
+ });
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {item &&
+ `Tier ${tier ?? 0}
+ `}
+
+ Greatness {calculateLevel(item?.xp ?? 0)}
+
+ {itemName}
+
+
+
handleEquipItems(item?.item ?? "")}
+ disabled={equipItems.includes(itemId)}
+ >
+ Equip
+
+
+ );
+};
diff --git a/ui/src/app/components/adventurer/ItemDisplay.tsx b/ui/src/app/components/adventurer/ItemDisplay.tsx
index 530471b87..f2059d99e 100644
--- a/ui/src/app/components/adventurer/ItemDisplay.tsx
+++ b/ui/src/app/components/adventurer/ItemDisplay.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect } from "react";
+import React, { useEffect, useState } from "react";
import { Item } from "../../types";
import LootIcon from "../icons/LootIcon";
import Efficacyicon from "../icons/EfficacyIcon";
@@ -6,10 +6,11 @@ import { processItemName, calculateLevel, getItemData } from "../../lib/utils";
import ItemBar from "./ItemBar";
import { GameData } from "../GameData";
import { getKeyFromValue, getValueFromKey } from "../../lib/utils";
-import { useMediaQuery } from "react-responsive";
import { SwapIcon, DownArrowIcon } from "../icons/Icons";
import { Button } from "../buttons/Button";
import useUIStore from "@/app/hooks/useUIStore";
+import { InventoryDisplay } from "./InventoryDisplay";
+import { useQueriesStore } from "@/app/hooks/useQueryStore";
interface ItemDisplayProps {
item: Item;
@@ -30,10 +31,13 @@ export const ItemDisplay = ({
disabled,
handleDrop,
}: ItemDisplayProps) => {
+ const [showInventoryItems, setShowInventoryItems] = useState(false);
const itemType = item?.item;
const itemName = processItemName(item);
+ const equipItems = useUIStore((state) => state.equipItems);
const { tier, type, slot } = getItemData(itemType ?? "");
+ const { data } = useQueriesStore();
const gameData = new GameData();
const itemSuffix = parseInt(
@@ -42,10 +46,6 @@ export const ItemDisplay = ({
const boost = getValueFromKey(gameData.ITEM_SUFFIX_BOOST, itemSuffix ?? 0);
const screen = useUIStore((state) => state.screen);
- const setScreen = useUIStore((state) => state.setScreen);
- const setInventorySelected = useUIStore(
- (state) => state.setInventorySelected
- );
const dropItems = useUIStore((state) => state.dropItems);
const scrollableRef = React.useRef(null);
@@ -119,124 +119,154 @@ export const ItemDisplay = ({
return dropItems.includes(getKeyFromValue(gameData.ITEMS, item) ?? "");
};
+ // Handle inventory display when user selects swap
+
+ const items = data.itemsByAdventurerQuery
+ ? data.itemsByAdventurerQuery.items
+ : [];
+
+ const itemsOwnedInSlot = items.filter((ownedItem) => {
+ const { slot } = getItemData(ownedItem.item ?? "");
+ return slot === itemSlot && item.item !== ownedItem.item;
+ });
+
+ const slotEquipped = itemsOwnedInSlot.some((item) =>
+ equipItems.includes(getKeyFromValue(gameData.ITEMS, item.item ?? "") ?? "")
+ );
+
+ // Check if they have slected to equip a slot then close inventory items
+ useEffect(() => {
+ if (slotEquipped) {
+ setShowInventoryItems(false);
+ }
+ }, [slotEquipped, equipItems]);
+
return (
-
-
-
-
-
-
-
-
-
-
- {item.item ? (
-
-
-
-
-
- {item &&
- `Tier ${tier ?? 0}
- `}
-
-
-
-
- {boost}
-
-
-
- {itemName}
-
- {slot == "Neck" || slot == "Ring"
- ? ` [+${calculateLevel(item?.xp ?? 0)} Luck]`
- : ""}
-
-
-
- {(screen == "play" ||
- screen == "upgrade" ||
- screen == "player") && (
- {
- setScreen("inventory");
- setInventorySelected(
- parseInt(
- getKeyFromValue(gameData.SLOTS, slot ?? "") ?? ""
- ) ?? 0
- );
- }}
- >
-
-
- )}
- {inventory && (
- <>
-
+ <>
+ {!showInventoryItems ? (
+
+
+
+
+
+
+
+
+
+
+ {item.item ? (
+
+
+
+
+
+ {item &&
+ `Tier ${tier ?? 0}
+ `}
+
+
+
+
+ {boost}
+
+
+
+ {itemName}
+
+ {slot == "Neck" || slot == "Ring"
+ ? ` [+${calculateLevel(item?.xp ?? 0)} Luck]`
+ : ""}
+
+
+
+ {(screen == "play" ||
+ screen == "upgrade" ||
+ screen == "player") && (
{
+ setShowInventoryItems(true);
+ }}
>
-
- {equipped ? "Equipped" : "Equip"}
-
+
-
-
+ )}
+ {inventory && (
+ <>
+
+
+
+ {equipped ? "Equipped" : "Equip"}
+
+
+
+
+
+
+ {equipped ? "Equipped" : "Equip"}
+
+
+
+ >
+ )}
+ {(screen == "play" ||
+ screen == "upgrade" ||
+ screen == "player" ||
+ screen == "inventory") && (
handleDrop(item.item ?? "")}
+ disabled={checkDropping(item.item ?? "")}
>
-
- {equipped ? "Equipped" : "Equip"}
-
+
-
- >
- )}
- {(screen == "play" ||
- screen == "upgrade" ||
- screen == "player" ||
- screen == "inventory") && (
-
handleDrop(item.item ?? "")}
- disabled={checkDropping(item.item ?? "")}
- >
-
-
- )}
-
-
+ )}
+
+
+
+
-
+ ) : (
+
+ )}
) : (
-
+ >
);
};
diff --git a/ui/src/app/components/intro/WalletSelect.tsx b/ui/src/app/components/intro/WalletSelect.tsx
index b5ab7ee0f..1a4ba7221 100644
--- a/ui/src/app/components/intro/WalletSelect.tsx
+++ b/ui/src/app/components/intro/WalletSelect.tsx
@@ -26,7 +26,7 @@ const WalletSelect = ({}: WalletSelectProps) => {
);
return (
-
+
{screen === "wallet" ? (
<>
@@ -44,7 +44,7 @@ const WalletSelect = ({}: WalletSelectProps) => {
-
+
setScreen("tutorial")}>
I don't have a wallet
@@ -63,7 +63,7 @@ const WalletSelect = ({}: WalletSelectProps) => {
{arcadeConnectors().length ? (
<>
Arcade Accounts
-
+
{arcadeConnectors().map((connector, index) => (
connect(connector)}
diff --git a/ui/src/app/containers/InventoryScreen.tsx b/ui/src/app/containers/InventoryScreen.tsx
index d65963dfb..1b70ccb6e 100644
--- a/ui/src/app/containers/InventoryScreen.tsx
+++ b/ui/src/app/containers/InventoryScreen.tsx
@@ -334,7 +334,6 @@ export default function InventoryScreen() {
}}
equipped={item.equipped}
disabled={
- singleEquipExists(item.item ?? "") ||
item.equipped ||
checkTransacting(item.item ?? "") ||
equipItems.includes(itemId)