From 16066df914af130c030878444d03896a970e6127 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Sat, 11 Sep 2021 03:23:29 +0400 Subject: [PATCH] more stuff on game format --- src/components/Game.tsx | 133 ----------------- src/content/nouns/nouns-gender.mdx | 6 +- src/content/nouns/nouns-unisex.mdx | 8 +- src/games/Game.tsx | 144 +++++++++++++++++++ src/{components => games}/GenderGame.tsx | 2 + src/{components => games}/UnisexNounGame.tsx | 2 + src/{components => games}/timer.css | 0 src/types.d.ts | 2 + 8 files changed, 154 insertions(+), 143 deletions(-) delete mode 100644 src/components/Game.tsx create mode 100644 src/games/Game.tsx rename src/{components => games}/GenderGame.tsx (95%) rename src/{components => games}/UnisexNounGame.tsx (98%) rename src/{components => games}/timer.css (100%) diff --git a/src/components/Game.tsx b/src/components/Game.tsx deleted file mode 100644 index 557177a..0000000 --- a/src/components/Game.tsx +++ /dev/null @@ -1,133 +0,0 @@ -import React, { useState, useRef } from "react"; -import { CountdownCircleTimer } from "react-countdown-circle-timer"; -import Reward, { RewardElement } from 'react-rewards'; -import "./timer.css"; -import { - getPercentageDone, -} from "../lib/game-utils"; -const errorVibration = 200; - -function Game({ questions, Display, timeLimit, Instructions }: GameInput) { - const rewardRef = useRef(null); - const [finish, setFinish] = useState(null); - const [current, setCurrent] = useState | undefined>(undefined); - const [questionBox, setQuestionBox] = useState>(questions()); - const [timerKey, setTimerKey] = useState(1); - - function handleCallback(correct: boolean) { - if (correct) handleAdvance(); - else handleFailure(); - } - function handleFailure() { - // rewardRef.current?.punishMe(); - setFinish("fail"); - navigator.vibrate(errorVibration); - } - function handleAdvance() { - const next = questionBox.next(); - if (next.done) handleFinish(); - else setCurrent(next.value); - } - function handleFinish() { - // post results - setFinish("pass"); - rewardRef.current?.rewardMe(); - setCurrent(undefined); - } - function handleQuit() { - setFinish(null); - setCurrent(undefined); - } - function handleRestart() { - const newQuestionBox = questions(); - const { value } = newQuestionBox.next(); - // just for type safety -- the generator will have at least one question - if (!value) return; - setQuestionBox(newQuestionBox); - setFinish(null); - setCurrent(value); - setTimerKey(prev => prev + 1); - } - function handleTimeOut() { - setFinish("time out"); - navigator.vibrate(errorVibration); - } - function getProgressWidth(): string { - const num = !current - ? 0 - : (finish === "pass") - ? 100 - : getPercentageDone(current.progress); - return `${num}%`; - } - const progressColor = finish === "pass" - ? "success" - : finish === "fail" - ? "danger" - : "primary"; - return
-
-
-
- {current &&
- - {!finish && } -
} - -
- {finish === null && - (current - ?
- -
- :
-
- {/* TODO: ADD IN TEXT DISPLAY OPTIONS HERE TOO - WHEN WE START USING THEM*/} - -
-
- -
-
) - } - {finish === "pass" &&
-

- 🎉 Finished! -

- -
} - {(finish === "fail" || finish === "time out") &&
-

{failMessage(current?.progress, finish)}

- -
} -
-
-
; -} - -function failMessage(progress: Progress | undefined, finish: "time out" | "fail"): string { - const pDone = progress ? getPercentageDone(progress) : 0; - const { message, face } = pDone < 20 - ? { message: "No, sorry", face: "😑" } - : pDone < 30 - ? { message: "Oops, that's wrong", face: "😟" } - : pDone < 55 - ? { message: "Fail", face: "😕" } - : pDone < 78 - ? { message: "You almost got it!", face: "😩" } - : { message: "Nooo! So close!", face: "😭" }; - return finish === "fail" - ? `${message} ${face}` - : `⏳ Time's Up ${face}`; -} - -export default Game; \ No newline at end of file diff --git a/src/content/nouns/nouns-gender.mdx b/src/content/nouns/nouns-gender.mdx index bb8a681..19564eb 100644 --- a/src/content/nouns/nouns-gender.mdx +++ b/src/content/nouns/nouns-gender.mdx @@ -8,7 +8,7 @@ import { Examples, } from "@lingdocs/pashto-inflector"; import genderColors from "../../lib/gender-colors"; -import GenderGame from "../../components/GenderGame"; +import GenderGame from "../../games/GenderGame"; import { firstVariation } from "../../lib/text-tools"; import GenderTable from "../../components/GenderTable"; import Link from "../../components/Link"; @@ -109,8 +109,6 @@ All nouns in Pashto are either or . Thankfully, you can pretty m - Words ending in can be either or . - Words ending in can also be plural, as in -**🕹 Here's a little game to practice identifying the genders of words:** - ## Exceptions @@ -166,6 +164,4 @@ Some words are used to describe people who obviously have a gender and they *tot }, ]} /> -**🕹 Let's try the game again, this time with the exceptions included:** - diff --git a/src/content/nouns/nouns-unisex.mdx b/src/content/nouns/nouns-unisex.mdx index b0fac0e..b5d72a2 100644 --- a/src/content/nouns/nouns-unisex.mdx +++ b/src/content/nouns/nouns-unisex.mdx @@ -10,7 +10,7 @@ import { import Table from "../../components/Table"; import Link from "../../components/Link"; import GenderTable from "../../components/GenderTable"; -import UnisexNounGame from "../../components/UnisexNounGame"; +import UnisexNounGame from "../../games/UnisexNounGame"; There are many words for people and animals in Pashto that can be used in both masculine and feminine forms. @@ -64,10 +64,10 @@ With the feminine form the on }, { masc: { - ex: {p: "ښووونکی", f:"xowóonkey", e: "male teacher 👨‍🏫" }, + ex: {p: "ښوونکی", f:"xUwóonkey", e: "male teacher 👨‍🏫" }, }, fem: { - ex: { p: "ښووونکې", f: "xowóonke", e: "female teacher 👩‍🏫" }, + ex: { p: "ښوونکې", f: "xUwóonke", e: "female teacher 👩‍🏫" }, }, }, ]} /> @@ -209,8 +209,6 @@ If the accent comes on the end of the word, the femine form is a little differen } ]} /> -**🕹 Here's a game to practice changing the genders of nouns** -