0
0
Fork 0

Make the max limit count actually end the game

This commit is contained in:
Oliver-Akins 2023-01-19 12:46:20 -06:00
parent d760f249e2
commit 1764eb9c53

View file

@ -1,4 +1,4 @@
import { database } from "$/main"; import { config, database } from "$/main";
import { addLetter } from "$/utils/game"; import { addLetter } from "$/utils/game";
import { ServerRoute } from "@hapi/hapi"; import { ServerRoute } from "@hapi/hapi";
import Joi from "joi"; import Joi from "joi";
@ -22,12 +22,15 @@ const route: ServerRoute = {
let data = await database.getChannel(channel); let data = await database.getChannel(channel);
console.log(data) console.log(data)
if (data.solution.includes(guess)) { if (data.key[guess] != null) {
data.current = addLetter(data.key, data.current, guess); data.current = addLetter(data.key, data.current, guess);
} else { } else {
data.incorrect++; data.incorrect++;
}; };
return `${data.current} (incorrect: ${data.incorrect}/6)`; if (data.incorrect >= config.game.max_incorrect) {
return `Oop, you ded. Answer: ${data.solution}`;
};
return `${data.current} (incorrect: ${data.incorrect}/${config.game.max_incorrect})`;
}, },
}; };
export default route; export default route;