feat: historique combat enrichi — loot affiché + 10 entrées
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 33s

- 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
This commit is contained in:
2026-03-24 21:08:49 +01:00
parent 74938dd35f
commit 4fc8be9ea0
4 changed files with 21 additions and 2 deletions

View File

@@ -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;
}

View File

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