Skip to content

Commit

Permalink
add logic to check discovered item is equipped or not equipped
Browse files Browse the repository at this point in the history
  • Loading branch information
starknetdev committed Jun 26, 2024
1 parent 032a81c commit bf1cae1
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions ui/src/app/components/actions/DiscoveryDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ import LootIcon from "@/app/components/icons/LootIcon";
import { Discovery } from "@/app/types";
import { GameData } from "@/app/lib/data/GameData";
import { getItemData } from "@/app/lib/utils";
import useAdventurerStore from "@/app/hooks/useAdventurerStore";

interface DiscoveryProps {
discoveryData: Discovery;
}

export const DiscoveryDisplay = ({ discoveryData }: DiscoveryProps) => {
const adventurer = useAdventurerStore((state) => state.adventurer);
const beastName = processBeastName(
discoveryData?.entity ?? "",
discoveryData?.special2 ?? "",
discoveryData?.special3 ?? ""
);

console.log(adventurer!["weapon"]);
console.log(getItemData("Wand" ?? ""));

const AdventurerHealthExists = (discoveryData?.adventurerHealth ?? 0) > 0;

const gameData = new GameData();
Expand Down Expand Up @@ -139,13 +144,21 @@ export const DiscoveryDisplay = ({ discoveryData }: DiscoveryProps) => {
if (discoveryData?.subDiscoveryType === "Loot") {
const itemName = gameData.ITEMS[discoveryData?.outputAmount!];
const { slot } = getItemData(itemName ?? "");
const hasEquipped = adventurer![slot.toLowerCase()] == itemName;
return (
<span className="flex flex-row items-center justify-between">
<div className="flex self-center">
<p>
WOW! Discovered the Loot item {itemName}!{" "}
<LootIcon size={"w-5"} type={slot} />
</p>
{!hasEquipped ? (
<p>
WOW! Discovered {itemName}. Check your bag!
<LootIcon size={"w-5"} type={slot} />
</p>
) : (
<p>
WOW! Discovered and equipped {itemName}!
<LootIcon size={"w-5"} type={slot} />
</p>
)}
</div>
<HealthPotionIcon />
</span>
Expand Down

0 comments on commit bf1cae1

Please sign in to comment.