[repo] desacoplamento e maior coesão
This commit is contained in:
synt-xerror
2026-03-13 11:30:34 -03:00
parent fe95e77a68
commit 88a7abba5d
19 changed files with 439 additions and 393 deletions

29
src/games/adivinhacao.js Normal file
View File

@@ -0,0 +1,29 @@
import { botMsg } from "../utils/botMsg.js";
let jogoAtivo = null;
export function iniciarJogo() {
jogoAtivo = Math.floor(Math.random()*100)+1;
return jogoAtivo;
}
export function pararJogo() {
jogoAtivo = null;
}
export async function processarJogo(msg, chat) {
if (!jogoAtivo) return;
const tentativa = msg.body.trim();
if (!/^\d+$/.test(tentativa)) return;
const num = parseInt(tentativa);
if (num === jogoAtivo) {
await msg.reply(botMsg(`Acertou! Número: ${jogoAtivo}`));
pararJogo();
} else if (num > jogoAtivo) {
await chat.sendMessage(botMsg("Menor."));
} else {
await chat.sendMessage(botMsg("Maior."));
}
}