Skip to content

Commit

Permalink
house keeping
Browse files Browse the repository at this point in the history
  • Loading branch information
starknetdev committed Oct 4, 2023
1 parent ed4efc4 commit 55b9297
Show file tree
Hide file tree
Showing 27 changed files with 30 additions and 191 deletions.
11 changes: 0 additions & 11 deletions ui/src/app/components/actions/DiscoveryDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import useAdventurerStore from "../../hooks/useAdventurerStore";
import { processBeastName } from "../../lib/utils";
import {
HeartIcon,
CoinIcon,
GiBruteIcon,
SkullCrossedBonesIcon,
Expand Down Expand Up @@ -143,15 +141,6 @@ export const DiscoveryDisplay = ({ discoveryData }: DiscoveryProps) => {
</span>
);
}

if (discoveryData?.subDiscoveryType === "XP") {
return (
<span className="flex flex-row items-center justify-between">
<p>NICE! Discovered {discoveryData.outputAmount} XP!</p>
<GiStarsStackIcon />
</span>
);
}
}

return null;
Expand Down
2 changes: 0 additions & 2 deletions ui/src/app/components/actions/KillAdventurer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import useTransactionCartStore from "@/app/hooks/useTransactionCartStore";
import { useUiSounds, soundSelector } from "../../hooks/useUiSound";
import useCustomQuery from "@/app/hooks/useCustomQuery";
import { getAdventurerById } from "../../hooks/graphql/queries";
import useLoadingStore from "@/app/hooks/useLoadingStore";
import TopInfo from "../adventurer/TopInfo";
import { useQueriesStore } from "@/app/hooks/useQueryStore";
import { useBlock } from "@starknet-react/core";
Expand All @@ -17,7 +16,6 @@ export default function KillAdventurer() {
const [adventurerTarget, setAdventurerTarget] = useState("");
const addToCalls = useTransactionCartStore((s) => s.addToCalls);
const { play: clickPlay } = useUiSounds(soundSelector.click);
const txAccepted = useLoadingStore((state) => state.txAccepted);
const { data: blockData } = useBlock({
refetchInterval: false,
});
Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/components/adventurer/DeathDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { useQueriesStore } from "@/app/hooks/useQueryStore";
import GlitchEffect from "../animations/GlitchEffect";
import PixelatedImage from "../animations/PixelatedImage";
import { getDeathMessageByRank } from "../../lib/utils";
import Image from "next/image";

export const DeathDialog = () => {
const messageRef = useRef<HTMLSpanElement>(null);
Expand All @@ -25,7 +24,7 @@ export const DeathDialog = () => {
const showDeathDialog = useUIStore((state) => state.showDeathDialog);
const [imageLoading, setImageLoading] = useState(false);

const { data, refetch, setData } = useQueriesStore();
const { refetch, setData } = useQueriesStore();

useCustomQuery("adventurersByXPQuery", getAdventurerByXP, undefined);

Expand Down
17 changes: 3 additions & 14 deletions ui/src/app/components/adventurer/Info.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import { useMemo } from "react";
import { Adventurer, NullAdventurer, NullItem } from "../../types";
import { getItemsByAdventurer } from "../../hooks/graphql/queries";
import { HeartIcon, CoinIcon, BagIcon, QuestionMarkIcon } from "../icons/Icons";
import { HeartIcon, CoinIcon, QuestionMarkIcon } from "../icons/Icons";
import { ItemDisplay } from "./ItemDisplay";
import LevelBar from "./LevelBar";
import {
calculateLevel,
getRealmNameById,
getKeyFromValue,
countOccurrences,
} from "../../lib/utils";
import { getRealmNameById, getKeyFromValue } from "../../lib/utils";
import { useQueriesStore } from "../../hooks/useQueryStore";
import useCustomQuery from "../../hooks/useCustomQuery";
import useUIStore from "../../hooks/useUIStore";
import useLoadingStore from "../../hooks/useLoadingStore";
import { Item } from "@/app/types";
import { HealthCountDown } from "../CountDown";
import { GameData } from "../GameData";
Expand All @@ -32,9 +23,7 @@ export default function Info({
upgradeCost,
}: InfoProps) {
const formatAdventurer = adventurer ? adventurer : NullAdventurer;
const profile = useUIStore((state) => state.profile);
const { data, isLoading, data: storeData } = useQueriesStore();
const txAccepted = useLoadingStore((state) => state.txAccepted);
const { data } = useQueriesStore();
const dropItems = useUIStore((state) => state.dropItems);
const setDropItems = useUIStore((state) => state.setDropItems);
const potionAmount = useUIStore((state) => state.potionAmount);
Expand Down
5 changes: 0 additions & 5 deletions ui/src/app/components/adventurer/TopInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ export default function TopInfo({ adventurer }: InfoProps) {
<LevelBar xp={formatAdventurer.xp ?? 0} />
</div>
</div>
{/* {0 === 0 && (
<div className="absolute w-full h-full flex items-center justify-center backdrop-blur-[1px]">
<p className="text-6xl font-bold text-red-600 uppercase">DEAD</p>
</div>
)} */}
</div>
</div>
) : (
Expand Down
5 changes: 2 additions & 3 deletions ui/src/app/components/beast/BattleDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ import useAdventurerStore from "../../hooks/useAdventurerStore";
import { useQueriesStore } from "../../hooks/useQueryStore";
import { getRankFromList, getOrdinalSuffix } from "../../lib/utils";
import { processBeastName, getBeastData } from "../../lib/utils";
import { Adventurer, Battle, Discovery } from "@/app/types";
import { Battle } from "@/app/types";
import Head from "../../../../public/icons/loot/head.svg";
import Hand from "../../../../public/icons/loot/hand.svg";
import Chest from "../../../../public/icons/loot/chest.svg";
import Waist from "../../../../public/icons/loot/waist.svg";
import Foot from "../../../../public/icons/loot/foot.svg";
import { appUrl, battle } from "@/app/lib/constants";
import { appUrl } from "@/app/lib/constants";
import {
GiWalkingBootIcon,
GiFootTripIcon,
GiBattleGearIcon,
SkullCrossedBonesIcon,
GiSandsOfTimeIcon,
} from "../icons/Icons";

interface BattleDisplayProps {
Expand Down
16 changes: 6 additions & 10 deletions ui/src/app/components/beast/BeastDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { getBeastData } from "../../lib/utils";
import { HeartIcon } from "../icons/Icons";
import EfficacyIcon from "../icons/EfficacyIcon";
import { processBeastName } from "../../lib/utils";
import { Battle, Beast, Adventurer } from "@/app/types";
import { useQueriesStore } from "@/app/hooks/useQueryStore";
import { Beast } from "@/app/types";

import { HealthCountDown } from "../CountDown";

Expand All @@ -26,8 +25,9 @@ export const BeastDisplay = ({ beastData }: BeastDisplayProps) => {
<div className="flex justify-between py-1 sm:py-3 text-2xl sm:text-4xl border-b border-terminal-green px-2 ">
{beastName}
<div
className={`text-4xl flex ${beastData?.health === 0 ? "text-red-600" : "text-terminal-green"
}`}
className={`text-4xl flex ${
beastData?.health === 0 ? "text-red-600" : "text-terminal-green"
}`}
>
<HeartIcon className="self-center w-4 h-4 fill-current mr-1" />{" "}
<div className="self-center text-xl sm:text-4xl">
Expand All @@ -36,12 +36,8 @@ export const BeastDisplay = ({ beastData }: BeastDisplayProps) => {
</div>
</div>
<div className="flex justify-between w-full p-2 text-lg sm:text-3xl text-terminal-yellow">
<p>
Level {beastData?.level}
</p>
<p>
Tier {tier}
</p>
<p>Level {beastData?.level}</p>
<p>Tier {tier}</p>
</div>
<div className="flex flex-row justify-center gap-4 items-center w-full py-1 sm:py-4 space-x-2">
<div className="flex flex-row gap-2 items-center ml-5">
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/components/intro/WalletSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import { useState } from "react";
import { Button } from "../buttons/Button";
import { useConnectors, useAccount } from "@starknet-react/core";
import { useConnectors } from "@starknet-react/core";
import useUIStore from "../../hooks/useUIStore";
import Image from "next/image";
import { WalletTutorial } from "../tutorial/WalletTutorial";
Expand Down
5 changes: 2 additions & 3 deletions ui/src/app/components/inventory/InventoryRow.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useEffect, useState, useRef, ReactElement, useCallback } from "react";
import { useEffect, useState, ReactElement, useCallback } from "react";
import { useContracts } from "../../hooks/useContracts";
import { Button } from "../buttons/Button";
import useAdventurerStore from "../../hooks/useAdventurerStore";
import useTransactionCartStore from "../../hooks/useTransactionCartStore";
import { useMediaQuery } from "react-responsive";
import { Item, Menu, Metadata } from "@/app/types";
import { Item } from "@/app/types";
import { GameData } from "../GameData";
import { getKeyFromValue } from "@/app/lib/utils";

Expand Down
4 changes: 0 additions & 4 deletions ui/src/app/components/leaderboard/LiveRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ import useUIStore from "@/app/hooks/useUIStore";
import { chunkArray, calculateLevel } from "@/app/lib/utils";

interface LiveLeaderboardRowProps {
index: number;
adventurer: Adventurer;
rank: number;
handleRowSelected: (id: number) => void;
}

const LiveLeaderboardRow = ({
index,
adventurer,
rank,
handleRowSelected,
}: LiveLeaderboardRowProps) => {
const { gameContract } = useContracts();
Expand Down
2 changes: 0 additions & 2 deletions ui/src/app/components/leaderboard/LiveTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ const LiveLeaderboardTable = ({
(adventurer: Adventurer, index: number) => (
<LiveRow
key={index}
index={index}
adventurer={adventurer}
rank={rankXp(adventurer, index)}
handleRowSelected={handleRowSelected}
/>
)
Expand Down
2 changes: 0 additions & 2 deletions ui/src/app/components/leaderboard/ScoreRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import { useUiSounds, soundSelector } from "@/app/hooks/useUiSound";
import { formatNumber } from "@/app/lib/utils";

interface ScoreLeaderboardRowProps {
index: number;
adventurer: any;
rank: number;
handleRowSelected: (id: number) => void;
}

const ScoreRow = ({
index,
adventurer,
rank,
handleRowSelected,
Expand Down
4 changes: 0 additions & 4 deletions ui/src/app/components/leaderboard/ScoreTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ const ScoreLeaderboardTable = ({

const scoresWithLords = mergedScores;

console.log(scoresWithLords);
console.log(scoresData);

const totalPages = Math.ceil(scores.length / itemsPerPage);

let previousXp = -1;
Expand Down Expand Up @@ -108,7 +105,6 @@ const ScoreLeaderboardTable = ({
{scoresWithLords.map((adventurer: any, index: number) => (
<ScoreRow
key={index}
index={index}
adventurer={adventurer}
rank={rankXp(adventurer, index)}
handleRowSelected={handleRowSelected}
Expand Down
14 changes: 0 additions & 14 deletions ui/src/app/components/marketplace/MarketplaceRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ import {
Metadata,
Item,
Adventurer,
Call,
ItemPurchase,
UpgradeStats,
} from "../../types";
import { CoinIcon } from "../icons/Icons";
import EfficacyDisplay from "../icons/EfficacyIcon";
import { GameData } from "../GameData";
import { useMediaQuery } from "react-responsive";

interface MarketplaceRowProps {
item: Item;
index: number;
selectedIndex: number;
adventurers: Adventurer[];
activeMenu: number | null;
setActiveMenu: (value: number | null) => void;
calculatedNewGold: number;
Expand All @@ -45,7 +42,6 @@ const MarketplaceRow = ({
item,
index,
selectedIndex,
adventurers,
activeMenu,
setActiveMenu,
calculatedNewGold,
Expand All @@ -56,25 +52,15 @@ const MarketplaceRow = ({
totalCharisma,
}: MarketplaceRowProps) => {
const [selectedButton, setSelectedButton] = useState<number>(0);
const { gameContract } = useContracts();
const adventurer = useAdventurerStore((state) => state.adventurer);
const calls = useTransactionCartStore((state) => state.calls);
const addToCalls = useTransactionCartStore((state) => state.addToCalls);
const { hashes, transactions } = useTransactionManager();
const { data: txData } = useWaitForTransaction({ hash: hashes[0] });
// const setPurchasedItem = useUIStore((state) => state.setPurchasedItem);

const transactingMarketIds = (transactions[0]?.metadata as Metadata)?.items;

const gameData = new GameData();

const singlePurchaseExists = (item: string) => {
// return calls.some(
// (call: Call) =>
// call.entrypoint == "buy_items_and_upgrade_stats" &&
// Array.isArray(call.calldata) &&
// call.calldata[2] == getKeyFromValue(gameData.ITEMS, item)?.toString()
// );
return purchaseItems.some(
(purchasingItem: ItemPurchase) => purchasingItem.item == item
);
Expand Down
1 change: 0 additions & 1 deletion ui/src/app/components/marketplace/MarketplaceTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ const MarketplaceTable = ({
item={item}
index={index}
selectedIndex={selectedIndex}
adventurers={adventurers}
activeMenu={showEquipQ}
setActiveMenu={setShowEquipQ}
calculatedNewGold={calculatedNewGold}
Expand Down
27 changes: 1 addition & 26 deletions ui/src/app/containers/AdventurerScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useEffect, useState, useMemo } from "react";
import { useEffect, useState } from "react";
import { useAccount } from "@starknet-react/core";
// import { getAdventurersByOwner } from "../hooks/graphql/queries";
import { AdventurersList } from "../components/start/AdventurersList";
import { CreateAdventurer } from "../components/start/CreateAdventurer";
import ButtonMenu from "../components/menu/ButtonMenu";
Expand All @@ -26,38 +25,14 @@ export default function AdventurerScreen({
}: AdventurerScreenProps) {
const [activeMenu, setActiveMenu] = useState(0);
const [loading, setLoading] = useState(false);
const { account } = useAccount();
const adventurer = useAdventurerStore((state) => state.adventurer);

const setAdventurer = useAdventurerStore((state) => state.setAdventurer);
const txAccepted = useLoadingStore((state) => state.txAccepted);
const { data } = useQueriesStore();
const adventurers = useQueriesStore(
(state) => state.data.adventurersByOwnerQuery?.adventurers || []
);
const queryAdventurer = useQueriesStore(
(state) => state.data.adventurerByIdQuery?.adventurers[0] || NullAdventurer
);
const resetData = useQueriesStore((state) => state.resetData);
const startOption = useUIStore((state) => state.startOption);
const setStartOption = useUIStore((state) => state.setStartOption);

console.log(startOption);

// const owner = account?.address ? padAddress(account.address) : "";

// const ownerVariables = useMemo(() => {
// return {
// owner: owner,
// };
// }, [owner]);

// useCustomQuery(
// "adventurersByOwnerQuery",
// getAdventurersByOwner,
// ownerVariables
// );

const menu = [
{
id: 1,
Expand Down
Loading

0 comments on commit 55b9297

Please sign in to comment.