From 4fc8be9ea0e3c2c90540315f0e8627547afe501e Mon Sep 17 00:00:00 2001 From: Tetardtek Date: Tue, 24 Mar 2026 21:08:49 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20historique=20combat=20enrichi=20?= =?UTF-8?q?=E2=80=94=20loot=20affich=C3=A9=20+=2010=20entr=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajout loot_material_id + loot_quantity sur combat_logs - Historique passe de 5 à 10 entrées - Affichage loot (🎁×N) dans l'historique récent - Fix scope variables multi-combat loot tracking --- frontend/src/api/types.ts | 1 + frontend/src/pages/CombatPage.tsx | 7 +++++-- src/combat/combat-log.entity.ts | 6 ++++++ src/combat/combat.service.ts | 9 +++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts index 8dbc543..5b39fdd 100644 --- a/frontend/src/api/types.ts +++ b/frontend/src/api/types.ts @@ -109,6 +109,7 @@ export interface CombatLog { goldEarned: number; levelUp: boolean; createdAt: string; + lootQuantity: number; monster: { id: string; name: string; minLevel: number; maxLevel: number }; } diff --git a/frontend/src/pages/CombatPage.tsx b/frontend/src/pages/CombatPage.tsx index eec8af3..6ed54d0 100644 --- a/frontend/src/pages/CombatPage.tsx +++ b/frontend/src/pages/CombatPage.tsx @@ -131,7 +131,10 @@ function HistoryEntry({ h }: { h: CombatLog }) { {h.winner === 'player' ? '✓' : '✗'} {h.monster.name} - {h.winner === 'player' ? `+${h.xpEarned}xp +${h.goldEarned}or` : `${h.totalRounds} tours`} + {h.winner === 'player' + ? `+${h.xpEarned}xp +${h.goldEarned}or${h.lootQuantity > 0 ? ` 🎁×${h.lootQuantity}` : ''}` + : `${h.totalRounds} tours` + } ); @@ -333,7 +336,7 @@ export function CombatPage() { Historique récent

- {history.slice(0, 5).map(h => )} + {history.slice(0, 10).map(h => )}
)} diff --git a/src/combat/combat-log.entity.ts b/src/combat/combat-log.entity.ts index 921666d..4b1c915 100644 --- a/src/combat/combat-log.entity.ts +++ b/src/combat/combat-log.entity.ts @@ -49,6 +49,12 @@ export class CombatLog { @Column({ name: 'level_up', default: false }) levelUp: boolean; + @Column({ name: 'loot_material_id', type: 'varchar', nullable: true }) + lootMaterialId: string | null; + + @Column({ name: 'loot_quantity', default: 0 }) + lootQuantity: number; + @CreateDateColumn({ name: 'created_at' }) createdAt: Date; } diff --git a/src/combat/combat.service.ts b/src/combat/combat.service.ts index e62a585..1a5d809 100644 --- a/src/combat/combat.service.ts +++ b/src/combat/combat.service.ts @@ -252,6 +252,8 @@ export class CombatService { xpEarned: result.xpEarned, goldEarned: result.goldEarned, levelUp: levelUpData.levelsGained > 0, + lootMaterialId: lootedMaterialId, + lootQuantity: lootMaterial?.quantity ?? 0, }); await manager.save(combatLog); @@ -386,6 +388,9 @@ export class CombatService { let newEnduranceSaved = enduranceCurrent - COMBAT_ENDURANCE_COST; + let combatLootMatId: string | null = null; + let combatLootQty = 0; + if (result.winner === 'player') { const levelUp = applyXpGain(character.level, character.xp, result.xpEarned); character.xp = levelUp.newXp; @@ -407,6 +412,8 @@ export class CombatService { await addMaterialInTx(manager, character.id, monster.dropMaterialId, dropQty); totals.loot.push({ name: 'matériau', quantity: dropQty }); lootedMaterialIds.push(monster.dropMaterialId); + combatLootMatId = monster.dropMaterialId; + combatLootQty = dropQty; } } } else { @@ -427,6 +434,7 @@ export class CombatService { winner: result.winner, totalRounds: result.totalRounds, roundsData: result.rounds, xpEarned: result.xpEarned, goldEarned: result.goldEarned, levelUp: false, + lootMaterialId: combatLootMatId, lootQuantity: combatLootQty, })); if (result.winner !== 'player') break; // Arrêt sur défaite @@ -491,6 +499,7 @@ export class CombatService { xpEarned: true, goldEarned: true, levelUp: true, + lootQuantity: true, createdAt: true, monster: { id: true, name: true, minLevel: true, maxLevel: true } as any, },