diff --git a/client/src/components/lobby/duels.tsx b/client/src/components/lobby/duels.tsx
index 9ec1ee67..2d29cb4c 100644
--- a/client/src/components/lobby/duels.tsx
+++ b/client/src/components/lobby/duels.tsx
@@ -56,7 +56,7 @@ export default function Duels({
});
const { system } = useDojo();
const account = useAccount();
- const join_game = async (game_id: string, index: number) => {
+ const join_game = async (game_id: string, index: number, seed_number: number) => {
setJoinStatus({
status: "JOINING",
index: index,
@@ -69,6 +69,7 @@ export default function Duels({
player_2_address,
setJoinStatus,
index,
+ seed_number
);
}
};
@@ -89,7 +90,7 @@ export default function Duels({
if (isPlayerInGame || isGameFull) {
navigate(`/games/${game.game_id}`);
} else {
- join_game(game.game_id, index)
+ join_game(game.game_id, index, 1)
.then((res) => console.info(res))
.catch((errorJoiningGame) => console.error(errorJoiningGame));
}
diff --git a/client/src/components/not-enough.tsx b/client/src/components/not-enough.tsx
new file mode 100644
index 00000000..e94ca1cb
--- /dev/null
+++ b/client/src/components/not-enough.tsx
@@ -0,0 +1,41 @@
+import { Dialog } from "@material-tailwind/react";
+import { useState } from "react";
+import { Button } from "./ui/button";
+import { BellIcon } from "@heroicons/react/24/solid";
+
+export default function NotEnough({ isEnough }: { isEnough: boolean }) {
+ const [open, setOpen] = useState(!isEnough);
+ const handleOpen = () => setOpen(open);
+ return(
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/client/src/dojo/createSystemCalls.ts b/client/src/dojo/createSystemCalls.ts
index 2237101f..924bedc8 100644
--- a/client/src/dojo/createSystemCalls.ts
+++ b/client/src/dojo/createSystemCalls.ts
@@ -27,9 +27,9 @@ export function createSystemCalls(
}
};
- const create_game = async (account: AccountInterface, setGameId: any) => {
+ const create_game = async (account: AccountInterface, setGameId: any, settings_id: number) => {
try {
- const { transaction_hash } = await client.actions.create_game(account);
+ const { transaction_hash } = await client.actions.create_game(account, settings_id);
getEvents(
await account.waitForTransaction(transaction_hash, {
retryInterval: 100,
@@ -48,11 +48,13 @@ export function createSystemCalls(
account: AccountInterface,
player_2: string,
setGameId: any,
+ settings_id: number
) => {
try {
const { transaction_hash } = await client.actions.create_private_game(
account,
player_2,
+ settings_id
);
getEvents(
await account.waitForTransaction(transaction_hash, {
@@ -74,11 +76,13 @@ export function createSystemCalls(
player_2_address: string,
setJoinStatus: any,
index: number,
+ settings_id: number
) => {
try {
const { transaction_hash } = await client.actions.join_game(
account,
game_id,
+ settings_id
);
const receipt = await account.waitForTransaction(transaction_hash, {
diff --git a/client/src/dojo/generated/generated.ts b/client/src/dojo/generated/generated.ts
index 731cce73..f989d103 100644
--- a/client/src/dojo/generated/generated.ts
+++ b/client/src/dojo/generated/generated.ts
@@ -27,7 +27,7 @@ export async function setupWorld(provider: DojoProvider) {
}
};
- const create_game = async (account: AccountInterface) => {
+ const create_game = async (account: AccountInterface, settings_id: number) => {
console.log("account: ", account);
try {
return await provider.execute(
@@ -35,7 +35,7 @@ export async function setupWorld(provider: DojoProvider) {
{
contractName,
entrypoint: "new_game",
- calldata: [],
+ calldata: [settings_id],
},
NAMESPACE,
);
@@ -48,6 +48,7 @@ export async function setupWorld(provider: DojoProvider) {
const create_private_game = async (
account: AccountInterface,
player_2: string,
+ settings_id: number,
) => {
try {
return await provider.execute(
@@ -55,7 +56,7 @@ export async function setupWorld(provider: DojoProvider) {
{
contractName,
entrypoint: "create_private_game",
- calldata: [player_2],
+ calldata: [player_2, settings_id],
},
NAMESPACE,
);
@@ -65,14 +66,14 @@ export async function setupWorld(provider: DojoProvider) {
}
};
- const join_game = async (account: AccountInterface, game_id: string) => {
+ const join_game = async (account: AccountInterface, game_id: string, settings_id: number) => {
try {
return await provider.execute(
account,
{
contractName,
entrypoint: "join_game",
- calldata: [game_id],
+ calldata: [game_id, settings_id],
},
NAMESPACE,
);
diff --git a/client/src/lib/constants.ts b/client/src/lib/constants.ts
index c7d347c4..c3d49200 100644
--- a/client/src/lib/constants.ts
+++ b/client/src/lib/constants.ts
@@ -604,6 +604,14 @@ export const gameStarted = (games_data_one: any, games_data_two: any) =>
games_data_two?.pit6 == 4
);
+
+export const normalizeAddress = (address: string) => {
+ // Remove '0x' prefix, convert to lowercase, and pad with leading zeros if needed
+ const cleanAddress = address?.toLowerCase()?.replace("0x", "");
+ // Pad to 64 characters (32 bytes) with leading zeros
+ return cleanAddress?.padStart(64, "0");
+};
+
export const MancalaBoardModelsQuery = gql`
query mancalaSaltMancalaBoardModels {
mancalaSaltMancalaBoardModels {
@@ -4685,3 +4693,4 @@ export const TUTORIAL_STEPS: TutorialStep[] = [
],
},
];
+
diff --git a/client/src/pages/Home.tsx b/client/src/pages/Home.tsx
index 4186698d..0edd623b 100644
--- a/client/src/pages/Home.tsx
+++ b/client/src/pages/Home.tsx
@@ -3,19 +3,29 @@ import link from "../assets/link-out.png";
import { Link } from "react-router-dom";
import Bubble from "@/components/ui/svgs/bubble";
import small_logo from "@/assets/small-logo.png";
+import { useAccount, useConnect } from "@starknet-react/core";
+import { Button } from "@/components/ui/button";
export default function Home() {
+ const { isConnected } = useAccount();
+ const { connect, connectors } = useConnect();
return (
-
+ {
+ isConnected ?
-
+ :
+ }
{
+ const create_game = async (settings_id: number) => {
setCreating(true);
if (account.account) {
//using account from cartridge
- await system.create_game(account.account, setGameId);
+ await system.create_game(account.account, setGameId, settings_id);
if (gameId) {
setCreating(false);
}
@@ -67,10 +67,10 @@ export default function Lobby() {
}
};
- const create_private_game = async () => {
+ const create_private_game = async (settings_id: number) => {
setCreating(true);
if (account.account) {
- await system.create_private_game(account.account, player2, setGameId);
+ await system.create_private_game(account.account, player2, setGameId, settings_id);
if (gameId) {
setCreating(false);
}
@@ -467,8 +467,8 @@ export default function Lobby() {
className="bg-[#F58229] hover:bg-[#F58229] font-medium hover:cursor-pointer rounded-3xl"
onClick={() =>
type == "private"
- ? create_private_game()
- : create_game()
+ ? create_private_game(1)
+ : create_game(1)
}
>
diff --git a/client/src/pages/games/Gameplay.tsx b/client/src/pages/games/Gameplay.tsx
index 625d6375..694a654d 100644
--- a/client/src/pages/games/Gameplay.tsx
+++ b/client/src/pages/games/Gameplay.tsx
@@ -8,6 +8,7 @@ import {
MancalaBoardModelQuery,
MancalaPlayerNames,
MancalaPlayQuery,
+ normalizeAddress,
} from "@/lib/constants";
import { useQuery } from "@apollo/client";
import AudioSection from "@/components/gameplay/audio-section";
@@ -16,6 +17,12 @@ import RestartButton from "@/components/gameplay/restart-button";
import EndgameButton from "@/components/gameplay/end-game-button";
import GameNavigation from "@/components/gameplay/game-navigation";
import TimeoutButton from "@/components/gameplay/timeout-button";
+import { Dialog, DialogBackdrop, DialogPanel } from "@headlessui/react";
+import winner from "@/assets/win.png";
+import lose from "@/assets/lose.png";
+import end from "@/assets/end.png";
+import createIcon from "@/assets/createIcon.png";
+import { Button } from "@/components/ui/button";
export default function Gameplay() {
const { gameId } = useParams();
@@ -46,9 +53,7 @@ export default function Gameplay() {
)
: 0;
const opponent_position = player_position === 0 ? 1 : 0;
- const opposition_address =
- game_players?.mancalaSaltPlayerModels.edges[opponent_position]?.node
- .address;
+ const opposition_address = game_players?.mancalaSaltPlayerModels.edges[opponent_position]?.node.address;
startMetadataPolling(100);
startPlayersPolling(100);
const [volume, setVolume] = useState(35);
@@ -58,6 +63,13 @@ export default function Gameplay() {
message: "",
});
+ const is_finished = involved && game_node?.status === "Finished";
+ const [open, setOpen] = useState(is_finished);
+ const handleClose = () => {
+ setOpen(false)
+ };
+ const user_won = normalizeAddress(game_node?.winner) === normalizeAddress(account.account?.address || "");
+ const [players, setPlayers] = useState<{ name: string, address: string }[]>()
return (
@@ -114,6 +127,54 @@ export default function Gameplay() {
+
+
+
);