From c7666ea039d8cd0d0a9b7c7eeafec71022a50f7f Mon Sep 17 00:00:00 2001 From: Martin Staadecker Date: Mon, 11 Mar 2024 18:51:54 -0400 Subject: [PATCH] Switch to shuffle-quiz --- .env.production | 2 +- .firebaserc | 2 +- .github/workflows/firebase-hosting-merge.yml | 4 ++-- .../workflows/firebase-hosting-pull-request.yml | 4 ++-- README.md | 2 +- firebase-debug.log | 1 + package.json | 4 ++-- src/firebase/FirebaseContext.tsx | 14 +++++++------- src/firebase/db_queries.ts | 8 ++++---- src/firebase/db_schema.ts | 4 ++-- src/game_logic/state_machine.ts | 12 ++++++------ src/router.tsx | 1 - src/routes/CreateGame.tsx | 8 ++++---- src/routes/ManageGame.tsx | 6 +++--- 14 files changed, 36 insertions(+), 36 deletions(-) create mode 100644 firebase-debug.log diff --git a/.env.production b/.env.production index db03122..f8e8a22 100644 --- a/.env.production +++ b/.env.production @@ -1 +1 @@ -VITE_DOMAIN="https://pop-uoft.web.app" \ No newline at end of file +VITE_DOMAIN="https://shuffle-quiz.web.app" \ No newline at end of file diff --git a/.firebaserc b/.firebaserc index d32493e..77c5922 100644 --- a/.firebaserc +++ b/.firebaserc @@ -1,5 +1,5 @@ { "projects": { - "default": "pop-uoft" + "default": "shuffle-quiz" } } diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index 3203207..19626e9 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -15,6 +15,6 @@ jobs: - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: '${{ secrets.GITHUB_TOKEN }}' - firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_POP_UOFT }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_SHUFFLE_QUIZ }}' channelId: live - projectId: pop-uoft + projectId: shuffle-quiz diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 4f32d0d..596f87e 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -13,5 +13,5 @@ jobs: - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: '${{ secrets.GITHUB_TOKEN }}' - firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_POP_UOFT }}' - projectId: pop-uoft + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_SHUFFLE_QUIZ }}' + projectId: shuffle-quiz diff --git a/README.md b/README.md index 58f4473..bef61ef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Shuffle Quiz -Try it out: [https://pop-uoft.web.app/](https://pop-uoft.web.app/) ! +Try it out: [https://shuffle-quiz.web.app/](https://shuffle-quiz.web.app/) ! ## What is this? diff --git a/firebase-debug.log b/firebase-debug.log new file mode 100644 index 0000000..6eee234 --- /dev/null +++ b/firebase-debug.log @@ -0,0 +1 @@ +[debug] [2024-03-11T22:51:34.304Z] ---------------------------------------------------------------------- diff --git a/package.json b/package.json index 4e97f6c..508ce06 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "pop-uoft", + "name": "shuffle-quiz", "version": "0.0.0", - "repository": "https://github.com/staadecker/pop-uoft", + "repository": "https://github.com/staadecker/shuffle-quiz", "author": "Martin Staadecker", "license": "MIT", "private": true, diff --git a/src/firebase/FirebaseContext.tsx b/src/firebase/FirebaseContext.tsx index beb2a1c..dbd3e16 100644 --- a/src/firebase/FirebaseContext.tsx +++ b/src/firebase/FirebaseContext.tsx @@ -18,12 +18,12 @@ export const FirebaseProvider = (props: { children: React.ReactNode }) => { const [currentUser, setCurrentUser] = useState(); const app = initializeApp({ - apiKey: "AIzaSyCnIpYjoP9LBwfEyEcMQgq4gd0vaa6BstA", - authDomain: "pop-uoft.firebaseapp.com", - projectId: "pop-uoft", - storageBucket: "pop-uoft.appspot.com", - messagingSenderId: "448097432689", - appId: "1:448097432689:web:1a82ae4b88d2f2e28a97d0", + apiKey: "AIzaSyBv0iJ3X3EDJ5Im1hBmBDpQ8tKO3F3TjZo", + authDomain: "shuffle-quiz.firebaseapp.com", + projectId: "shuffle-quiz", + storageBucket: "shuffle-quiz.appspot.com", + messagingSenderId: "774018965451", + appId: "1:774018965451:web:19c826207d24e9d0b8204e", }); const auth = getAuth(app); const db = getFirestore(app); @@ -38,7 +38,7 @@ export const FirebaseProvider = (props: { children: React.ReactNode }) => { if (currentUser === undefined) { return ; } - + return ( {props.children} diff --git a/src/firebase/db_queries.ts b/src/firebase/db_queries.ts index c83ae23..b74e1ec 100644 --- a/src/firebase/db_queries.ts +++ b/src/firebase/db_queries.ts @@ -122,8 +122,8 @@ export const loadPriorWorks = async ( export const createGame = async ( db: Firestore, waitTime: number, - popInterval: number, - numberOfPops: number, + roundDuration: number, + numRounds: number, question: string ) => { const gameId = getRandomGameId(3); @@ -131,8 +131,8 @@ export const createGame = async ( await setDoc(ref, { startTime: new Date(Date.now() + 1000 * waitTime), - popInterval, - numberOfPops, + roundDuration, + numRounds, question, }); return gameId; diff --git a/src/firebase/db_schema.ts b/src/firebase/db_schema.ts index c6ae1c2..8806f70 100644 --- a/src/firebase/db_schema.ts +++ b/src/firebase/db_schema.ts @@ -2,8 +2,8 @@ import { Timestamp } from "firebase/firestore"; export type GameMetaData = { startTime: Timestamp; - numberOfPops: number; - popInterval: number; + numRounds: number; + roundDuration: number; question: string; }; diff --git a/src/game_logic/state_machine.ts b/src/game_logic/state_machine.ts index 4b0ee89..ed9e956 100644 --- a/src/game_logic/state_machine.ts +++ b/src/game_logic/state_machine.ts @@ -87,7 +87,7 @@ export const useGameStateMachine = (gameId: string, isPlayer: boolean) => { if (context.users[context.currentUserUid] === undefined && isPlayer) send("already_started"); - if (Object.keys(context.users).length < context.meta!.numberOfPops) + if (Object.keys(context.users).length < context.meta!.numRounds) send("not_enough_players"); const expectedState = getExpectedState(context).state; if (expectedState === "in_progress" || expectedState === "saving_work") @@ -179,14 +179,14 @@ export const getExpectedState = ( } let round = 0; - const popInterval = context.meta!.popInterval * 60 * 1000; + const roundDuration = context.meta!.roundDuration * 60 * 1000; let timeSinceEvent = currentTime - startTime; - while (timeSinceEvent >= popInterval) { + while (timeSinceEvent >= roundDuration) { round++; - if (round == context.meta!.numberOfPops) { + if (round == context.meta!.numRounds) { return { state: "finished" }; } - timeSinceEvent -= popInterval; + timeSinceEvent -= roundDuration; } if (timeSinceEvent < SAVING_TIME && round > 0) { @@ -198,7 +198,7 @@ export const getExpectedState = ( } return { - timeToChange: popInterval - timeSinceEvent, + timeToChange: roundDuration - timeSinceEvent, state: "in_progress", round: round, }; diff --git a/src/router.tsx b/src/router.tsx index f492d5b..a3bcf85 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -2,7 +2,6 @@ import { createBrowserRouter } from "react-router-dom"; import CreateGame from "./routes/CreateGame"; import ManageGame from "./routes/ManageGame"; import GamePage from "./routes/GamePage"; -import MessagePage from "./components/MessagePage"; export const router = createBrowserRouter([ { diff --git a/src/routes/CreateGame.tsx b/src/routes/CreateGame.tsx index e9bd0c9..862c379 100644 --- a/src/routes/CreateGame.tsx +++ b/src/routes/CreateGame.tsx @@ -28,8 +28,8 @@ const CreateGame = () => { const gameId = await createGame( db, Number(formData.get("waitingTime")), - Number(formData.get("popInterval")), - Number(formData.get("numberOfPops")), + Number(formData.get("roundDuration")), + Number(formData.get("numRounds")), getEditorState(editor) ); @@ -50,7 +50,7 @@ const CreateGame = () => {
@@ -58,7 +58,7 @@ const CreateGame = () => { label="Round duration" defaultValue={3} type="number" - name="popInterval" + name="roundDuration" InputProps={{ endAdornment: ( min diff --git a/src/routes/ManageGame.tsx b/src/routes/ManageGame.tsx index 3f4cb98..0be600e 100644 --- a/src/routes/ManageGame.tsx +++ b/src/routes/ManageGame.tsx @@ -58,7 +58,7 @@ const ManageGamePage = () => {

Join Game

-
@@ -80,7 +80,7 @@ const ManageGamePage = () => { const QRCode = () => { const { state } = useGame(); return ( -
+