Skip to content

Commit 699bfbe

Browse files
authored
DS Tournament Updates (#291)
* add tournament as tab * add ds tournament leaderboard tracking
1 parent 0f9e89e commit 699bfbe

File tree

5 files changed

+58
-51
lines changed

5 files changed

+58
-51
lines changed

ui/src/app/components/leaderboard/SeasonTable.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ const SeasonTable = ({
2828
const network = useUIStore((state) => state.network);
2929

3030
const seasonActive = process.env.NEXT_PUBLIC_SEASON_ACTIVE === "true";
31+
const isDSTournamentActive =
32+
process.env.NEXT_PUBLIC_DS_TOURNAMENT_ACTIVE === "true";
33+
const dsTournamentId = process.env.NEXT_PUBLIC_DS_TOURNAMENT_ID ?? 0;
3134

3235
// Memoize both the variables AND the client
3336
const { variables, client } = useMemo(() => {
3437
return {
3538
variables: {
36-
tournamentId: networkConfig[network!].tournamentId,
39+
tournamentId: isDSTournamentActive
40+
? dsTournamentId
41+
: networkConfig[network!].tournamentId,
3742
},
3843
client: tournamentClient(networkConfig[network!].tournamentGQLURL),
3944
};
@@ -99,9 +104,13 @@ const SeasonTable = ({
99104
<div className="flex flex-col gap-5 sm:gap-0 sm:flex-row justify-between w-full">
100105
<div className="flex flex-col w-full sm:mr-4 flex-grow-2 p-2 gap-2">
101106
<h4 className="text-center text-2xl m-0 uppercase">
102-
{seasonActive ? "Current Season" : "Season Ended"}
107+
{isDSTournamentActive
108+
? "Dark Shuffle Tournament"
109+
: seasonActive
110+
? "Current Season"
111+
: "Season Ended"}
103112
</h4>
104-
{seasonActive && (
113+
{(isDSTournamentActive || seasonActive) && (
105114
<>
106115
<table className="w-full xl:text-lg 2xl:text-xl border border-terminal-green">
107116
<thead className="border border-terminal-green">

ui/src/app/containers/AdventurerScreen.tsx

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Button } from "@/app/components/buttons/Button";
22
import ButtonMenu from "@/app/components/menu/ButtonMenu";
33
import { AdventurersList } from "@/app/components/start/AdventurersList";
44
import { CreateAdventurer } from "@/app/components/start/CreateAdventurer";
5-
import DSTournamentOverview from "@/app/components/start/DSTournamentOverview";
65
import useAdventurerStore from "@/app/hooks/useAdventurerStore";
76
import useNetworkAccount from "@/app/hooks/useNetworkAccount";
87
import { useQueriesStore } from "@/app/hooks/useQueryStore";
@@ -75,9 +74,6 @@ export default function AdventurerScreen({
7574
const { account } = useNetworkAccount();
7675
const owner = account?.address ? padAddress(account.address) : "";
7776

78-
const isDSTournamentActive =
79-
process.env.NEXT_PUBLIC_DS_TOURNAMENT_ACTIVE === "true";
80-
8177
const menu = [
8278
{
8379
id: 1,
@@ -101,56 +97,18 @@ export default function AdventurerScreen({
10197
},
10298
];
10399

104-
const dsTournamentMenu = [
105-
{
106-
id: 1,
107-
label: "Dark Shuffle Tournament",
108-
value: "ds tournament",
109-
action: () => {
110-
setStartOption("ds tournament");
111-
},
112-
disabled: false,
113-
},
114-
{
115-
id: 2,
116-
label: "Create Adventurer",
117-
value: "create adventurer",
118-
action: () => {
119-
setStartOption("create adventurer");
120-
setAdventurer(NullAdventurer);
121-
resetData("adventurerByIdQuery");
122-
},
123-
disabled: false,
124-
},
125-
{
126-
id: 3,
127-
label: "Choose Adventurer",
128-
value: "choose adventurer",
129-
action: () => {
130-
setStartOption("choose adventurer");
131-
},
132-
disabled: false,
133-
},
134-
];
135-
136100
return (
137101
<div className="flex flex-col sm:flex-row w-full h-full">
138102
<div className="w-full sm:w-1/6 h-10">
139103
<ButtonMenu
140-
buttonsData={isDSTournamentActive ? dsTournamentMenu : menu}
104+
buttonsData={menu}
141105
onSelected={(value) => setStartOption(value)}
142106
isActive={activeMenu == 0}
143107
setActiveMenu={setActiveMenu}
144108
className="sm:flex-col h-full"
145109
/>
146110
</div>
147111

148-
{startOption === "ds tournament" && (
149-
<div className="w-5/6 h-full">
150-
<DSTournamentOverview lordsCost={costToPlay} />
151-
</div>
152-
)}
153-
154112
{startOption === "create adventurer" && (
155113
<div className="flex flex-col w-5/6 h-full mx-auto sm:justify-center sm:flex-row gap-2">
156114
<CreateAdventurer

ui/src/app/hooks/useUIStore.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export type ScreenPage =
2424
| "onboarding"
2525
| "create adventurer"
2626
| "future"
27-
| "collections leaderboard";
27+
| "collections leaderboard"
28+
| "tournament";
2829

2930
export type Network =
3031
| "mainnet"

ui/src/app/lib/networkConfig.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ export const networkConfig = {
4040
mainnet: {
4141
rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet",
4242
lsGQLURL: "https://ls-indexer-sepolia.provable.games/graphql",
43-
tournamentGQLURL:
44-
"https://api.cartridge.gg/x/realms-world-04/torii/graphql",
43+
tournamentGQLURL: "https://api.cartridge.gg/x/ls-tournaments/torii/graphql",
4544
blastUrl:
4645
"https://starknet-mainnet.blastapi.io/5ef61753-e7c1-4593-bc62-97fdf96f8de5",
4746
ethAddress:

ui/src/app/page.tsx

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { NotificationDisplay } from "@/app/components/notifications/Notification
2222
import { SpecialBeast } from "@/app/components/notifications/SpecialBeast";
2323
import LoginDialog from "@/app/components/onboarding/LoginDialog";
2424
import { ProfileDialog } from "@/app/components/profile/ProfileDialog";
25+
import DSTournamentOverview from "@/app/components/start/DSTournamentOverview";
2526
import ActionsScreen from "@/app/containers/ActionsScreen";
2627
import AdventurerScreen from "@/app/containers/AdventurerScreen";
2728
import CollectionsLeaderboardScreen from "@/app/containers/CollectionsLeaderboardScreen";
@@ -164,6 +165,42 @@ function Home() {
164165
[onKatana]
165166
);
166167

168+
const isDSTournamentActive =
169+
process.env.NEXT_PUBLIC_DS_TOURNAMENT_ACTIVE === "true";
170+
171+
const dsMenuItems: Menu[] = useMemo(
172+
() => [
173+
{ id: 1, label: "Start", screen: "start" as ScreenPage, disabled: false },
174+
{ id: 2, label: "Play", screen: "play" as ScreenPage, disabled: false },
175+
{
176+
id: 3,
177+
label: "Inventory",
178+
screen: "inventory" as ScreenPage,
179+
disabled: false,
180+
},
181+
{
182+
id: 4,
183+
label: "Upgrade",
184+
screen: "upgrade" as ScreenPage,
185+
disabled: false,
186+
},
187+
{
188+
id: 5,
189+
label: "Leaderboard",
190+
screen: "leaderboard" as ScreenPage,
191+
disabled: false,
192+
},
193+
{ id: 6, label: "Guide", screen: "guide" as ScreenPage, disabled: false },
194+
{
195+
id: 7,
196+
label: "Tournament",
197+
screen: "tournament" as ScreenPage,
198+
disabled: false,
199+
},
200+
],
201+
[onKatana]
202+
);
203+
167204
const mobileMenuItems: Menu[] = useMemo(
168205
() => [
169206
{ id: 1, label: "Start", screen: "start" as ScreenPage, disabled: false },
@@ -602,7 +639,7 @@ function Home() {
602639
if (!onboarded) {
603640
setScreen("onboarding");
604641
} else if (onboarded) {
605-
setScreen("start");
642+
setScreen("tournament");
606643
}
607644
}, [onboarded]);
608645

@@ -816,7 +853,7 @@ function Home() {
816853
</div>
817854
<div className="hidden sm:block flex justify-center sm:justify-normal sm:pb-2">
818855
<ScreenMenu
819-
buttonsData={allMenuItems}
856+
buttonsData={isDSTournamentActive ? dsMenuItems : allMenuItems}
820857
onButtonClick={(value) => {
821858
setScreen(value);
822859
}}
@@ -865,6 +902,9 @@ function Home() {
865902
{screen === "collections leaderboard" && (
866903
<CollectionsLeaderboardScreen />
867904
)}
905+
{screen === "tournament" && (
906+
<DSTournamentOverview lordsCost={costToPlay} />
907+
)}
868908
{screen === "settings" && <Settings />}
869909
{screen === "player" && <Player gameContract={gameContract!} />}
870910
{screen === "wallet" && <WalletSelect />}

0 commit comments

Comments
 (0)