diff --git a/ui/src/app/components/BattleDialog.tsx b/ui/src/app/components/BattleDialog.tsx deleted file mode 100644 index 56195e755..000000000 --- a/ui/src/app/components/BattleDialog.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import React from "react"; -import useUIStore from "@/app/hooks/useUIStore"; -import { MdClose } from "react-icons/md"; -import { useUiSounds, soundSelector } from "@/app/hooks/useUiSound"; - -export const BattleDialog = (props: any) => { - const showBattleDialog = useUIStore((state) => state.showBattleDialog); - const { play: clickPlay } = useUiSounds(soundSelector.click); - - return ( - <> -
showBattleDialog(false)} - /> - -
-
-

Battle Details

-
- - - {React.Children.toArray( - props.events?.map((event: any) => ( - <> - {event.type === "adventurer_attack" && ( - <> -
- {`You attack for ${event.totalDamage} ${ - event.isCriticalHit ? "critical hit!" : "damage" - }`} -
- - )} - - {event.type === "beast_attack" && ( - <> -
- {`Beast attack ${event.location} for ${event.totalDamage} ${ - event.isCriticalHit ? "critical hit!" : "damage" - }`} -
- - )} - - )) - )} -
- - ); -}; diff --git a/ui/src/app/components/FleeDialog.tsx b/ui/src/app/components/FleeDialog.tsx deleted file mode 100644 index affb6f19d..000000000 --- a/ui/src/app/components/FleeDialog.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import React from "react"; -import useUIStore from "@/app/hooks/useUIStore"; -import { MdClose } from "react-icons/md"; -import { useUiSounds, soundSelector } from "@/app/hooks/useUiSound"; - -export const FleeDialog = (props: any) => { - const showFleeDialog = useUIStore((state) => state.showFleeDialog); - const { play: clickPlay } = useUiSounds(soundSelector.click); - - return ( - <> -
showFleeDialog(false)} - /> - -
-
-

Flee Details

-
- - - {React.Children.toArray( - props.events?.map((event: any) => ( - <> - {event.type === "beast_attack" && ( - <> -
- {`Failed to flee`} -
- -
- {`Beast attack ${event.location} for ${event.totalDamage} ${ - event.isCriticalHit ? "critical hit!" : "damage" - }`} -
- - )} - - )) - )} - - {props.success ? ( -
- {`Flee success!`} -
- ) : ( -
- {`Killed by beast`} -
- )} -
- - ); -}; diff --git a/ui/src/app/components/encounters/EncounterTable.tsx b/ui/src/app/components/encounters/EncounterTable.tsx deleted file mode 100644 index 60b17b21c..000000000 --- a/ui/src/app/components/encounters/EncounterTable.tsx +++ /dev/null @@ -1,445 +0,0 @@ -import { - BladeIcon, - BludgeonIcon, - MagicIcon, - ClothIcon, - HideIcon, - MetalIcon, - HeartVitalityIcon, - CoinIcon, -} from "@/app/components/icons/Icons"; -import React, { useEffect, useMemo, useState } from "react"; -import { - listAllEncounters, - beastEncounters, -} from "@/app/lib/utils/processFutures"; -import useAdventurerStore from "@/app/hooks/useAdventurerStore"; -import { useQueriesStore } from "@/app/hooks/useQueryStore"; -import { getItemData, calculateLevel } from "@/app/lib/utils"; -import useUIStore from "@/app/hooks/useUIStore"; -import { MdClose } from "react-icons/md"; -import { Button } from "@/app/components/buttons/Button"; - -const EncounterTable = () => { - const [view, setView] = useState(0); - - const [beastTable, setBeastTable] = useState([]); - const adventurer = useAdventurerStore((state) => state.adventurer); - const adventurerEntropy = useUIStore((state) => state.adventurerEntropy); - const showEncounterTable = useUIStore((state) => state.showEncounterTable); - const hasBeast = useAdventurerStore((state) => state.computed.hasBeast); - - const formattedAdventurerEntropy = BigInt(adventurerEntropy); - - const { data } = useQueriesStore(); - - let armoritems = - data.itemsByAdventurerQuery?.items - .map((item) => ({ ...item, ...getItemData(item.item ?? "") })) - .filter((item) => { - return !["Weapon", "Ring", "Neck"].includes(item.slot!); - }) || []; - - let weaponItems = - data.itemsByAdventurerQuery?.items - .map((item) => ({ ...item, ...getItemData(item.item ?? "") })) - .filter((item) => { - return item.slot! === "Weapon"; - }) || []; - - const encounters = useMemo( - () => - listAllEncounters( - adventurer?.xp!, - formattedAdventurerEntropy, - hasBeast, - adventurer?.level! - ), - [adventurer?.xp, formattedAdventurerEntropy] - ); - - useEffect(() => { - if (view === 1) { - setBeastTable( - beastEncounters( - encounters.map((encounter: any) => encounter.xp), - formattedAdventurerEntropy - ) - ); - } - }, [encounters, formattedAdventurerEntropy, view]); - - return ( -
-
-
- - -
- - - - - - - - - - - - - - - - - - {view === 0 && ( - - {adventurerEntropy ? ( - React.Children.toArray( - encounters.map((encounter: any) => { - let [special2, special3] = encounter.specialName?.split( - " " - ) || ["no", "no"]; - let nameMatch = - encounter.encounter === "Beast" && encounter.level >= 19 - ? armoritems.find( - (item) => - item.special2 === special2 || - item.special3 === special3 - ) - : false; - let weaponMatch = - encounter.encounter === "Beast" && encounter.level >= 19 - ? weaponItems.find( - (item) => - item.special2 === special2 || - item.special3 === special3 - ) - : false; - - return ( - - - - - - - - - - - - - ); - }) - ) - ) : ( - - - Waiting for new entropy... somebody has to rotate it! - - - )} - - )} - - {view === 1 && ( - - {adventurerEntropy ? ( - React.Children.toArray( - beastTable.map((encounter: any) => { - let [special2, special3] = encounter.specialName?.split( - " " - ) || ["no", "no"]; - let nameMatch = - encounter.encounter === "Beast" && encounter.level >= 19 - ? armoritems.find( - (item) => - item.special2 === special2 || - item.special3 === special3 - ) - : false; - let weaponMatch = - encounter.encounter === "Beast" && encounter.level >= 19 - ? weaponItems.find( - (item) => - item.special2 === special2 || - item.special3 === special3 - ) - : false; - - return ( - - - - - - - - - - - - - ); - }) - ) - ) : ( - - - Waiting for randomness from Pragma! - - - )} - - )} -
- XP (lvl) - - Encounter - - Tier - - Lvl - - HP - - Type - - Location - - Avoid - - Crit - - Next XP (Lvl) -
- - {encounter.xp}. ({encounter.adventurerLevel}) - - - - {encounter.encounter} - - {encounter.encounter === "Beast" && - encounter.level >= 19 && ( - - {encounter.specialName} - - )} - - - {encounter.encounter !== "Discovery" && - encounter.tier} - {encounter.type === "Health" && ( -
- {" "} - {encounter.tier}{" "} - -
- )} - {encounter.type === "Gold" && ( -
- {" "} - {encounter.tier}{" "} - -
- )} -
-
- - {encounter.level} - - - - {encounter.health} - - - - {encounter.type === "Blade" && ( - - )} - {encounter.type === "Bludgeon" && ( - - )} - {encounter.type === "Magic" && ( - - )} - - {encounter.encounter === "Beast" && ( - <> - / - {encounter.type === "Blade" && ( - - )} - {encounter.type === "Bludgeon" && ( - - )} - {encounter.type === "Magic" && ( - - )} - - )} - - - - {encounter.location} - - - - - {encounter.dodgeRoll && - ((encounter.encounter === "Beast" - ? adventurer?.wisdom! - : adventurer?.intelligence!) > - encounter.dodgeRoll - ? "Yes" - : "No")} - - - {encounter.dodgeRoll && - `(${encounter.dodgeRoll})`} - - - 3 - ? "text-red-500" - : encounter.criticalMultiplier > 0 - ? "text-terminal-yellow" - : "" - }`} - > - {encounter.criticalMultiplier >= 0 && ( - - {encounter.criticalMultiplier > 0 - ? `${encounter.criticalMultiplier * 20}%` - : "No"} - - )} - - - {encounter.nextXp} ( - {calculateLevel(encounter.nextXp)}) - -
- - {encounter.xp}. ({encounter.adventurerLevel}) - - - {encounter.encounter} - {encounter.encounter === "Beast" && - encounter.level >= 19 && ( - - {encounter.specialName} - - )} - - - {encounter.encounter !== "Discovery" && - encounter.tier} - {encounter.type === "Health" && ( -
- {" "} - {encounter.tier}{" "} - -
- )} - {encounter.type === "Gold" && ( -
- {" "} - {encounter.tier}{" "} - -
- )} -
-
- - {encounter.level} - - - - {encounter.health} - - - - {encounter.type === "Blade" && ( - - )} - {encounter.type === "Bludgeon" && ( - - )} - {encounter.type === "Magic" && ( - - )} - - {encounter.encounter === "Beast" && ( - <> - / - {encounter.type === "Blade" && ( - - )} - {encounter.type === "Bludgeon" && ( - - )} - {encounter.type === "Magic" && ( - - )} - - )} - - - - {encounter.location} - - - - {encounter.dodgeRoll} - - - - {encounter.nextXp} ( - {calculateLevel(encounter.nextXp)}) - -
-
-
- ); -}; - -export default EncounterTable; diff --git a/ui/src/app/components/menu/ScreenMenu.tsx b/ui/src/app/components/menu/ScreenMenu.tsx index c8c026691..9622977c0 100644 --- a/ui/src/app/components/menu/ScreenMenu.tsx +++ b/ui/src/app/components/menu/ScreenMenu.tsx @@ -15,21 +15,17 @@ interface HorizontalKeyboardControlProps { buttonsData: Menu[]; disabled?: boolean[]; onButtonClick: (value: any) => void; - hideEncounters?: boolean; } const HorizontalKeyboardControl: React.FC = ({ buttonsData, onButtonClick, disabled, - hideEncounters, }) => { const { play } = useUiSounds(soundSelector.click); const [selectedIndex, setSelectedIndex] = useState(0); const buttonRefs = useRef<(HTMLButtonElement | null)[]>([]); const screen = useUIStore((state) => state.screen); - const encounterTable = useUIStore((state) => state.encounterTable); - const showEncounterTable = useUIStore((state) => state.showEncounterTable); useEffect(() => { onButtonClick(buttonsData[selectedIndex]?.screen); @@ -103,14 +99,6 @@ const HorizontalKeyboardControl: React.FC = ({ {buttonData.label} ))} -
); }; diff --git a/ui/src/app/components/navigation/Header.tsx b/ui/src/app/components/navigation/Header.tsx index aaab67943..922647e41 100644 --- a/ui/src/app/components/navigation/Header.tsx +++ b/ui/src/app/components/navigation/Header.tsx @@ -136,8 +136,6 @@ export default function Header({ const setUpgrades = useUIStore((state) => state.setUpgrades); const setUpgradeScreen = useUIStore((state) => state.setUpgradeScreen); const setSlayAdventurers = useUIStore((state) => state.setSlayAdventurers); - const encounterTable = useUIStore((state) => state.encounterTable); - const showEncounterTable = useUIStore((state) => state.showEncounterTable); const items = data.latestMarketItemsQuery ? data.latestMarketItemsQuery.items @@ -337,13 +335,6 @@ export default function Header({
- - {nextEncounter && showFuture && ( -
-
Next Big Encounter
- -
- {nextEncounter?.encounter! === "levelup" && ( - Level Up! - )} - - {nextEncounter?.encounter! === "Beast" && ( - <> -
- - Beast{" "} - {nextEncounter.level >= 19 - ? `"${nextEncounter.specialName}"` - : ""} - - - - {gameData.BEASTS[nextEncounter.id]} - - - - Tier {nextEncounter.tier} - Level {nextEncounter.level} - - - - {nextEncounter.type === "Blade" && ( - - )} - {nextEncounter.type === "Bludgeon" && ( - - )} - {nextEncounter.type === "Magic" && ( - - )} - {nextEncounter.type} - / - {nextEncounter.type === "Blade" && ( - - )} - {nextEncounter.type === "Bludgeon" && ( - - )} - {nextEncounter.type === "Magic" && ( - - )} - {nextEncounter.type === "Blade" - ? "Hide" - : nextEncounter.type === "Bludgeon" - ? "Metal" - : "Cloth"} - - {nextEncounter?.encounter === "Beast" && - nextEncounter.dodgeRoll <= adventurer?.wisdom! ? ( -
No Ambush
- ) : ( -
- Ambush! -
- - Damage to {nextEncounter.location} for{" "} - {nextEncounter.damage} - - - - -
-
- )} -
- - )} - - {nextEncounter?.encounter! === "Obstacle" && ( - <> -
- - Obstacle - - - - {gameData.OBSTACLES[parseInt(nextEncounter.id)]} - - - - Tier {nextEncounter.tier} - Level {nextEncounter.level} - - - {nextEncounter.type === "Blade" && ( - - )} - {nextEncounter.type === "Bludgeon" && ( - - )} - {nextEncounter.type === "Magic" && ( - - )} - {nextEncounter.type} - - {nextEncounter.dodgeRoll <= - adventurer?.intelligence! ? ( -
Avoided
- ) : ( -
-
- - Damage to {nextEncounter.location} for{" "} - {nextEncounter.damage} - - - - -
-
- )} -
- - )} -
-
- )} +
) : (

@@ -321,138 +135,6 @@ export default function ActionsScreen({ title="Explore" /> - - {nextEncounter && ( -

-
Next Big Encounter
- -
- {nextEncounter?.encounter! === "levelup" && ( - Level Up! - )} - - {nextEncounter?.encounter! === "Beast" && ( - <> -
- - Beast{" "} - {nextEncounter.level >= 19 - ? `"${nextEncounter.specialName}"` - : ""} - - - - {gameData.BEASTS[nextEncounter.id]} - - - - Tier {nextEncounter.tier} - Level {nextEncounter.level} - - - - {nextEncounter.type === "Blade" && ( - - )} - {nextEncounter.type === "Bludgeon" && ( - - )} - {nextEncounter.type === "Magic" && ( - - )} - {nextEncounter.type} - / - {nextEncounter.type === "Blade" && ( - - )} - {nextEncounter.type === "Bludgeon" && ( - - )} - {nextEncounter.type === "Magic" && ( - - )} - {nextEncounter.type === "Blade" - ? "Hide" - : nextEncounter.type === "Bludgeon" - ? "Metal" - : "Cloth"} - - {nextEncounter?.encounter === "Beast" && - nextEncounter.dodgeRoll <= adventurer?.wisdom! ? ( -
No Ambush
- ) : ( -
- Ambush! -
- - Damage to {nextEncounter.location} for{" "} - {nextEncounter.damage} - - - - -
-
- )} -
- - )} - - {nextEncounter?.encounter! === "Obstacle" && ( - <> -
- - Obstacle - - - - {gameData.OBSTACLES[parseInt(nextEncounter.id)]} - - - - Tier {nextEncounter.tier} - Level {nextEncounter.level} - - - {nextEncounter.type === "Blade" && ( - - )} - {nextEncounter.type === "Bludgeon" && ( - - )} - {nextEncounter.type === "Magic" && ( - - )} - {nextEncounter.type} - - {nextEncounter.dodgeRoll <= - adventurer?.intelligence! ? ( -
Avoided
- ) : ( -
-
- - Damage to {nextEncounter.location} for{" "} - {nextEncounter.damage} - - - - -
-
- )} -
- - )} -
-
- )} )} diff --git a/ui/src/app/containers/BeastScreen.tsx b/ui/src/app/containers/BeastScreen.tsx index 9ff487722..2025d2866 100644 --- a/ui/src/app/containers/BeastScreen.tsx +++ b/ui/src/app/containers/BeastScreen.tsx @@ -5,25 +5,12 @@ import { BeastDisplay } from "@/app/components/beast/BeastDisplay"; import useLoadingStore from "@/app/hooks/useLoadingStore"; import useAdventurerStore from "@/app/hooks/useAdventurerStore"; import { useQueriesStore } from "@/app/hooks/useQueryStore"; -import { processBeastName, getItemData, getBeastData } from "@/app/lib/utils"; +import { processBeastName } from "@/app/lib/utils"; import { Battle, NullBeast, ButtonData, Beast } from "@/app/types"; import { Button } from "@/app/components/buttons/Button"; import useUIStore from "@/app/hooks/useUIStore"; import ActionMenu from "@/app/components/menu/ActionMenu"; import { useController } from "@/app/context/ControllerContext"; -import { - getGoldReward, - nextAttackResult, - simulateBattle, - simulateFlee, -} from "@/app/lib/utils/processFutures"; -import { - GiBattleGearIcon, - HeartIcon, - SkullCrossedBonesIcon, -} from "@/app/components/icons/Icons"; -import { FleeDialog } from "@/app/components/FleeDialog"; -import { BattleDialog } from "@/app/components/BattleDialog"; import { useUiSounds, soundSelector } from "@/app/hooks/useUiSound"; interface BeastScreenProps { @@ -48,14 +35,8 @@ export default function BeastScreen({ const adventurer = useAdventurerStore((state) => state.adventurer); const loading = useLoadingStore((state) => state.loading); const estimatingFee = useUIStore((state) => state.estimatingFee); - const adventurerEntropy = useUIStore((state) => state.adventurerEntropy); - const battleDialog = useUIStore((state) => state.battleDialog); - const fleeDialog = useUIStore((state) => state.fleeDialog); - const showBattleDialog = useUIStore((state) => state.showBattleDialog); - const showFleeDialog = useUIStore((state) => state.showFleeDialog); const resetNotification = useLoadingStore((state) => state.resetNotification); const [showBattleLog, setShowBattleLog] = useState(false); - const [showFutures, setShowFutures] = useState(false); const hasBeast = useAdventurerStore((state) => state.computed.hasBeast); const isAlive = useAdventurerStore((state) => state.computed.isAlive); const beastData = useQueriesStore( @@ -196,73 +177,6 @@ export default function BeastScreen({ }, ]; - const [attackDetails, setAttackDetails] = useState(); - const [battleDetails, setBattleDetails] = useState(); - const [fleeDetails, setFleeDetails] = useState(); - const [goldReward, setGoldReward] = useState(0); - - const { data } = useQueriesStore(); - - useEffect(() => { - if ( - !data.itemsByAdventurerQuery || - !beastData || - !adventurer?.beastHealth || - !isAlive || - !adventurerEntropy - ) - return; - - let items: any = data.itemsByAdventurerQuery?.items - .filter((item) => item.equipped) - .map((item) => ({ - item: item.item, - ...getItemData(item.item ?? ""), - special2: item.special2, - special3: item.special3, - xp: Math.max(1, item.xp!), - })); - - const beastDetails = { - ...getBeastData(beastData?.beast ?? ""), - special2: beastData?.special2, - special3: beastData?.special3, - level: beastData.level, - seed: beastData.seed, - }; - - if (!goldReward) { - setGoldReward( - getGoldReward( - items, - beastDetails, - adventurer.xp!, - BigInt(adventurerEntropy) - ) - ); - } - - setAttackDetails( - nextAttackResult( - items, - beastDetails, - adventurer, - BigInt(adventurerEntropy) - ) - ); - setFleeDetails( - simulateFlee(items, beastDetails, adventurer, BigInt(adventurerEntropy)) - ); - setBattleDetails( - simulateBattle(items, beastDetails, adventurer, BigInt(adventurerEntropy)) - ); - }, [ - data.itemsByAdventurerQuery, - beastData, - adventurerEntropy, - adventurer?.beastHealth, - ]); - const beastName = processBeastName( beastData?.beast ?? "", beastData?.special2 ?? "", @@ -354,199 +268,12 @@ export default function BeastScreen({ {(hasBeast || formatBattles.length > 0) && } - {!showFutures && ( - - - - - - )} - - {isAlive && hasBeast && attackDetails && showFutures && ( -
-
-
- Battle Result - - {battleDetails.success && ( - - Success! - - - )} - - {!battleDetails.success && ( - - Failure! - - - )} - - - {battleDetails.healthLeft} Health left - - - - -
- - - -
- Flee Result - - {fleeDetails.flee && ( - - Success! - - - )} - - {!fleeDetails.flee && ( - - Failure! - - - )} - - - {fleeDetails.healthLeft} Health left - - - - -
-
-
- )} - - {isAlive && hasBeast && attackDetails && ( -
-
-
- Battle Result - - {battleDetails.success && ( - - Success! - - - )} - - {!battleDetails.success && ( - - Failure! - - - )} - - - {battleDetails.healthLeft} Health left - - - - -
- -
- {adventurer?.dexterity !== 0 ? ( - <> - Flee Result - - {fleeDetails.flee && ( - - Success! - - - )} - - {!fleeDetails.flee && ( - - Failure! - - - )} - - - {fleeDetails.healthLeft} Health left - - - - - - ) : ( -
No DEX
- )} -
-
-
- )} - - {battleDialog && battleDetails?.events && ( - - )} - {fleeDialog && fleeDetails?.events && ( - - )} + ); diff --git a/ui/src/app/containers/UpgradeScreen.tsx b/ui/src/app/containers/UpgradeScreen.tsx index c6d1cdd51..85ded3006 100644 --- a/ui/src/app/containers/UpgradeScreen.tsx +++ b/ui/src/app/containers/UpgradeScreen.tsx @@ -100,7 +100,24 @@ export default function UpgradeScreen({ const { play: clickPlay } = useUiSounds(soundSelector.click); useEffect(() => { - setEntropyReady(false); + if (onKatana) return; + const fetchEntropy = async () => { + const entropy = await gameContract!.call("get_adventurer_entropy", [ + adventurer?.id!, + ]); + if (entropy !== BigInt(0)) { + setEntropyReady(true); + clearInterval(interval); + } + }; + + // Call the function immediately + fetchEntropy(); + + // Set up the interval to call the function every 10 seconds + const interval = setInterval(fetchEntropy, 10000); + + return () => clearInterval(interval); // Cleanup on component unmount }, []); const setData = useQueriesStore((state) => state.setData); diff --git a/ui/src/app/hooks/useUIStore.ts b/ui/src/app/hooks/useUIStore.ts index b43adbf9f..daa748961 100644 --- a/ui/src/app/hooks/useUIStore.ts +++ b/ui/src/app/hooks/useUIStore.ts @@ -22,8 +22,7 @@ export type ScreenPage = | "wallet" | "tutorial" | "onboarding" - | "create adventurer" - | "future"; + | "create adventurer"; export type Network = | "mainnet" @@ -96,8 +95,6 @@ type State = { setIsMintingLords: (value: boolean) => void; averageBlockTime: number; setAverageBlockTime: (value: number) => void; - adventurerEntropy: bigint; - setAdventurerEntropy: (value: bigint) => void; entropyReady: boolean; setEntropyReady: (value: boolean) => void; loginScreen: boolean; @@ -107,12 +104,6 @@ type State = { onMainnet: boolean; onSepolia: boolean; onKatana: boolean; - encounterTable: boolean; - battleDialog: boolean; - fleeDialog: boolean; - showEncounterTable: (value: boolean) => void; - showBattleDialog: (value: boolean) => void; - showFleeDialog: (value: boolean) => void; vitBoostRemoved: number; setVitBoostRemoved: (value: number) => void; }; @@ -185,8 +176,6 @@ const useUIStore = create((set) => ({ setIsMintingLords: (value) => set({ isMintingLords: value }), averageBlockTime: 0, setAverageBlockTime: (value) => set({ averageBlockTime: value }), - adventurerEntropy: BigInt(0), - setAdventurerEntropy: (value) => set({ adventurerEntropy: value }), entropyReady: false, setEntropyReady: (value) => set({ entropyReady: value }), loginScreen: false, @@ -201,12 +190,6 @@ const useUIStore = create((set) => ({ onMainnet: false, onSepolia: false, onKatana: false, - encounterTable: false, - battleDialog: false, - fleeDialog: false, - showEncounterTable: (value) => set({ encounterTable: value }), - showBattleDialog: (value) => set({ battleDialog: value }), - showFleeDialog: (value) => set({ fleeDialog: value }), vitBoostRemoved: 0, setVitBoostRemoved: (value) => set({ vitBoostRemoved: value }), })); diff --git a/ui/src/app/lib/classes.ts b/ui/src/app/lib/classes.ts index a742af7e2..908e038aa 100644 --- a/ui/src/app/lib/classes.ts +++ b/ui/src/app/lib/classes.ts @@ -5,7 +5,6 @@ export class AdventurerClass implements Adventurer { [key: string]: number | string | Date | undefined; id?: number; // Adventurer ID owner?: string; // Hex address of the owner - entropy?: string; // Entropy of the adventurer name?: string; // Name of the adventurer order?: string; // Order of the adventurer health?: number; // Health of the adventurer @@ -38,7 +37,6 @@ export class AdventurerClass implements Adventurer { const { id, owner, - entropy, name, order, health, @@ -70,7 +68,6 @@ export class AdventurerClass implements Adventurer { this.id = id; this.owner = owner; - this.entropy = entropy; this.name = name; this.order = order; this.health = health; diff --git a/ui/src/app/lib/utils/processFutures.ts b/ui/src/app/lib/utils/processFutures.ts deleted file mode 100644 index eacb1d57c..000000000 --- a/ui/src/app/lib/utils/processFutures.ts +++ /dev/null @@ -1,1017 +0,0 @@ -import * as starknet from "@scure/starknet"; -import { calculateLevel } from "."; - -const MAX_ID = BigInt(75); -const U128_MAX = BigInt("340282366920938463463374607431768211455"); - -interface Beast { - encounter: string; - id: bigint; - type: string; - tier: number; - level: number; - health: number; - location: string; - dodgeRoll: number; - nextXp: number; - specialName: string; - criticalMultiplier: number; - damage: number; -} - -interface Encounter { - encounter: string; - id?: bigint; - type: string; - tier: string | number; - level?: number; - health?: number; - location?: string; - dodgeRoll?: number; - nextXp: number; - specialName?: string; - criticalMultiplier?: number; - damage?: number; -} - -interface Item { - slot: string; - item?: string; - type?: string; - xp?: number; - level?: number; - tier?: number; - special2?: string; - special3?: string; -} - -interface CombatResult { - totalDamage: number; - isCriticalHit: boolean; -} - -interface BattleEvent { - type: string; - totalDamage: number; - isCriticalHit: boolean; - beastDamageType?: string; - location?: string; -} - -export function beastEncounters( - xpList: number[], - adventurerEntropy: bigint -): any[] { - let beasts: any[] = []; - - xpList.forEach((xp) => { - const level = BigInt(Math.floor(Math.sqrt(xp))); - - let { rnd2 } = getRandomness(xp, adventurerEntropy); - - beasts.push({ - ...beastEncounter(adventurerEntropy, level, xp, rnd2), - adventurerLevel: Math.floor(Math.sqrt(xp)), - xp: xp, - }); - }); - - return beasts; -} - -export function listAllEncounters( - xp: number, - adventurerEntropy: bigint, - hasBeast: boolean, - adventurerLevel: number -): Encounter[] { - let encounters: Encounter[] = []; - - if (!adventurerEntropy) { - return encounters; - } - - if (!xp || xp === 0) { - xp = 4; - } - - encounters = recurseEncounters( - encounters, - [xp], - adventurerEntropy, - hasBeast, - adventurerLevel - ); - - return encounters; -} - -function recurseEncounters( - encounters: Encounter[], - xpList: number[], - adventurerEntropy: bigint, - hasBeast: boolean, - adventurerLevel: number -): Encounter[] { - if (encounters.length > 49) { - return encounters; - } - - let xp = xpList.sort((a, b) => a - b).shift()!; - - if (calculateLevel(xp) > adventurerLevel) { - return encounters; - } - - let nextEncounter = { - ...getNextEncounter(xp, adventurerEntropy, undefined, hasBeast), - adventurerLevel: Math.floor(Math.sqrt(xp)), - xp: xp, - }; - encounters.push(nextEncounter); - - if (nextEncounter.encounter === "Beast") { - if (!xpList.includes(xp + 1)) { - xpList.push(xp + 1); - } - } - - if (!xpList.includes(nextEncounter.nextXp)) { - xpList.push(nextEncounter.nextXp); - } - - return recurseEncounters( - encounters, - xpList, - adventurerEntropy, - false, - adventurerLevel - ); -} - -export function getNextBigEncounter( - lvl: number, - xp: number, - adventurerEntropy: bigint, - items: Item[] -): Encounter { - let newLevel = Math.floor(Math.sqrt(xp)); - if (newLevel > lvl) { - return { encounter: "levelup", type: "", tier: "", nextXp: xp + 1 }; - } - - let encounter = getNextEncounter(xp, adventurerEntropy, items); - if (encounter.encounter !== "Discovery") { - return encounter; - } - - return getNextBigEncounter(lvl, xp + 1, adventurerEntropy, items); -} - -function getNextEncounter( - xp: number, - adventurerEntropy: bigint, - items?: Item[], - hasBeast?: boolean -): Encounter { - let { rnd1, rnd2 } = getRandomness(xp, adventurerEntropy); - const level = BigInt(Math.floor(Math.sqrt(xp))); - - let encounter = Number(rnd1 % BigInt(3)); - - if (hasBeast || encounter === 0) { - return beastEncounter(adventurerEntropy, level, xp, rnd2, items); - } else if (encounter === 1) { - return obstacleEncounter(level, rnd2, xp, items); - } else { - return discoveryEncounter(level, rnd2, xp); - } -} - -function getRandomness(xp: number, adventurerEntropy: bigint) { - let params = [BigInt(xp), adventurerEntropy]; - - let poseidon = starknet.poseidonHashMany(params); - let d = poseidon / U128_MAX; - let r = poseidon % U128_MAX; - - return { rnd1: r, rnd2: d }; -} - -function getRandomnessWithHealth( - xp: number, - health: number, - adventurerEntropy: bigint -) { - let params = [BigInt(xp), BigInt(health), adventurerEntropy]; - - let poseidon = starknet.poseidonHashMany(params); - - let d = poseidon / U128_MAX; - let r = poseidon % U128_MAX; - - return { rnd1: r, rnd2: d }; -} - -function getBaseDiscoveryAmount(level: bigint, entropy: bigint): bigint { - let discovery_multiplier = level / BigInt(5); - let discovery_range = (discovery_multiplier + BigInt(1)) * BigInt(3); - let discovery_amount = BigInt(1) + (entropy % discovery_range); - - return discovery_amount; -} - -function getAttackLocation(entropy: bigint): string { - let slots = BigInt(5); - - let rnd_slot = Number(entropy % slots); - - if (rnd_slot == 0) { - return "Chest"; - } else if (rnd_slot == 1) { - return "Head"; - } else if (rnd_slot == 2) { - return "Waist"; - } else if (rnd_slot == 3) { - return "Foot"; - } else if (rnd_slot == 4) { - return "Hand"; - } - return "Unknown"; -} - -function getXpReward(level: bigint, tier: bigint): bigint { - let xp = ((BigInt(6) - tier) * level) / BigInt(2); - - if (xp < 4) { - return BigInt(4); - } - - return xp; -} - -function abilityBasedAvoidThreat(level: bigint, entropy: bigint): bigint { - let dice_roll = entropy % level; - return dice_roll; -} - -function getObstacleLevel(level: bigint, entropy: bigint): bigint { - let obstacleLevel = BigInt(1) + (entropy % (level * BigInt(2))); - - if (level >= 50) { - obstacleLevel += BigInt(80); - } else if (level >= 40) { - obstacleLevel += BigInt(40); - } else if (level >= 30) { - obstacleLevel += BigInt(20); - } else if (level >= 20) { - obstacleLevel += BigInt(10); - } - - return obstacleLevel; -} - -function getTier(id: bigint): bigint { - if ((id >= 1 && id <= 5) || (id >= 26 && id < 31) || (id >= 51 && id < 56)) { - return BigInt(1); - } else if ( - (id >= 6 && id < 11) || - (id >= 31 && id < 36) || - (id >= 56 && id < 61) - ) { - return BigInt(2); - } else if ( - (id >= 11 && id < 16) || - (id >= 36 && id < 41) || - (id >= 61 && id < 66) - ) { - return BigInt(3); - } else if ( - (id >= 16 && id < 21) || - (id >= 41 && id < 46) || - (id >= 66 && id < 71) - ) { - return BigInt(4); - } else { - return BigInt(5); - } -} - -function getType(id: bigint): string { - if (id >= 0 && id < 26) { - return "Magic"; - } else if (id < 51) { - return "Blade"; - } else if (id < 76) { - return "Bludgeon"; - } else { - return "None"; - } -} - -function getBeastHealth(level: bigint, seed: bigint): bigint { - let health = BigInt(1) + (seed % (level * BigInt(15))); - - if (level >= 50) { - health += BigInt(500); - } else if (level >= 40) { - health += BigInt(400); - } else if (level >= 30) { - health += BigInt(200); - } else if (level >= 20) { - health += BigInt(100); - } else { - health += BigInt(10); - } - - if (health > 511) { - return BigInt(511); - } else { - return health; - } -} - -function beastEncounter( - adventurerEntropy: bigint, - level: bigint, - xp: number, - rnd2: bigint, - items?: Item[] -): Beast { - let seed = getRandomness(xp, adventurerEntropy).rnd1; - - let beast_id = (seed % MAX_ID) + BigInt(1); - - let beast_health = getBeastHealth(level, seed); - - let beast_tier = getTier(beast_id); - let beast_type = getType(beast_id); - let beast_level = getObstacleLevel(level, seed); - - let ambush_location = getAttackLocation(rnd2); - let roll = abilityBasedAvoidThreat(level, seed); - let xp_reward = getXpReward(beast_level, beast_tier); - let specialName = getSpecialName(seed); - let criticalMultiplier = critical_multiplier(10, rnd2); - - let adventurerArmor = items?.find((item) => item.slot === ambush_location); - - let damage = calculateEncounterDamage( - beast_type, - Number(beast_tier), - Number(beast_level), - adventurerArmor, - 2, - criticalMultiplier - ); - - return { - encounter: "Beast", - id: beast_id, - type: beast_type, - tier: Number(beast_tier), - level: Number(beast_level), - health: Number(beast_health), - location: ambush_location, - dodgeRoll: Number(roll) + 1, - nextXp: xp + Number(xp_reward), - specialName, - criticalMultiplier, - damage, - }; -} - -function obstacleEncounter( - level: bigint, - rnd2: bigint, - xp: number, - items?: Item[] -): Encounter { - let obstacle_id = (rnd2 % MAX_ID) + BigInt(1); - let obstacle_level = getObstacleLevel(level, rnd2); - let obstacle_tier = getTier(obstacle_id); - let obstacle_type = getType(obstacle_id); - - let location = getAttackLocation(rnd2); - let roll = abilityBasedAvoidThreat(level, rnd2); - let xp_reward = getXpReward(obstacle_level, obstacle_tier); - let criticalMultiplier = critical_multiplier(10, rnd2); - - let adventurerArmor = items?.find((item) => item.slot === location); - - let damage = calculateEncounterDamage( - obstacle_type, - Number(obstacle_tier), - Number(obstacle_level), - adventurerArmor, - 2, - criticalMultiplier - ); - - return { - encounter: "Obstacle", - id: obstacle_id, - type: obstacle_type, - tier: Number(obstacle_tier), - level: Number(obstacle_level), - location: location, - dodgeRoll: Number(roll) + 1, - nextXp: xp + Number(xp_reward), - criticalMultiplier, - damage, - }; -} - -function discoveryEncounter( - level: bigint, - rnd2: bigint, - xp: number -): Encounter { - let discovery_type = rnd2 % BigInt(2); - - let discovery_amount = getBaseDiscoveryAmount(level, rnd2); - - return { - encounter: "Discovery", - type: discovery_type === BigInt(0) ? "Gold" : "Health", - tier: `${Number(discovery_amount)}`, - nextXp: xp + 1, - }; -} - -function getElementalType(weapon_type?: string, armor_type?: string): string { - if (!weapon_type) return "Weak"; - if (!armor_type) return "Strong"; - - if ( - (weapon_type === "Magic" && armor_type === "Metal") || - (weapon_type === "Blade" && armor_type === "Cloth") || - (weapon_type === "Bludgeon" && armor_type === "Hide") - ) { - return "Strong"; - } - - if ( - (weapon_type === "Magic" && armor_type === "Hide") || - (weapon_type === "Blade" && armor_type === "Metal") || - (weapon_type === "Bludgeon" && armor_type === "Cloth") - ) { - return "Weak"; - } - - return "Fair"; -} - -function elementalAdjustedDamage( - base_attack: number, - weapon_type: string, - armor_type: string -): number { - let elemental_effect = Math.floor(base_attack / 2); - - if ( - (weapon_type === "Magic" && armor_type === "Metal") || - (weapon_type === "Blade" && armor_type === "Cloth") || - (weapon_type === "Bludgeon" && armor_type === "Hide") - ) { - let damage = base_attack + elemental_effect; - return damage; - } - - if ( - (weapon_type === "Magic" && armor_type === "Hide") || - (weapon_type === "Blade" && armor_type === "Metal") || - (weapon_type === "Bludgeon" && armor_type === "Cloth") - ) { - let damage = base_attack - elemental_effect; - return damage; - } - - return base_attack; -} - -function strength_dmg(damage: number, strength: number): number { - if (strength == 0) { - return 0; - } - - return (damage * strength * 10) / 100; -} - -function critical_multiplier(luck: number, entropy: bigint): number { - if (luck > Number(entropy % BigInt(100))) { - return Number(entropy % BigInt(5)) + 1; - } - - return 0; -} - -function critical_hit_bonus( - base_damage: number, - luck: number, - ring: Item | undefined, - entropy: bigint -): number { - let total = 0; - - if (luck > Number(entropy % BigInt(100))) { - let damage_boost_base = Math.floor(base_damage / 5); - let damage_multiplier = Number(entropy % BigInt(5)) + 1; - total = damage_boost_base * damage_multiplier; - - if (ring?.item === "Titanium Ring" && total > 0) { - total += Math.floor((total * 3 * Math.floor(Math.sqrt(ring.xp!))) / 100); - } - } - - return total; -} - -function weapon_special_bonus( - damage: number, - weapon: Item, - beast: Beast, - ring: Item | undefined, - entropy: bigint -): number { - let special2_bonus = - weapon.special2 && weapon.special2 === beast.specialName - ? Math.floor(damage * (Number(entropy % BigInt(4)) + 4)) - : 0; - let special3_bonus = - weapon.special3 && weapon.special3 === beast.specialName - ? Math.floor(damage / 4) * (Number(entropy % BigInt(4)) + 1) - : 0; - - let total_bonus = special2_bonus + special3_bonus; - - if (ring?.item === "Platinum Ring" && total_bonus > 0) { - total_bonus += Math.floor( - (total_bonus * 3 * Math.floor(Math.sqrt(ring.xp!))) / 100 - ); - } - - return total_bonus; -} - -function calculateDamage( - weapon: any | undefined, - beast: any | undefined, - ring: Item | undefined, - strength: number, - luck: number, - entropy: bigint, - minimumDmg: number -): CombatResult { - if (!weapon) return { totalDamage: minimumDmg, isCriticalHit: false }; - - let elemental_damage = 0; - let special_bonus = 0; - let base_armor = 0; - - let weapon_lvl = weapon.level || Math.floor(Math.sqrt(weapon.xp!)); - let base_attack = weapon_lvl * (6 - weapon.tier!); - - if (beast) { - let beast_lvl = beast.level || Math.floor(Math.sqrt(beast.xp!)); - let weapon_type = weapon.type || weapon.item! || weapon.attack!; - let beast_armor = beast.armor || beast.type; - - base_armor = beast_lvl * (6 - beast.tier); - elemental_damage = elementalAdjustedDamage( - base_attack, - weapon_type, - beast_armor - ); - special_bonus = weapon_special_bonus( - elemental_damage, - weapon, - beast, - ring, - entropy - ); - } else { - elemental_damage = base_attack * 1.5; - } - - let strength_bonus = strength_dmg(elemental_damage, strength); - let crit_bonus = critical_hit_bonus(elemental_damage, luck, ring, entropy); - - let total_attack = - elemental_damage + strength_bonus + crit_bonus + special_bonus; - let total_damage = Math.floor(total_attack - base_armor); - - return { - totalDamage: Math.max(minimumDmg, total_damage), - isCriticalHit: crit_bonus > 0, - }; -} - -function calculateEncounterDamage( - type: string | undefined, - tier: number, - level: number, - adventurerArmor: Item | undefined, - minimumDmg: number, - critMultiplier: number -) { - if (!type) return minimumDmg; - - let crit_bonus = critMultiplier * 20; - - let base_attack = level * (6 - tier!); - - let base_armor = 0; - let elemental_damage = 0; - - if (adventurerArmor) { - base_armor = - calculateLevel(adventurerArmor?.xp!) * (6 - adventurerArmor?.tier!); - elemental_damage = elementalAdjustedDamage( - base_attack, - type, - adventurerArmor?.type! - ); - } else { - elemental_damage = base_attack * 1.5; - } - - let total_attack = elemental_damage + crit_bonus; - let total_damage = Math.floor(total_attack - base_armor); - - return Math.max(minimumDmg, total_damage); -} - -function neck_reduction( - item: Item | undefined, - neck: Item | undefined -): boolean { - if (!item || !neck) return false; - - if (item.type === "Cloth" && neck.item === "Amulet") { - return true; - } - - if (item.type === "Hide" && neck.item === "Pendant") { - return true; - } - - if (item.type === "Metal" && neck.item === "Necklace") { - return true; - } - - return false; -} - -function beastCounterAttack( - items: Item[], - beast: any, - rnd1: bigint, - rnd2: bigint -) { - let attack_location = getAttackLocation(rnd2); - let item = items.find((item) => item.slot === attack_location); - let combatResult = calculateDamage(beast, item, undefined, 0, 10, rnd1, 2); - - let neck = items.find((item) => item.slot === "Neck"); - if (neck_reduction(item, neck)) { - combatResult.totalDamage -= Math.floor( - (Math.floor(Math.sqrt(item!.xp!)) * - (6 - item!.tier!) * - Math.floor(Math.sqrt(neck!.xp!)) * - 3) / - 100 - ); - } - - let elementalType = getElementalType(beast?.type, item?.type); - - return { - damage: Math.max(combatResult.totalDamage, 2), - isCrit: combatResult.isCriticalHit, - beastDamageType: elementalType, - location: attack_location, - }; -} - -export function nextAttackResult( - items: Item[], - beast: any, - adventurer: any, - adventurerEntropy: bigint -): { - beastFatal: boolean; - damage: number; - damageType: string; - isCriticalHit: boolean; - counter: number; - counterCrit: boolean; - adventurerFatal?: boolean; - beastDamageType?: string; - location?: string; -} { - let { rnd1, rnd2 } = getRandomnessWithHealth( - adventurer.xp, - adventurer.health, - adventurerEntropy - ); - let weapon = items.find((item) => item.slot === "Weapon"); - let ring = items.find((item) => item.slot === "Ring"); - let combatResult = calculateDamage( - weapon, - beast, - ring, - adventurer.strength, - adventurer.luck, - rnd1, - 4 - ); - let elementalType = getElementalType(weapon?.type, beast?.type); - - if (combatResult.totalDamage >= adventurer.beastHealth) { - return { - beastFatal: true, - damage: combatResult.totalDamage, - damageType: elementalType, - isCriticalHit: combatResult.isCriticalHit, - counter: 0, - counterCrit: false, - }; - } - - let beastCounter = beastCounterAttack(items, beast, rnd1, rnd2); - - return { - beastFatal: false, - adventurerFatal: beastCounter.damage >= adventurer.health, - damage: combatResult.totalDamage, - damageType: elementalType, - isCriticalHit: combatResult.isCriticalHit, - counter: beastCounter.damage, - counterCrit: beastCounter.isCrit, - beastDamageType: beastCounter.beastDamageType, - location: beastCounter.location, - }; -} - -export function getGoldReward( - items: Item[], - beast: any, - xp: number, - adventurerEntropy: bigint -): number { - if (xp < 1) { - return 4; - } - - let seed = getRandomness(xp, adventurerEntropy).rnd1; - - let ring = items.find( - (item) => item.slot === "Ring" && item.item === "Gold Ring" - ); - - let base_reward = Math.max( - 4, - Math.floor(((6 - beast.tier) * beast.level) / 2 / 2) - ); - - let bonus_base = Math.floor(base_reward / 4); - let bonus_multiplier = Number(seed % BigInt(5)); - - base_reward += Math.floor(bonus_base * bonus_multiplier); - - if (ring) { - base_reward += Math.floor( - (base_reward * Math.floor(Math.sqrt(ring.xp!)) * 3) / 100 - ); - } - - return Math.max(4, base_reward); -} - -function getSpecialName(seed: bigint): string { - let special2 = 1 + Number(seed % BigInt(69)); - let special3 = 1 + Number(seed % BigInt(18)); - return `${ITEM_NAME_PREFIXES[special2]} ${ITEM_NAME_SUFFIXES[special3]}`; -} - -export function simulateBattle( - items: Item[], - beast: any, - adventurer: any, - adventurerEntropy: bigint -): { success: boolean; healthLeft: number; events: BattleEvent[] } { - let health = adventurer.health; - let beastHealth = adventurer.beastHealth; - - let events: BattleEvent[] = []; - - while (health > 0) { - let { rnd1, rnd2 } = getRandomnessWithHealth( - adventurer.xp, - health, - adventurerEntropy - ); - let weapon = items.find((item) => item.slot === "Weapon"); - let ring = items.find((item) => item.slot === "Ring"); - let combatResult = calculateDamage( - weapon, - beast, - ring, - adventurer.strength, - adventurer.luck, - rnd1, - 4 - ); - - events.push({ - type: "adventurer_attack", - totalDamage: combatResult.totalDamage, - isCriticalHit: combatResult.isCriticalHit, - beastDamageType: undefined, - location: undefined, - }); - - if (combatResult.totalDamage >= beastHealth) { - return { - success: true, - healthLeft: health, - events, - }; - } - - let beastCounter = beastCounterAttack(items, beast, rnd1, rnd2); - - events.push({ - type: "beast_attack", - totalDamage: beastCounter.damage, - isCriticalHit: beastCounter.isCrit, - beastDamageType: beastCounter.beastDamageType, - location: beastCounter.location, - }); - - if (beastCounter.damage >= health) { - return { - success: false, - healthLeft: 0, - events, - }; - } - - beastHealth -= combatResult.totalDamage; - health -= beastCounter.damage; - } - - return { - success: false, - healthLeft: 0, - events, - }; -} - -export function simulateFlee( - items: Item[], - beast: any, - adventurer: any, - adventurerEntropy: bigint -): { flee: boolean; healthLeft: number; events: BattleEvent[] } { - if (!adventurer.dexterity) { - return { - flee: false, - healthLeft: 0, - events: [], - }; - } - - const level = BigInt(Math.floor(Math.sqrt(adventurer.xp))); - let health = adventurer.health; - - let events: BattleEvent[] = []; - - while (health > 0) { - let { rnd1, rnd2 } = getRandomnessWithHealth( - adventurer.xp, - health, - adventurerEntropy - ); - let roll = abilityBasedAvoidThreat(level, rnd1); - - if (adventurer.dexterity > roll) { - return { - flee: true, - healthLeft: health, - events, - }; - } - - let beastCounter = beastCounterAttack(items, beast, rnd2, rnd2); - health -= beastCounter.damage; - - events.push({ - type: "beast_attack", - totalDamage: beastCounter.damage, - isCriticalHit: beastCounter.isCrit, - beastDamageType: beastCounter.beastDamageType, - location: beastCounter.location, - }); - } - - return { - flee: false, - healthLeft: 0, - events, - }; -} - -const ITEM_NAME_PREFIXES: { [key: number]: string } = { - 1: "Agony", - 2: "Apocalypse", - 3: "Armageddon", - 4: "Beast", - 5: "Behemoth", - 6: "Blight", - 7: "Blood", - 8: "Bramble", - 9: "Brimstone", - 10: "Brood", - 11: "Carrion", - 12: "Cataclysm", - 13: "Chimeric", - 14: "Corpse", - 15: "Corruption", - 16: "Damnation", - 17: "Death", - 18: "Demon", - 19: "Dire", - 20: "Dragon", - 21: "Dread", - 22: "Doom", - 23: "Dusk", - 24: "Eagle", - 25: "Empyrean", - 26: "Fate", - 27: "Foe", - 28: "Gale", - 29: "Ghoul", - 30: "Gloom", - 31: "Glyph", - 32: "Golem", - 33: "Grim", - 34: "Hate", - 35: "Havoc", - 36: "Honour", - 37: "Horror", - 38: "Hypnotic", - 39: "Kraken", - 40: "Loath", - 41: "Maelstrom", - 42: "Mind", - 43: "Miracle", - 44: "Morbid", - 45: "Oblivion", - 46: "Onslaught", - 47: "Pain", - 48: "Pandemonium", - 49: "Phoenix", - 50: "Plague", - 51: "Rage", - 52: "Rapture", - 53: "Rune", - 54: "Skull", - 55: "Sol", - 56: "Soul", - 57: "Sorrow", - 58: "Spirit", - 59: "Storm", - 60: "Tempest", - 61: "Torment", - 62: "Vengeance", - 63: "Victory", - 64: "Viper", - 65: "Vortex", - 66: "Woe", - 67: "Wrath", - 68: "Lights", - 69: "Shimmering", -}; - -const ITEM_NAME_SUFFIXES: { [key: number]: string } = { - 1: "Bane", - 2: "Root", - 3: "Bite", - 4: "Song", - 5: "Roar", - 6: "Grasp", - 7: "Instrument", - 8: "Glow", - 9: "Bender", - 10: "Shadow", - 11: "Whisper", - 12: "Shout", - 13: "Growl", - 14: "Tear", - 15: "Peak", - 16: "Form", - 17: "Sun", - 18: "Moon", -}; diff --git a/ui/src/app/lib/utils/syscalls.ts b/ui/src/app/lib/utils/syscalls.ts index 563d09929..1ae57c0bf 100644 --- a/ui/src/app/lib/utils/syscalls.ts +++ b/ui/src/app/lib/utils/syscalls.ts @@ -879,6 +879,7 @@ export function syscalls({ setEquipItems([]); setDropItems([]); !onKatana && getEthBalance(); + setEntropyReady(false); } catch (e) { console.log(e); stopLoading(e, true); @@ -1181,6 +1182,7 @@ export function syscalls({ setScreen("play"); !onKatana && getEthBalance(); + setEntropyReady(false); } catch (e) { console.log(e); stopLoading(e, true); diff --git a/ui/src/app/page.tsx b/ui/src/app/page.tsx index 848f5803d..52f6d6b0f 100644 --- a/ui/src/app/page.tsx +++ b/ui/src/app/page.tsx @@ -59,7 +59,6 @@ import useControls from "@/app/hooks/useControls"; import { networkConfig } from "@/app/lib/networkConfig"; import useNetworkAccount from "@/app/hooks/useNetworkAccount"; import { useController } from "@/app/context/ControllerContext"; -import EncounterTable from "@/app/components/encounters/EncounterTable"; const allMenuItems: Menu[] = [ { id: 1, label: "Start", screen: "start", disabled: false }, @@ -124,11 +123,6 @@ function Home() { const setSpecialBeastDefeated = useUIStore( (state) => state.setSpecialBeastDefeated ); - const encounterTable = useUIStore((state) => state.encounterTable); - const setAdventurerEntropy = useUIStore( - (state) => state.setAdventurerEntropy - ); - const { contract: gameContract } = useContract({ address: networkConfig[network!].gameAddress, abi: Game, @@ -165,7 +159,6 @@ function Home() { const showDeathDialog = useUIStore((state) => state.showDeathDialog); const setStartOption = useUIStore((state) => state.setStartOption); const setEntropyReady = useUIStore((state) => state.setEntropyReady); - const adventurerEntropy = useUIStore((state) => state.adventurerEntropy); const [accountChainId, setAccountChainId] = useState< constants.StarknetChainId | undefined >(); @@ -528,29 +521,6 @@ function Home() { } }, [onboarded]); - useEffect(() => { - const fetchEntropy = async () => { - if (adventurer?.id) { - const entropy = await gameContract!.call("get_adventurer_entropy", [ - adventurer?.id!, - ]); - if (entropy !== BigInt(0)) { - setAdventurerEntropy(BigInt(entropy.toString())); - setEntropyReady(true); - clearInterval(interval); - } - } - }; - - // Call the function immediately - fetchEntropy(); - - // Set up the interval to call the function every 10 seconds - const interval = setInterval(fetchEntropy, 10000); - - return () => clearInterval(interval); // Cleanup on component unmount - }, [adventurer?.level]); - if (!isConnected && disconnected) { return ; } @@ -615,9 +585,6 @@ function Home() { setScreen(value); }} disabled={mobileMenuDisabled} - hideEncounters={ - adventurerEntropy === BigInt(0) || !adventurer?.id - } />
@@ -673,12 +640,6 @@ function Home() { {screen === "settings" && } {screen === "player" && } {screen === "wallet" && } - - {encounterTable && ( -
- -
- )}