From 95aa1200956d16c7627b0452c96116717503c73d Mon Sep 17 00:00:00 2001 From: codermehraj Date: Mon, 8 Jan 2024 02:12:48 +0600 Subject: [PATCH 1/2] fixed ai score issue and other UI releted issues --- .../src/components/GutiButton.jsx | 74 +++++++++++-------- FrontendTemplate/src/components/ShakeHand.jsx | 4 +- .../src/components/gameControllers.js | 8 +- FrontendTemplate/src/pages/ai_page/AIPage.jsx | 20 ++--- .../src/pages/landing_page/LandingPage.css | 5 ++ .../src/pages/landing_page/LandingPage.jsx | 4 +- 6 files changed, 64 insertions(+), 51 deletions(-) diff --git a/FrontendTemplate/src/components/GutiButton.jsx b/FrontendTemplate/src/components/GutiButton.jsx index 1caa921..66af45c 100644 --- a/FrontendTemplate/src/components/GutiButton.jsx +++ b/FrontendTemplate/src/components/GutiButton.jsx @@ -7,7 +7,14 @@ import chor from "../assets/chor.png"; import dakat from "../assets/dakat.png"; import { Button } from "antd"; -const GutiButton = ({ playerName, shufArray, restart, scores, addScore, setScore }) => { +const GutiButton = ({ + playerName, + shufArray, + restart, + scores, + addScore, + setScore, +}) => { const [showButton, setShowButton] = useState(true); const [showImage, setShowImage] = useState(false); const [selectedButton, setSelectedButton] = useState(null); @@ -17,7 +24,7 @@ const GutiButton = ({ playerName, shufArray, restart, scores, addScore, setScore const [policeGuess, setPoliceGuess] = useState(-1); const [isChor, setIsChor] = useState(true); const gotImage = [chor, dakat, police, babu]; - const bangla = ["চোর", "ডাকাত", "পুলিশ", "বাবু"]; + const bangla = ["চোর", "ডাকাত", "পুলিশ", "বাবু"]; var curscore = [0, 0, 0, 0]; var selectedIndex; @@ -36,7 +43,7 @@ const GutiButton = ({ playerName, shufArray, restart, scores, addScore, setScore const tmp = shufArray[index]; shufArray[index] = shufArray[0]; shufArray[0] = tmp; - //console.log("after" + shufArray); + console.log("after" + shufArray); setSelectedImage(shufArray[0]); // TODO : DISTRIBUTE 3 to ai @@ -60,32 +67,28 @@ const GutiButton = ({ playerName, shufArray, restart, scores, addScore, setScore } } - function getChorDakat(){ + function getChorDakat() { var ans = []; - for(var i = 0; i < 4; i++){ - if(shufArray[i] < 2) ans.push(i); + for (var i = 0; i < 4; i++) { + if (shufArray[i] < 2) ans.push(playerName[i]); } return ans; } - function isPoliceCorrect(){ - if(isChor && shufArray[policeGuess] == 0) return true; -else if(!isChor && shufArray[policeGuess] == 1) return true; - else{ + function isPoliceCorrect() { + if(policeGuess === -1) { const currentTimestamp = new Date().getTime(); - const randomValue = currentTimestamp % 2; - - if(randomValue==0){ - return true; - } - else return false; + const randomValue = currentTimestamp % 2; + setPoliceGuess(getChorDakat()[randomValue]); } + if (isChor && policeGuess === getPolice(0)) return true; + else if (!isChor && policeGuess === getPolice(1)) return true; return false; } function getScore() { const newScores = [0, 0, 0, 0]; // Create a new array to store the updated scores - + for (let i = 0; i < 4; i++) { if (shufArray[i] === 3) newScores[i] = 100; else if (shufArray[i] === 2 && isPoliceCorrect()) newScores[i] = 80; @@ -99,10 +102,9 @@ else if(!isChor && shufArray[policeGuess] == 1) return true; } else newScores[i] = 40; } } - + return newScores; } - return ( @@ -110,16 +112,22 @@ else if(!isChor && shufArray[policeGuess] == 1) return true;
{lastState && (
- {isPoliceCorrect() ? "পুলিশ সঠিক ধরেছেন" : "পুলিশ ভূল ধরেছেন"}
- চোর {isChor && isPoliceCorrect() ? "+০" : "+৪০"}
- ডাকাত {!isChor && isPoliceCorrect() ? "+০" : "+৬০"}
+ {isPoliceCorrect() ? "পুলিশ সঠিক ধরেছেন" : "পুলিশ ভূল ধরেছেন"}{" "} +
+ চোর {isChor && isPoliceCorrect() ? "+০" : "+৪০"}{" "} +
+ ডাকাত + {!isChor && isPoliceCorrect() ? "+০" : "+৬০"} + {" "} +
বাবু +১০০
পুলিশ {isPoliceCorrect() ? "+৮০" : "+০"}
-
{isChor == true ? "চোর কে ধরুন" : "ডাকাত কে ধরুন" }
+
+ {" "} +
+ {" "} + {isChor == true ? "চোর কে ধরুন" : "ডাকাত কে ধরুন"}{" "} +
{" "} +
{selectedImage == 2 && (
@@ -160,21 +174,21 @@ else if(!isChor && shufArray[policeGuess] == 1) return true; className="jayga" onClick={() => { setLastState(true); - setPoliceState(false); - setPoliceGuess((getChorDakat())[0]); + setPoliceState(false); + setPoliceGuess(getChorDakat()[0]); }} > - {(getChorDakat())[0]} + {getChorDakat()[0]}
)} diff --git a/FrontendTemplate/src/components/ShakeHand.jsx b/FrontendTemplate/src/components/ShakeHand.jsx index a16fcf4..619887f 100644 --- a/FrontendTemplate/src/components/ShakeHand.jsx +++ b/FrontendTemplate/src/components/ShakeHand.jsx @@ -79,7 +79,9 @@ const Wrapper = styled.section ` font-size: 20px; height: 40px; width: 200px; - display: inline-block; + display: flex; + justify-content: center; + align-items: center; padding: 10px 20px; border: none; border-radius: 20px; diff --git a/FrontendTemplate/src/components/gameControllers.js b/FrontendTemplate/src/components/gameControllers.js index 4f922d9..a06d357 100644 --- a/FrontendTemplate/src/components/gameControllers.js +++ b/FrontendTemplate/src/components/gameControllers.js @@ -29,10 +29,10 @@ export function updateScore(scores, move, guess) { var police; for (let i = 0; i < 4; i++) { - if (move[i] == 0) score[i] = 40; - else if (move[i] == 1) score[i] = 60; - else if (move[i] == 3) score[i] = 100; - else if (move[i] == 2) { + if (move[i] === 0) score[i] = 40; + else if (move[i] === 1) score[i] = 60; + else if (move[i] === 3) score[i] = 100; + else if (move[i] === 2) { score[i] = 80; police = i; } diff --git a/FrontendTemplate/src/pages/ai_page/AIPage.jsx b/FrontendTemplate/src/pages/ai_page/AIPage.jsx index fcccd76..ade6a11 100644 --- a/FrontendTemplate/src/pages/ai_page/AIPage.jsx +++ b/FrontendTemplate/src/pages/ai_page/AIPage.jsx @@ -1,7 +1,6 @@ import "./AIPage.css"; import { FloatButton } from "antd"; import { CommentOutlined } from "@ant-design/icons"; -import ChatModal from "../../components/ChatModal"; import { useEffect, useState } from "react"; import GameBoard from "../../components/GameBoard"; @@ -58,7 +57,7 @@ export default function AIPage() { console.log("Scoreee isss: "); // console.log(scores[0][scores[0].length - 1]); var maxScore = Math.max(...totalScore); - if (maxScore >= 140) { + if (maxScore >= 1500) { setIsGameOver(true); console.log(isGameOver); console.log("yes i am true"); @@ -105,11 +104,13 @@ export default function AIPage() { const randomValue = currentTimestamp % 19; const a = peopleNames[randomValue]; const b = peopleNames[randomValue + 1]; - const c = peopleNames[randomValue + 2]; + const c = peopleNames[randomValue + 2]; setSelectedNames([userData.username, a, b, c]); + const tmpScore = [[userData.username], [a], [b], [c]]; + console.log(tmpScore); - setScore([[userData.username], [a], [b], [c]]); + setScore(tmpScore); initiated = true; } @@ -120,7 +121,7 @@ export default function AIPage() { return ( <> - {isGameOver ? ( + {isGameOver && ( - ) : ( - )} - - } - onClick={() => { - setIsModalOpen(true); - }} - />
+
Chor Dakat Babu Police @@ -41,6 +41,6 @@ export default function LandingPage() { }}>continue
- +
); } From c278dee1ab26b12c590bd634bed1ea203c9a3cf7 Mon Sep 17 00:00:00 2001 From: codermehraj Date: Mon, 8 Jan 2024 02:44:57 +0600 Subject: [PATCH 2/2] fixed leaderboard and phone palyer card css in ai page --- FrontendTemplate/src/components/Players.jsx | 16 ++++++++++------ FrontendTemplate/src/pages/ai_page/AIPage.css | 7 +++++++ FrontendTemplate/src/pages/ai_page/AIPage.jsx | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/FrontendTemplate/src/components/Players.jsx b/FrontendTemplate/src/components/Players.jsx index b7ac6fd..4fb9e4a 100644 --- a/FrontendTemplate/src/components/Players.jsx +++ b/FrontendTemplate/src/components/Players.jsx @@ -89,17 +89,22 @@ const Wrapper = styled.section` flex-direction: column; justify-content: center; align-items: center; - height: 275px; + height: 150px; + } + .color-name { + font-size: 15px; } .player-container .image { - margin-top: -20px; + /* margin-top: -20px; */ max-height: 70%; } .player-container .r8 { - margin-top: -80px; + margin-top: -30px; + font-size: 15px; } .r8 { - margin-top: -30px; + /* margin-top: -10px; */ + font-size: 15px; padding: 0px; } .image { @@ -107,8 +112,7 @@ const Wrapper = styled.section` max-height: 100%; } .name { - font-size: 25px; - padding: 20px; + font-size: 15px; } } `; diff --git a/FrontendTemplate/src/pages/ai_page/AIPage.css b/FrontendTemplate/src/pages/ai_page/AIPage.css index 872ff32..e1af49d 100644 --- a/FrontendTemplate/src/pages/ai_page/AIPage.css +++ b/FrontendTemplate/src/pages/ai_page/AIPage.css @@ -30,6 +30,13 @@ border: 1px solid black; } +.score-row-element{ + display:block; + width:100%; + height: 30px; + overflow: hidden; +} + @media (max-width: 768px) { .ai-canvas{ flex-direction: column; diff --git a/FrontendTemplate/src/pages/ai_page/AIPage.jsx b/FrontendTemplate/src/pages/ai_page/AIPage.jsx index ade6a11..4ebab4e 100644 --- a/FrontendTemplate/src/pages/ai_page/AIPage.jsx +++ b/FrontendTemplate/src/pages/ai_page/AIPage.jsx @@ -146,7 +146,7 @@ export default function AIPage() { {scores.map((score, index) => (
{score.map((point, idx) => ( - + {point}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy