feat: Add floating combat text and damage flash feedback

This commit is contained in:
2026-01-07 20:16:55 +01:00
parent 5c5cc13903
commit df3f892eb2
2 changed files with 101 additions and 22 deletions

View File

@@ -103,6 +103,34 @@ game.turnManager.on('phase_changed', (phase) => {
game.onCombatResult = (log) => {
ui.showCombatLog(log);
// 1. Show Attack Roll on Attacker
// Find Attacker pos
const attacker = game.heroes.find(h => h.id === log.attackerId) || game.monsters.find(m => m.id === log.attackerId);
if (attacker) {
const rollColor = log.hitSuccess ? '#00ff00' : '#888888'; // Green vs Gray
renderer.showFloatingText(attacker.x, attacker.y, `🎲 ${log.hitRoll}`, rollColor);
}
// 2. Show Damage on Defender
const defender = game.heroes.find(h => h.id === log.defenderId) || game.monsters.find(m => m.id === log.defenderId);
if (defender) {
setTimeout(() => { // Slight delay for cause-effect
if (log.hitSuccess) {
if (log.woundsCaused > 0) {
// HIT and WOUND
renderer.triggerDamageEffect(log.defenderId);
renderer.showFloatingText(defender.x, defender.y, `💥 -${log.woundsCaused}`, '#ff0000');
} else {
// BLOCKED (Hit but Toughness saved)
renderer.showFloatingText(defender.x, defender.y, `🛡️ Block`, '#ffff00');
}
} else {
// MISS
renderer.showFloatingText(defender.x, defender.y, `💨 Miss`, '#aaaaaa');
}
}, 500);
}
};
game.onEntityMove = (entity, path) => {