feat: historique combat enrichi — loot affiché + 10 entrées
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 33s
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:
@@ -109,6 +109,7 @@ export interface CombatLog {
|
|||||||
goldEarned: number;
|
goldEarned: number;
|
||||||
levelUp: boolean;
|
levelUp: boolean;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
lootQuantity: number;
|
||||||
monster: { id: string; name: string; minLevel: number; maxLevel: number };
|
monster: { id: string; name: string; minLevel: number; maxLevel: number };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,10 @@ function HistoryEntry({ h }: { h: CombatLog }) {
|
|||||||
{h.winner === 'player' ? '✓' : '✗'} {h.monster.name}
|
{h.winner === 'player' ? '✓' : '✗'} {h.monster.name}
|
||||||
</span>
|
</span>
|
||||||
<span style={{ color: '#6b7a99' }}>
|
<span style={{ color: '#6b7a99' }}>
|
||||||
{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`
|
||||||
|
}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -333,7 +336,7 @@ export function CombatPage() {
|
|||||||
<Clock size={11} /> Historique récent
|
<Clock size={11} /> Historique récent
|
||||||
</p>
|
</p>
|
||||||
<div className="card" style={{ padding: '0.75rem' }}>
|
<div className="card" style={{ padding: '0.75rem' }}>
|
||||||
{history.slice(0, 5).map(h => <HistoryEntry key={h.id} h={h} />)}
|
{history.slice(0, 10).map(h => <HistoryEntry key={h.id} h={h} />)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -49,6 +49,12 @@ export class CombatLog {
|
|||||||
@Column({ name: 'level_up', default: false })
|
@Column({ name: 'level_up', default: false })
|
||||||
levelUp: boolean;
|
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' })
|
@CreateDateColumn({ name: 'created_at' })
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,6 +252,8 @@ export class CombatService {
|
|||||||
xpEarned: result.xpEarned,
|
xpEarned: result.xpEarned,
|
||||||
goldEarned: result.goldEarned,
|
goldEarned: result.goldEarned,
|
||||||
levelUp: levelUpData.levelsGained > 0,
|
levelUp: levelUpData.levelsGained > 0,
|
||||||
|
lootMaterialId: lootedMaterialId,
|
||||||
|
lootQuantity: lootMaterial?.quantity ?? 0,
|
||||||
});
|
});
|
||||||
await manager.save(combatLog);
|
await manager.save(combatLog);
|
||||||
|
|
||||||
@@ -386,6 +388,9 @@ export class CombatService {
|
|||||||
|
|
||||||
let newEnduranceSaved = enduranceCurrent - COMBAT_ENDURANCE_COST;
|
let newEnduranceSaved = enduranceCurrent - COMBAT_ENDURANCE_COST;
|
||||||
|
|
||||||
|
let combatLootMatId: string | null = null;
|
||||||
|
let combatLootQty = 0;
|
||||||
|
|
||||||
if (result.winner === 'player') {
|
if (result.winner === 'player') {
|
||||||
const levelUp = applyXpGain(character.level, character.xp, result.xpEarned);
|
const levelUp = applyXpGain(character.level, character.xp, result.xpEarned);
|
||||||
character.xp = levelUp.newXp;
|
character.xp = levelUp.newXp;
|
||||||
@@ -407,6 +412,8 @@ export class CombatService {
|
|||||||
await addMaterialInTx(manager, character.id, monster.dropMaterialId, dropQty);
|
await addMaterialInTx(manager, character.id, monster.dropMaterialId, dropQty);
|
||||||
totals.loot.push({ name: 'matériau', quantity: dropQty });
|
totals.loot.push({ name: 'matériau', quantity: dropQty });
|
||||||
lootedMaterialIds.push(monster.dropMaterialId);
|
lootedMaterialIds.push(monster.dropMaterialId);
|
||||||
|
combatLootMatId = monster.dropMaterialId;
|
||||||
|
combatLootQty = dropQty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -427,6 +434,7 @@ export class CombatService {
|
|||||||
winner: result.winner, totalRounds: result.totalRounds,
|
winner: result.winner, totalRounds: result.totalRounds,
|
||||||
roundsData: result.rounds, xpEarned: result.xpEarned,
|
roundsData: result.rounds, xpEarned: result.xpEarned,
|
||||||
goldEarned: result.goldEarned, levelUp: false,
|
goldEarned: result.goldEarned, levelUp: false,
|
||||||
|
lootMaterialId: combatLootMatId, lootQuantity: combatLootQty,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (result.winner !== 'player') break; // Arrêt sur défaite
|
if (result.winner !== 'player') break; // Arrêt sur défaite
|
||||||
@@ -491,6 +499,7 @@ export class CombatService {
|
|||||||
xpEarned: true,
|
xpEarned: true,
|
||||||
goldEarned: true,
|
goldEarned: true,
|
||||||
levelUp: true,
|
levelUp: true,
|
||||||
|
lootQuantity: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
monster: { id: true, name: true, minLevel: true, maxLevel: true } as any,
|
monster: { id: true, name: true, minLevel: true, maxLevel: true } as any,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user