diff --git a/packages/backend/index.ts b/packages/backend/index.ts index 581ef12..6fe5fa3 100644 --- a/packages/backend/index.ts +++ b/packages/backend/index.ts @@ -33,9 +33,7 @@ app.use(morgan("common")); app.use(bodyParser.json({ limit: "30mb" })); app.use(bodyParser.urlencoded({ limit: "30mb", extended: true })); app.use( - cors({ - origin: "*", - }), + cors(), ); /**Ably Setup */ diff --git a/packages/backend/vercel.json b/packages/backend/vercel.json index a3b7958..5e02a5b 100644 --- a/packages/backend/vercel.json +++ b/packages/backend/vercel.json @@ -1,11 +1,6 @@ { - "version": 2, - "name": "dice-demonstration-backend", - "builds": [ - { "src": "index.ts", "use": "@vercel/node" } - ], - "routes": [ - { "src": "/(.*)", "dest": "/index.ts" } - ] - } - \ No newline at end of file + "version": 2, + "name": "dice-demonstration-backend", + "builds": [{ "src": "index.ts", "use": "@vercel/node" }], + "routes": [{ "src": "/(.*)", "dest": "/index.ts" }] +} diff --git a/packages/nextjs/components/Wallet.tsx b/packages/nextjs/components/Wallet.tsx index c8b7dbd..4dcba08 100644 --- a/packages/nextjs/components/Wallet.tsx +++ b/packages/nextjs/components/Wallet.tsx @@ -213,7 +213,7 @@ export default function Wallet() {

Known Private Keys:

{extraPkDisplay} + + {isWinner && ( +
Congrats, you found the hidden characters and have successfully swept the private Key
+ )} + {!isWinner && isHacked && !game.winner && ( +
+ {isSweeping + ? "Hidden characters found, Trying to Sweep the wallet ..." + : "Hidden characters found, Failed to sweep PrivateKey"} +
+ )} + {!isWinner && isHacked && game.winner != undefined && ( +
Hidden characters found but you were beaten to sweeping the private key by another wallet
+ )} + {!isWinner && !isHacked &&
Sorry fren, you lost
} + +
The hidden characters are {Object.values(game.hiddenChars).join(", ")}
)} diff --git a/packages/nextjs/components/dicedemo/GameCreateForm.tsx b/packages/nextjs/components/dicedemo/GameCreateForm.tsx index 0674c81..d03539c 100644 --- a/packages/nextjs/components/dicedemo/GameCreateForm.tsx +++ b/packages/nextjs/components/dicedemo/GameCreateForm.tsx @@ -120,9 +120,11 @@ const GameCreationForm = () => { max="64" value={sliderValue} onChange={handleSliderChange} - className="slider appearance-none w-full h-2 bg-primary rounded outline-none slider-thumb " + className="slider appearance-none w-[87%] h-2 bg-primary rounded outline-none slider-thumb " /> - {sliderValue} + + {sliderValue} +
diff --git a/packages/nextjs/components/dicedemo/GameJoinForm.tsx b/packages/nextjs/components/dicedemo/GameJoinForm.tsx index a126278..8eaa961 100644 --- a/packages/nextjs/components/dicedemo/GameJoinForm.tsx +++ b/packages/nextjs/components/dicedemo/GameJoinForm.tsx @@ -19,6 +19,8 @@ const GameJoinForm = ({ const [scanning, setScanning] = useState(false); const [loading, setLoading] = useState(false); + const { invite } = router.query; + const handleChange = (value: string) => { setInviteCode(value); }; @@ -26,8 +28,7 @@ const GameJoinForm = ({ const { address: playerAddress } = useAccount(); const serverUrl = serverConfig.isLocal ? serverConfig.localUrl : serverConfig.liveUrl; - const handleJoinGame = async (event: React.FormEvent) => { - event.preventDefault(); + const handleJoinGame = async (invite: string) => { setLoading(true); const response = await fetch(`${serverUrl}/player/join`, { method: "PATCH", @@ -35,21 +36,19 @@ const GameJoinForm = ({ Authorization: `Bearer`, "Content-Type": "application/json", }, - body: JSON.stringify({ inviteCode, playerAddress }), + body: JSON.stringify({ inviteCode: invite, playerAddress }), }); const updatedGame = await response.json(); + saveGameState(JSON.stringify(updatedGame)); setLoading(false); if (updatedGame.error) { notification.error(updatedGame.error); return; } - - saveGameState(JSON.stringify(updatedGame)); - await router.push({ pathname: `/game/[id]`, - query: { id: inviteCode }, + query: { id: invite }, }); notification.success("Joined game successfully"); @@ -70,9 +69,9 @@ const GameJoinForm = ({ setScanning(false); }; - const openCamera = () => { - setScanning(true); - }; + // const openCamera = () => { + // setScanning(true); + // }; useEffect(() => { if (labelRef.current) { @@ -80,9 +79,22 @@ const GameJoinForm = ({ } }, []); + useEffect(() => { + if (invite) { + handleJoinGame(invite as string); + } + if (Object.keys(router.query).length > 0) { + router.replace({ + pathname: router.pathname, + query: {}, + }); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [invite]); + return (
-
+ handleJoinGame(inviteCode)}> - )}
+ {game.winner && ( +
+ Winner
+
+ )} + {/* {isAdmin && game.winner && ( + + )} */} -
-
-
-

- HIDDEN CHARACTERS -

+ {screenwidth > 768 && ( +
+
+

HIDDEN CHARACTERS

-

{Object.values(game?.hiddenPrivateKey)}

-
-
-

- PLAYERS -

-
-
- {game?.players?.map((player: string) => ( -
-
768 ? "long" : "short"} address={player} /> - {isAdmin && ( - - )} +

{Object.values(game?.hiddenPrivateKey)}

+
+
+

+ PLAYERS: {game?.players.length} +

- ))} +
+ {game?.players?.map((player: string) => ( +
+
+ {isAdmin && ( + + )} +
+ ))} +
+
-
+ )}
+ {isPlayer && (
{" "} - {game?.winner == address && ( - - )} - {game.winner && game?.winner != address && ( - + {(isHacked || game.winner) && ( + )}
)} + {screenwidth <= 768 && game.players.length > 0 && ( +
+
+
+

PLAYERS

+
+
+ {game?.players?.map((player: string) => ( +
+
+ {isAdmin && ( + + )} +
+ ))} +
+
+
+ )} {isAdmin && game.winner && } {!isAdmin && !isPlayer &&

Sorry fren, You have been kicked

} diff --git a/packages/nextjs/server.config.ts b/packages/nextjs/server.config.ts index 19c8da0..9121921 100644 --- a/packages/nextjs/server.config.ts +++ b/packages/nextjs/server.config.ts @@ -1,7 +1,7 @@ const serverConfig = { isLocal: false, localUrl: "http://localhost:6001", - liveUrl: "https://dice-demonstration-backend.vercel.app", + liveUrl: "https://rich-ruby-cygnet-tie.cyclic.app/", }; export default serverConfig;