feat: Add floating combat text and damage flash feedback
This commit is contained in:
28
src/main.js
28
src/main.js
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user