Make the max limit count actually end the game
This commit is contained in:
parent
d760f249e2
commit
1764eb9c53
1 changed files with 6 additions and 3 deletions
|
|
@ -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;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue