feat(economy): enhance minigame commands to track stats, quest progress, and achievements

This commit is contained in:
2025-10-05 05:35:32 -05:00
parent b10cc89583
commit 0990533f6e
15 changed files with 954 additions and 30 deletions

View File

@@ -2,6 +2,9 @@ import type { CommandMessage } from '../../../core/types/commands';
import type Amayo from '../../../core/client';
import { runMinigame } from '../../../game/minigames/service';
import { resolveArea, getDefaultLevel, findBestToolKey } from './_helpers';
import { updateStats } from '../../../game/stats/service';
import { updateQuestProgress } from '../../../game/quests/service';
import { checkAchievements } from '../../../game/achievements/service';
export const command: CommandMessage = {
name: 'pelear',
@@ -26,13 +29,37 @@ export const command: CommandMessage = {
try {
const result = await runMinigame(userId, guildId, areaKey, level, { toolKey: toolKey ?? undefined });
// Actualizar stats y misiones
await updateStats(userId, guildId, { fightsCompleted: 1 });
await updateQuestProgress(userId, guildId, 'fight_count', 1);
// Contar mobs derrotados
const mobsCount = result.mobs.length;
if (mobsCount > 0) {
await updateStats(userId, guildId, { mobsDefeated: mobsCount });
await updateQuestProgress(userId, guildId, 'mob_defeat_count', mobsCount);
}
const newAchievements = await checkAchievements(userId, guildId, 'fight_count');
const rewards = result.rewards.map(r => r.type === 'coins' ? `🪙 +${r.amount}` : `🎁 ${r.itemKey} x${r.qty}`).join(' · ') || '—';
const mobs = result.mobs.length ? result.mobs.join(', ') : '—';
const toolInfo = result.tool?.key ? `🗡️ ${result.tool.key}${result.tool.broken ? ' (rota)' : ` (-${result.tool.durabilityDelta} dur.)`}` : '—';
await message.reply(`⚔️ Arena (nivel ${level})
let response = `⚔️ Arena (nivel ${level})
Recompensas: ${rewards}
Enemigos: ${mobs}
Arma: ${toolInfo}`);
Arma: ${toolInfo}`;
if (newAchievements.length > 0) {
response += `\n\n🏆 ¡Logro desbloqueado!`;
for (const ach of newAchievements) {
response += `\n✨ **${ach.name}** - ${ach.description}`;
}
}
await message.reply(response);
} catch (e: any) {
await message.reply(`❌ No se pudo pelear: ${e?.message ?? e}`);
}