Skip to content

Commit

Permalink
Switch to shuffle-quiz
Browse files Browse the repository at this point in the history
  • Loading branch information
staadecker committed Mar 11, 2024
1 parent 9af5fed commit c7666ea
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_DOMAIN="https://pop-uoft.web.app"
VITE_DOMAIN="https://shuffle-quiz.web.app"
2 changes: 1 addition & 1 deletion .firebaserc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"projects": {
"default": "pop-uoft"
"default": "shuffle-quiz"
}
}
4 changes: 2 additions & 2 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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?

Expand Down
1 change: 1 addition & 0 deletions firebase-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[debug] [2024-03-11T22:51:34.304Z] ----------------------------------------------------------------------
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
14 changes: 7 additions & 7 deletions src/firebase/FirebaseContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export const FirebaseProvider = (props: { children: React.ReactNode }) => {
const [currentUser, setCurrentUser] = useState<User | undefined>();

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);
Expand All @@ -38,7 +38,7 @@ export const FirebaseProvider = (props: { children: React.ReactNode }) => {
if (currentUser === undefined) {
return <Loading fullScreen />;
}

return (
<FirebaseContext.Provider value={{ app, auth, db, currentUser }}>
{props.children}
Expand Down
8 changes: 4 additions & 4 deletions src/firebase/db_queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ 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);
const ref = doc(db, "games", gameId);

await setDoc(ref, {
startTime: new Date(Date.now() + 1000 * waitTime),
popInterval,
numberOfPops,
roundDuration,
numRounds,
question,
});
return gameId;
Expand Down
4 changes: 2 additions & 2 deletions src/firebase/db_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Timestamp } from "firebase/firestore";

export type GameMetaData = {
startTime: Timestamp;
numberOfPops: number;
popInterval: number;
numRounds: number;
roundDuration: number;
question: string;
};

Expand Down
12 changes: 6 additions & 6 deletions src/game_logic/state_machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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) {
Expand All @@ -198,7 +198,7 @@ export const getExpectedState = (
}

return {
timeToChange: popInterval - timeSinceEvent,
timeToChange: roundDuration - timeSinceEvent,
state: "in_progress",
round: round,
};
Expand Down
1 change: 0 additions & 1 deletion src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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([
{
Expand Down
8 changes: 4 additions & 4 deletions src/routes/CreateGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);

Expand All @@ -50,15 +50,15 @@ const CreateGame = () => {
<div className="flex flex-row space-x-8">
<TextField
label="Number of rounds"
name="numberOfPops"
name="numRounds"
defaultValue={3}
type="number"
/>
<TextField
label="Round duration"
defaultValue={3}
type="number"
name="popInterval"
name="roundDuration"
InputProps={{
endAdornment: (
<InputAdornment position="end">min</InputAdornment>
Expand Down
6 changes: 3 additions & 3 deletions src/routes/ManageGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ const ManageGamePage = () => {
<div className="flex flex-row h-full w-full p-8 items-stretch">
<div className="flex flex-col items-center basis-1/2">
<h1 className="text-4xl py-4">Join Game</h1>
<div className="rounded-xl bg-white text-center space-y-0 pb-8">
<div className="rounded-xl bg-white text-center space-y-0 pb-8 px-4">
<QRCode />
<a
href={link}
className="underline text-4xl font-bold text-blue-900 py-8"
target="_blank"
>
{link.split("//")[1]}
</a>
</a>
</div>
</div>
<div className="basis-1/2 flex flex-col">
Expand All @@ -80,7 +80,7 @@ const ManageGamePage = () => {
const QRCode = () => {
const { state } = useGame();
return (
<div className="p-8 ">
<div className="p-8 flex flex-row justify-center">
<QRCodeSVG
value={import.meta.env.DOMAIN + state.context.gameId}
size={300}
Expand Down

0 comments on commit c7666ea

Please sign in to comment.