diff --git a/packages/nextjs/components/dicedemo/Congrats.tsx b/packages/nextjs/components/dicedemo/Congrats.tsx index db13d4d..1ab3696 100644 --- a/packages/nextjs/components/dicedemo/Congrats.tsx +++ b/packages/nextjs/components/dicedemo/Congrats.tsx @@ -1,5 +1,4 @@ import { Dispatch, SetStateAction } from "react"; -import useSweepWallet from "~~/hooks/useSweepWallet"; import { Game } from "~~/types/game/game"; const Congrats = ({ @@ -8,20 +7,18 @@ const Congrats = ({ isHacked, isWinner, game, - token, }: { isOpen: boolean; setIsOpen: Dispatch>; isHacked: boolean; isWinner: boolean; game: Game; - token: string; }) => { const closePopup = () => { setIsOpen(false); }; - const { isSweeping } = useSweepWallet({ game: game, token: token }); + // const { isSweeping } = useSweepWallet({ game: game, token: token }); return (
@@ -36,11 +33,7 @@ const Congrats = ({
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"} -
+
Hidden characters found, Trying to sweep private key ...
)} {!isWinner && isHacked && game.winner != undefined && (
Hidden characters found but you were beaten to sweeping the private key by another wallet
diff --git a/packages/nextjs/components/dicedemo/GameJoinForm.tsx b/packages/nextjs/components/dicedemo/GameJoinForm.tsx index 8eaa961..66cd7be 100644 --- a/packages/nextjs/components/dicedemo/GameJoinForm.tsx +++ b/packages/nextjs/components/dicedemo/GameJoinForm.tsx @@ -94,7 +94,7 @@ const GameJoinForm = ({ return (
-
handleJoinGame(inviteCode)}> +
- - +
{scanning && (
(null); const [isRolling, setIsRolling] = useState(false); const [isUnitRolling, setIsUnitRolling] = useState([false]); @@ -44,12 +44,16 @@ function GamePage() { const prize = useBalance({ address: game?.adminAddress }); const { sweepWallet } = useSweepWallet({ game, token }); - // const calculateLength = () => { - // const maxLength = 200; - // const diceCount = game?.diceCount ?? 0; - // const calculatedLength = Math.max(maxLength - (diceCount - 1) * 3.8, 10); - // return calculatedLength; - // }; + const calculateLength = () => { + const maxLength = 150; + const diceCount = game?.diceCount ?? 0; + const calculatedLength = Math.max(maxLength - (diceCount - 1) * 3, 10); + return calculatedLength; + }; + + const length = calculateLength(); + + console.log(length); const generateRandomHex = () => { const hexDigits = "0123456789ABCDEF"; @@ -74,23 +78,25 @@ function GamePage() { } setRolls(rolls); let iterations = 0; - for (let i = 0; i < isUnitRolling.length; i++) { - setTimeout(() => { - setIsUnitRolling(prevState => { - const newState = [...prevState]; - newState[i] = false; - return newState; - }); - iterations++; - if (iterations === isUnitRolling.length) { - setIsRolling(false); - setTimeout(() => { - setSpinning(false); - setRolledResult(rolls); - }, 5000); - } - }, i * 1000); - } + setTimeout(() => { + for (let i = 0; i < isUnitRolling.length; i++) { + setTimeout(() => { + setIsUnitRolling(prevState => { + const newState = [...prevState]; + newState[i] = false; + return newState; + }); + iterations++; + if (iterations === isUnitRolling.length) { + setIsRolling(false); + setTimeout(() => { + setSpinning(false); + setRolledResult(rolls); + }, 500); + } + }, i * 800); + } + }, 800); } }; @@ -133,12 +139,6 @@ function GamePage() { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - useEffect(() => { - if (videoRef.current && !isRolling) { - videoRef.current.currentTime = 9999; - } - }, [isRolling]); - useEffect(() => { const isHiiddenChars = compareResult(); @@ -191,7 +191,7 @@ function GamePage() { const autoRoll = () => { if (autoRolling && game?.mode === "auto") { rollTheDice(); - timeout = setTimeout(autoRoll, 5500); + timeout = setTimeout(autoRoll, 5000); } }; if (game?.winner) { @@ -390,9 +390,9 @@ function GamePage() {
- Dice count: {game.diceCount} + Hidden Characters: {game.diceCount}
- {screenwidth <= 768 && ( + {screenwidth <= 768 && isAdmin && (

HIDDEN CHARACTERS

@@ -419,17 +419,24 @@ function GamePage() {
{screenwidth > 768 && (
-
-

HIDDEN CHARACTERS

-
-

{Object.values(game?.hiddenPrivateKey)}

+ {isAdmin && ( +
+
+

Private Key

+
+

+ {Object.values(game?.hiddenPrivateKey)} +

+
+ )} +

PLAYERS: {game?.players.length}

-
+
{game?.players?.map((player: string) => (
@@ -470,6 +477,7 @@ function GamePage() { {game.mode === "auto" ? " Auto Roll" : game.mode === "brute" ? "Brute Roll" : "Roll"}
+

Guess the hidden characters

Result: {rolledResult.length > 0 && !spinning && {rolledResult.join(" , ")}} @@ -478,30 +486,33 @@ function GamePage() { {Object.entries(game.hiddenChars).map(([key], index) => rolled ? ( isUnitRolling[index] || (isRolling && game.mode == "brute") ? ( -
@@ -513,7 +524,6 @@ function GamePage() { isHacked={isHacked} isWinner={game.winner == address} game={game} - token={token} /> )}
diff --git a/packages/nextjs/public/rolls-gif/0.gif b/packages/nextjs/public/rolls-gif/0.gif new file mode 100644 index 0000000..dc94183 Binary files /dev/null and b/packages/nextjs/public/rolls-gif/0.gif differ diff --git a/packages/nextjs/public/rolls-gif/1.gif b/packages/nextjs/public/rolls-gif/1.gif new file mode 100644 index 0000000..c9fcb65 Binary files /dev/null and b/packages/nextjs/public/rolls-gif/1.gif differ diff --git a/packages/nextjs/public/rolls-gif/2.gif b/packages/nextjs/public/rolls-gif/2.gif new file mode 100644 index 0000000..cb441ec Binary files /dev/null and b/packages/nextjs/public/rolls-gif/2.gif differ diff --git a/packages/nextjs/public/rolls-gif/3.gif b/packages/nextjs/public/rolls-gif/3.gif new file mode 100644 index 0000000..58bac2a Binary files /dev/null and b/packages/nextjs/public/rolls-gif/3.gif differ diff --git a/packages/nextjs/public/rolls-gif/4.gif b/packages/nextjs/public/rolls-gif/4.gif new file mode 100644 index 0000000..c9c403a Binary files /dev/null and b/packages/nextjs/public/rolls-gif/4.gif differ diff --git a/packages/nextjs/public/rolls-gif/5.gif b/packages/nextjs/public/rolls-gif/5.gif new file mode 100644 index 0000000..3215554 Binary files /dev/null and b/packages/nextjs/public/rolls-gif/5.gif differ diff --git a/packages/nextjs/public/rolls-gif/6.gif b/packages/nextjs/public/rolls-gif/6.gif new file mode 100644 index 0000000..82fb73f Binary files /dev/null and b/packages/nextjs/public/rolls-gif/6.gif differ diff --git a/packages/nextjs/public/rolls-gif/7.gif b/packages/nextjs/public/rolls-gif/7.gif new file mode 100644 index 0000000..ac82c29 Binary files /dev/null and b/packages/nextjs/public/rolls-gif/7.gif differ diff --git a/packages/nextjs/public/rolls-gif/8.gif b/packages/nextjs/public/rolls-gif/8.gif new file mode 100644 index 0000000..abaa108 Binary files /dev/null and b/packages/nextjs/public/rolls-gif/8.gif differ diff --git a/packages/nextjs/public/rolls-gif/9.gif b/packages/nextjs/public/rolls-gif/9.gif new file mode 100644 index 0000000..8f3252e Binary files /dev/null and b/packages/nextjs/public/rolls-gif/9.gif differ diff --git a/packages/nextjs/public/rolls-gif/A.gif b/packages/nextjs/public/rolls-gif/A.gif new file mode 100644 index 0000000..0f4bd0d Binary files /dev/null and b/packages/nextjs/public/rolls-gif/A.gif differ diff --git a/packages/nextjs/public/rolls-gif/B.gif b/packages/nextjs/public/rolls-gif/B.gif new file mode 100644 index 0000000..ef28c45 Binary files /dev/null and b/packages/nextjs/public/rolls-gif/B.gif differ diff --git a/packages/nextjs/public/rolls-gif/C.gif b/packages/nextjs/public/rolls-gif/C.gif new file mode 100644 index 0000000..3a7d4df Binary files /dev/null and b/packages/nextjs/public/rolls-gif/C.gif differ diff --git a/packages/nextjs/public/rolls-gif/D.gif b/packages/nextjs/public/rolls-gif/D.gif new file mode 100644 index 0000000..200403f Binary files /dev/null and b/packages/nextjs/public/rolls-gif/D.gif differ diff --git a/packages/nextjs/public/rolls-gif/E.gif b/packages/nextjs/public/rolls-gif/E.gif new file mode 100644 index 0000000..c812474 Binary files /dev/null and b/packages/nextjs/public/rolls-gif/E.gif differ diff --git a/packages/nextjs/public/rolls-gif/F.gif b/packages/nextjs/public/rolls-gif/F.gif new file mode 100644 index 0000000..8eef701 Binary files /dev/null and b/packages/nextjs/public/rolls-gif/F.gif differ diff --git a/packages/nextjs/public/rolls-gif/Spin.gif b/packages/nextjs/public/rolls-gif/Spin.gif new file mode 100644 index 0000000..a64f45c Binary files /dev/null and b/packages/nextjs/public/rolls-gif/Spin.gif differ diff --git a/packages/nextjs/public/rolls-jpg/0.jpg b/packages/nextjs/public/rolls-jpg/0.jpg new file mode 100644 index 0000000..50bec12 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/0.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/1.jpg b/packages/nextjs/public/rolls-jpg/1.jpg new file mode 100644 index 0000000..dc85cc7 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/1.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/2.jpg b/packages/nextjs/public/rolls-jpg/2.jpg new file mode 100644 index 0000000..67d8383 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/2.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/3.jpg b/packages/nextjs/public/rolls-jpg/3.jpg new file mode 100644 index 0000000..86e7242 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/3.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/4.jpg b/packages/nextjs/public/rolls-jpg/4.jpg new file mode 100644 index 0000000..5b72454 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/4.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/5.jpg b/packages/nextjs/public/rolls-jpg/5.jpg new file mode 100644 index 0000000..ec0a5bb Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/5.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/6.jpg b/packages/nextjs/public/rolls-jpg/6.jpg new file mode 100644 index 0000000..f452b27 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/6.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/7.jpg b/packages/nextjs/public/rolls-jpg/7.jpg new file mode 100644 index 0000000..199d9db Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/7.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/8.jpg b/packages/nextjs/public/rolls-jpg/8.jpg new file mode 100644 index 0000000..bc44e14 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/8.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/9.jpg b/packages/nextjs/public/rolls-jpg/9.jpg new file mode 100644 index 0000000..3d891c8 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/9.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/A.jpg b/packages/nextjs/public/rolls-jpg/A.jpg new file mode 100644 index 0000000..b5b17d5 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/A.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/B.jpg b/packages/nextjs/public/rolls-jpg/B.jpg new file mode 100644 index 0000000..90a4ff5 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/B.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/C.jpg b/packages/nextjs/public/rolls-jpg/C.jpg new file mode 100644 index 0000000..263c6c5 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/C.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/D.jpg b/packages/nextjs/public/rolls-jpg/D.jpg new file mode 100644 index 0000000..4712e92 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/D.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/E.jpg b/packages/nextjs/public/rolls-jpg/E.jpg new file mode 100644 index 0000000..be97786 Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/E.jpg differ diff --git a/packages/nextjs/public/rolls-jpg/F.jpg b/packages/nextjs/public/rolls-jpg/F.jpg new file mode 100644 index 0000000..b3db54d Binary files /dev/null and b/packages/nextjs/public/rolls-jpg/F.jpg differ