fix game jam

This commit is contained in:
lingdocs 2021-09-03 15:15:26 +04:00
parent 5210dfa3d4
commit f250acc4b1
3 changed files with 10 additions and 7 deletions

View File

@ -15,6 +15,8 @@ import {
firstVariation,
} from "../lib/text-tools";
const genders: T.Gender[] = ["masc", "fem"];
// const masc = words.filter((w) => w.entry.c === "n. m.");
// const fem = words.filter((w) => w.entry.c === "n. f.");
type CategorySet = Record<string, { category: string, def: string, entry: T.DictionaryEntry }[]>;
@ -51,15 +53,16 @@ const amount = 40;
export default function({level}: { level: 1 | 2 }) {
function* questions () {
const wordPool = {...types};
const exceptionsPool = {...exceptions};
for (let i = 0; i < amount; i++) {
const base = level === 1
? wordPool
: getRandomFromList([wordPool, exceptions]);
const gender = getRandomFromList(Object.keys(base));
: getRandomFromList([wordPool, exceptionsPool]);
const gender = getRandomFromList(genders);
let typeToUse: string;
do {
typeToUse = getRandomFromList(Object.keys(base[gender]));
} while (!base[gender].length);
} while (!base[gender][typeToUse].length);
const question = getRandomFromList(base[gender][typeToUse]).entry;
base[gender][typeToUse] = base[gender][typeToUse].filter(({ entry }) => entry.ts !== question.ts);
yield {

View File

@ -104,9 +104,9 @@ export default function() {
value={answer}
onChange={handleInput}
/>
</div>
<div>
<button type="submit" className="btn btn-primary">Check</button>
<div className="text-muted small mt-3">
Type <kbd>Enter</kbd> to check
</div>
</div>
</form>

View File

@ -40,7 +40,7 @@ module.exports = [
{ ts: 1575924767041, e: `shepherd` }, // شپون - shpoon
{ ts: 1527815279, e: `shepherd` }, // شپونکی - shpoonkey
{ ts: 1527819173, e: `analyst, examiner` }, // شنونکی - shanóonkey
{ ts: 1612614411126, e: `teacher` }, // ښووونکی - xowóonkey
{ ts: 1527812806, e: `teacher` }, // ښووونکی - xowóonkey
{ ts: 1527815436, e: `tyrant, oppressor, cruel person` }, // ظالم - zaalim
{ ts: 1527818632, e: `twin` }, // غبرګونی - ghbargoney
{ ts: 1527812624, e: `thief` }, // غل - ghul