feat(loldle): reject duplicate guesses within a round

Prevents two players in a group from wasting a slot on the same champion —
re-guessing a previously tried champion replies with a hint and does not
consume a guess.
This commit is contained in:
tiennm99 committed 2026-04-22 09:35:22 +07:00
1 parent d03b1859a5
commit da79408542
1 file changed
+7
+7
View File
@@ -118,6 +118,13 @@ export async function handleLoldle(ctx, db) {
const guess = findChampion(champions, arg);
if (!guess) return ctx.reply(`Champion not found: "${arg}".`);
if (game.guesses.some((g) => g.champion === guess.name)) {
return ctx.reply(
`🔁 <b>${escapeHtml(guess.name)}</b> was already guessed this round — try another champion.`,
{ parse_mode: "HTML" },
);
}
const target = champions.find((c) => c.id === game.target);
// champions.json can be refreshed between rounds — an active target may disappear.
if (!target) {