feat: Sistema de combate completo con tarjetas de personajes y animaciones
- Tarjetas de héroes y monstruos con tokens circulares - Sistema de selección: héroe + monstruo para atacar - Botón de ATACAR en tarjeta de monstruo - Animación de muerte: fade-out + hundimiento (1.5s) - Visualización de estadísticas completas (WS, BS, S, T, W, I, A, Mov) - Placeholder cuando no hay héroe seleccionado - Tokens de héroes y monstruos en formato circular - Deselección correcta de monstruos - Fix: paso de gameEngine a CombatMechanics para callbacks de muerte
This commit is contained in:
@@ -20,7 +20,7 @@ export class CombatMechanics {
|
||||
* @param {Object} defender
|
||||
* @returns {Object} Result log
|
||||
*/
|
||||
static resolveMeleeAttack(attacker, defender) {
|
||||
static resolveMeleeAttack(attacker, defender, gameEngine = null) {
|
||||
const log = {
|
||||
attackerId: attacker.id,
|
||||
defenderId: defender.id,
|
||||
@@ -88,7 +88,7 @@ export class CombatMechanics {
|
||||
}
|
||||
|
||||
// 6. Apply Damage to Defender State
|
||||
this.applyDamage(defender, wounds);
|
||||
this.applyDamage(defender, wounds, gameEngine);
|
||||
|
||||
if (defender.isDead) {
|
||||
log.defenderDied = true;
|
||||
@@ -110,7 +110,7 @@ export class CombatMechanics {
|
||||
return 6; // Fallback
|
||||
}
|
||||
|
||||
static applyDamage(entity, amount) {
|
||||
static applyDamage(entity, amount, gameEngine = null) {
|
||||
if (!entity.stats) entity.stats = {};
|
||||
|
||||
// If entity doesn't have current wounds tracked, init it from max
|
||||
@@ -135,6 +135,10 @@ export class CombatMechanics {
|
||||
if (entity.currentWounds <= 0) {
|
||||
entity.currentWounds = 0;
|
||||
entity.isDead = true;
|
||||
// Trigger death callback if available
|
||||
if (gameEngine && gameEngine.onEntityDeath) {
|
||||
gameEngine.onEntityDeath(entity.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user