diff --git a/frontend/package.json b/frontend/package.json index fc3ba53..5420eb1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,6 +8,7 @@ "@emotion/core": "^11.0.0", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", + "@ramonak/react-progress-bar": "^5.2.0", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", diff --git a/frontend/src/Components/ScoreModal.js b/frontend/src/Components/ScoreModal.js index 2a5643d..3367bc1 100644 --- a/frontend/src/Components/ScoreModal.js +++ b/frontend/src/Components/ScoreModal.js @@ -20,7 +20,7 @@ export default function ScoreModal({ You Answered - {userGuess} + @@ -30,7 +30,9 @@ export default function ScoreModal({ Correct Answer - {gameState["gameObjects"][progression]["objectEndDate"]} + @@ -62,6 +64,9 @@ export default function ScoreModal({ ); } + +export function YearEra({ year }) { + const era = year >= 0 ? "C.E." : "B.C.E."; + + return ( + + {year > 0 ? year : year * -1} {era} + + ); +} diff --git a/frontend/src/Pages/Game/ArtifactViewer.js b/frontend/src/Pages/Game/ArtifactViewer.js index de442cd..924d98c 100644 --- a/frontend/src/Pages/Game/ArtifactViewer.js +++ b/frontend/src/Pages/Game/ArtifactViewer.js @@ -7,9 +7,12 @@ import { Box, Text, Center, + Icon, } from "@chakra-ui/react"; import Zoom from "react-medium-image-zoom"; import "react-medium-image-zoom/dist/styles.css"; +import FadeInUpBox from "../../Components/FadeUp"; +import { FiZoomIn } from "react-icons/fi"; export default function ArtifactViewer({ gameObjects, progression }) { const [bigImgSrc, setBigImgSrc] = useState(gameObjects[0]["primaryImage"]); @@ -25,17 +28,8 @@ export default function ArtifactViewer({ gameObjects, progression }) { }, [progression]); return ( - - {/* additional images */} - - - - - + + {/* image */} {loading ? ( @@ -44,11 +38,19 @@ export default function ArtifactViewer({ gameObjects, progression }) { ) : ( - - + + )} - + + + + + Click image to enlarge + + + + {/* image description */} - {gameObjects[progression]["title"]} + {gameObjects[progression]["title"].substring(0, 75)} + {gameObjects[progression]["title"].length >= 75 && "..."} )} @@ -85,7 +88,9 @@ export default function ArtifactViewer({ gameObjects, progression }) { color="brand.700" fontFamily="monospace" > - {gameObjects[progression]["artistDisplayName"]} + {gameObjects[progression]["artistDisplayName"].substring(0, 50)} + {gameObjects[progression]["artistDisplayName"].length >= 50 && + "..."} )} @@ -100,7 +105,8 @@ export default function ArtifactViewer({ gameObjects, progression }) { color="brand.700" fontFamily="monospace" > - {gameObjects[progression]["medium"]} + {gameObjects[progression]["medium"].substring(0, 75)} + {gameObjects[progression]["medium"].length >= 75 && "..."} )} diff --git a/frontend/src/Pages/Game/Game.js b/frontend/src/Pages/Game/Game.js index fa2312c..a4a87e2 100644 --- a/frontend/src/Pages/Game/Game.js +++ b/frontend/src/Pages/Game/Game.js @@ -75,12 +75,7 @@ export default function Game({ setStage, gameState, setGameState }) { return ( {/* top legend */} - + {/* main content */} - - { - if (progression != 0) setProgression(progression - 1); - }} - icon={} - /> - + - - - {gameState["playerGuessed"].map((guessed, index) => { - return ( - - {guessed ? ( - { - setProgression(index); - }} - _hover={{ cursor: "pointer" }} - /> - ) : ( - { - setProgression(index); - }} - _hover={{ cursor: "pointer" }} - /> - )} - - ); - })} - + + + + + ); +} + +const TopMenuBar = () => { + return ( + - { - if (progression != 4) setProgression(progression + 1); - }} - icon={} - /> + + + ); -} +}; diff --git a/frontend/src/Pages/Game/GuessingBox.js b/frontend/src/Pages/Game/GuessingBox.js index 16d9d6c..b8e7e3c 100644 --- a/frontend/src/Pages/Game/GuessingBox.js +++ b/frontend/src/Pages/Game/GuessingBox.js @@ -25,6 +25,7 @@ export default function GuessingBox({ setStage, }) { const { isOpen, onOpen, onClose } = useDisclosure(); + const [isCE, setIsCE] = useState(true); const handleGuess = () => { // validate input @@ -32,17 +33,24 @@ export default function GuessingBox({ return; } + var playerGuess = 0; + if (!isCE) { + playerGuess = -1 * guess; + setGuess(-1 * guess); + } else playerGuess = 1 * guess; + // get prev game state const playerGuessed = structuredClone(gameState["playerGuessed"]); playerGuessed[progression] = true; // set current progression to true const guessNumbers = structuredClone(gameState["guesses"]); - guessNumbers[progression] = guess; + guessNumbers[progression] = playerGuess; // calculate round score var roundScore = 0; const difference = Math.abs( - gameState["gameObjects"][progression]["objectEndDate"] - parseInt(guess) + gameState["gameObjects"][progression]["objectEndDate"] - + parseInt(playerGuess) ); if (difference <= 1000) { roundScore = 1000 - difference; @@ -86,30 +94,70 @@ export default function GuessingBox({ - { - setGuess(e.target.value); - }} - > + > + { + if (e.target.value.toString().charAt(0) == "-") { + setIsCE(false); + setGuess(e.target.value.substring(1)); + } else setGuess(e.target.value); + }} + /> + { + setIsCE(!isCE); + }} + > + + {isCE ? "C.E." : "B.C.E."} + + + Guess the year! + + {/* next button */} {guess != "" ? ( { return ( - + gamemode diff --git a/frontend/src/Pages/PostGame/Results.js b/frontend/src/Pages/PostGame/Results.js index d6f5c0c..52db3aa 100644 --- a/frontend/src/Pages/PostGame/Results.js +++ b/frontend/src/Pages/PostGame/Results.js @@ -12,11 +12,12 @@ import { useEffect, useState } from "react"; import CountUp from "react-countup"; import { FiCheck, FiX } from "react-icons/fi"; import FadeInUpBox from "../../Components/FadeUp"; +import { YearEra } from "../../Components/ScoreModal"; export default function Results({ gameState, setStage }) { const [congratsText, setCongratsText] = useState(""); - const delay = 0.5; + const delay = 0.2; useEffect(() => { if (gameState["score"] >= 4000) setCongratsText("Fantastic job!"); @@ -27,138 +28,138 @@ export default function Results({ gameState, setStage }) { }, [gameState]); return ( - - {/* congratulatory text */} - - - {congratsText} - - - - {/* render score */} - - - - {" "} - / 5000 - + + + {/* congratulatory text */} + + + {congratsText} + - - {/* recap */} - - - {gameState["gameObjects"].map((obj, index) => { - return ( - - - {/* artifact image */} - + {/* render score */} + + + + {" "} + / 5000 + + + + + {/* recap */} + + + {gameState["gameObjects"].map((obj, index) => { + return ( + + + {/* artifact image */} + - {/* answers */} - - - {parseInt(obj["objectEndDate"]) == - parseInt(gameState["guesses"][index]) ? ( + {/* answers */} + + + {parseInt(obj["objectEndDate"]) == + parseInt(gameState["guesses"][index]) ? ( + + ) : ( + + )} + + + + + - ) : ( - - )} - - {gameState["guesses"][index]} - - - - + + + + + + + {/* pts earned */} + - {obj["objectEndDate"]} + {gameState["roundScores"][index]} pts - + + + ); + })} + + - {/* pts earned */} - - - {gameState["roundScores"][index]} pts - - - - - ); - })} + {/* button menu */} + + + + + + + + + + + + + - - - {/* button menu */} - - - - - - - - - - - - - ); diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 0111d6f..e0b210e 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -2609,6 +2609,11 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A== +"@ramonak/react-progress-bar@^5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@ramonak/react-progress-bar/-/react-progress-bar-5.2.0.tgz#30d72850b0f2f5020d59d5bcc94d54f8f2393aec" + integrity sha512-hgsn1YSXzDplCVNJ/YiCM0nVbVHKu7+2OHlj3kr2wU9ELPa9A/qj+c+GKGKqzJullsofRJV5yMN/Y/jL9aE4/Q== + "@remix-run/router@1.15.3": version "1.15.3" resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.15.3.tgz#d2509048d69dbb72d5389a14945339f1430b2d3c"