From 3026a97b8a79262f1ab6a58fa6a62f675f9f6439 Mon Sep 17 00:00:00 2001 From: skyrunner360 Date: Sun, 14 Apr 2024 21:24:18 +0530 Subject: [PATCH] feat: :lipstick: Game Complete! --- public/Snake_silhouette.svg | 2 +- src/App.tsx | 36 ++++++++++++++++++++------- src/Components/Board.tsx | 16 +----------- src/Components/Dice.tsx | 17 +++++++------ src/Components/PlayerInfo.tsx | 46 ++++++++++++++++++++--------------- 5 files changed, 64 insertions(+), 53 deletions(-) diff --git a/public/Snake_silhouette.svg b/public/Snake_silhouette.svg index 4bc20a1..1a57da8 100644 --- a/public/Snake_silhouette.svg +++ b/public/Snake_silhouette.svg @@ -14,7 +14,7 @@ + style="fill:#5ef286" />
@@ -16,15 +18,31 @@ function App() { {global === "notStarted" ? ( ) : ( -
-
- +
+
+
+ +
+
+ +
+
+ +
-
- -
-
- +
+ {playerPos.player1 === 0 && ( +
+ + Player 1 +
+ )} + {playerPos.player2 === 0 && ( +
+ + Player 2 +
+ )}
)} diff --git a/src/Components/Board.tsx b/src/Components/Board.tsx index a9389c0..1c18ee6 100644 --- a/src/Components/Board.tsx +++ b/src/Components/Board.tsx @@ -14,21 +14,7 @@ const Board = () => { const playerPos = useRecoilValue(playerPositions); return ( -
-
- {playerPos.player1 === 0 && ( -
- - Player 1 -
- )} - {playerPos.player2 === 0 && ( -
- - Player 2 -
- )} -
+
{ }); if (isPlayerFree) { setGState({ ...gState, [`player${currPlayer}`]: { move: true } }); - if ( - playerPos.player1 + newVal >= 100 || - playerPos.player2 + newVal >= 100 - ) { + if (currPlayerPos >= 100) { setGState({ ...gState, global: "over" }); setGameLog([ ...gameLog, @@ -94,10 +91,7 @@ const Dice = () => { setDiceVal(0); } } else { - if ( - playerPos.player1 + newVal >= 100 || - playerPos.player2 + newVal >= 100 - ) { + if (currPlayerPos >= 100) { setGState({ ...gState, global: "over" }); setGameLog([ ...gameLog, @@ -138,6 +132,13 @@ const Dice = () => { Restart )} + ); diff --git a/src/Components/PlayerInfo.tsx b/src/Components/PlayerInfo.tsx index 4962f2e..801ae9e 100644 --- a/src/Components/PlayerInfo.tsx +++ b/src/Components/PlayerInfo.tsx @@ -13,27 +13,33 @@ const PlayerInfo = () => { return (
-

Game Logs

-
- {gLogs?.map((log) => ( -

- {log} -

- ))} +
+

+ Current Player Positions +

+

+ Player 1 :- {playerPos.player1} +

+

+ Player 2 :- {playerPos.player2} +

+
+
+

Game Logs

+
+ {gLogs?.map((log) => ( +

+ {log} +

+ ))} +
-

Player Positions

-

- Player 1 :- {playerPos.player1} -

-

- Player 2 :- {playerPos.player2} -

); };