diff --git a/src/components/combat/stance-selector.tsx b/src/components/combat/stance-selector.tsx index f970268..50e421b 100644 --- a/src/components/combat/stance-selector.tsx +++ b/src/components/combat/stance-selector.tsx @@ -8,11 +8,32 @@ import Typography from "@mui/material/Typography"; import { useHero } from "src/hooks/use-hero"; import { HeroStance } from "src/generated/graphql"; -const stanceDescriptions: { [x in HeroStance]?: string } = { +const stanceDescriptions: { [x in HeroStance]: string } = { [HeroStance.Normal]: "Normal stance with no pros or cons.", + + [HeroStance.Combat]: "???", + [HeroStance.Reckless]: "???", + [HeroStance.Aggressive]: "???", + [HeroStance.Defensive]: "???", + [HeroStance.NecroticBeam]: "???", + [HeroStance.CloudofKnives]: "???", + [HeroStance.FrozenOrb]: "???", + [HeroStance.MageArmor]: "???", + [HeroStance.NormalArrow]: "???", + [HeroStance.BarbedArrow]: "???", + [HeroStance.BloodHunter]: "???", + [HeroStance.DarkPresence]: "???", + [HeroStance.AuraoftheLifeless]: "???", + [HeroStance.ShieldSmash]: "???", + [HeroStance.ShieldSlash]: "???", + [HeroStance.HolySmite]: "???", + [HeroStance.VengefulSmite]: "???", + [HeroStance.WarriorsStance]: "???", + [HeroStance.Hexblade]: "???", + [HeroStance.Focus]: "???", }; -export function StanceSelector(): JSX.Element { +export function StanceSelector(): JSX.Element | null { const hero = useHero(); if (!hero) { @@ -23,7 +44,7 @@ export function StanceSelector(): JSX.Element { tooltip: stanceDescriptions[stance], })); - function handleChangeStance(stance) { + function handleChangeStance(stance: HeroStance) { console.log("Setting stance to", stance, hero); } diff --git a/src/game/crafting/destroy-items.tsx b/src/game/crafting/destroy-items.tsx index 4511091..1c2d148 100644 --- a/src/game/crafting/destroy-items.tsx +++ b/src/game/crafting/destroy-items.tsx @@ -12,6 +12,7 @@ import { Hero, InventoryItemType, useDestroyItemMutation, + EnchantmentType, } from "src/generated/graphql"; import { @@ -54,13 +55,18 @@ export function DestroyItems({ ) .sort(itemSorter); - const destroyableEnchantments: EnchantmentType[] = [ - ...new Set( - destroyableItems - .filter((item) => !isItemEquipped(hero, item)) - .map((item) => item.enchantment), - ), - ]; + const destroyableEnchantments: EnchantmentType[] = destroyableItems + .filter((item) => !isItemEquipped(hero, item)) + .map((item) => item.enchantment) + .reduce((memo, item) => { + if (!item) { + return memo; + } + if (memo.indexOf(item) < 0) { + memo.push(item); + } + return memo; + }, []); const label = "Select item to destroy"; diff --git a/src/game/crafting/disenchant-items.tsx b/src/game/crafting/disenchant-items.tsx index c46ea90..4247c89 100644 --- a/src/game/crafting/disenchant-items.tsx +++ b/src/game/crafting/disenchant-items.tsx @@ -12,6 +12,7 @@ import { Hero, InventoryItemType, useDisenchantItemMutation, + EnchantmentType, } from "src/generated/graphql"; import { @@ -54,13 +55,18 @@ export function DisenchantItems({ ) .sort(itemSorter); - const destroyableEnchantments: EnchantmentType[] = [ - ...new Set( - disenchantableItems - .filter((item) => !isItemEquipped(hero, item)) - .map((item) => item.enchantment), - ), - ]; + const destroyableEnchantments: EnchantmentType[] = disenchantableItems + .filter((item) => !isItemEquipped(hero, item)) + .map((item) => item.enchantment) + .reduce((memo, item) => { + if (!item) { + return memo; + } + if (memo.indexOf(item) < 0) { + memo.push(item); + } + return memo; + }, []); let selectedItem = filteredItems.find((item) => item.id === value); diff --git a/src/game/crafting/enchant-items.tsx b/src/game/crafting/enchant-items.tsx index 3c0a95d..ea7ded6 100644 --- a/src/game/crafting/enchant-items.tsx +++ b/src/game/crafting/enchant-items.tsx @@ -45,12 +45,12 @@ export function EnchantItems({ }) .sort(itemSorter); - const enchantmentsFound: { [x in EnchantmentType]?: number } = {}; + const enchantmentsFound = {} as { [x in EnchantmentType]: number }; const enchantments: EnchantmentType[] = [...hero.enchantments] .sort() .filter((ench) => { if (enchantmentsFound[ench]) { - enchantmentsFound[ench]++; + enchantmentsFound[ench] = (enchantmentsFound[ench] ?? 0) + 1; return false; } enchantmentsFound[ench] = 1; @@ -159,9 +159,9 @@ export function EnchantItems({ return ( {pureEnchantmentDisplayName(ench)}{" "} - {enchantmentsFound[ench] > 1 - ? `(${enchantmentsFound[ench]})` - : ""} + {enchantmentsFound[ench] && + enchantmentsFound[ench] > 1 && + `(${enchantmentsFound[ench]})`} {getEnchantmentDisplay(ench) !== "???" && (