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,
},