public int Fight(HeroPower power, Hero defender, List<Unit> defenders) { if (this.Life <= 0) Combat.Log.Add("Erro de lógica: herói morto tentando atacar"); int unitsAffected = 0; string defenderName = "unidades"; if (defender != null) defenderName = defender.Name; Combat.Log.Add(string.Format("<span class='{3}'>{0}</span> luta contra <span class='{4}'>{1}</span>. Preparando poder <span class='powerName'>{2}</span>", Name, power.PriorityTarget == HeroPower.TargetType.hero? defenderName : "unidades inimigas", power.Name, this.PositionInCombat == Character.CombatPosition.attacker? "attacker" : "defender", this.PositionInCombat == Character.CombatPosition.attacker? "defender" : "attacker")); if (Mana - power.ManaConsumption >= 0){ if (power.PriorityTarget == HeroPower.TargetType.hero) { if (defender != null && defender.Life > 0) { power.Unleash(defender); if (defender != null && defender.Life <=0) Combat.Log.Add(string.Format("<div class='rip'>{0} morreu pelas mãos de {1}</div>", defender.Name, this.Name)); } else if (defenders.Count > 0) unitsAffected = power.Unleash(defenders); } else { if (defenders.Count > 0) unitsAffected = power.Unleash(defenders); else if (defender != null && defender.Life > 0) power.Unleash(defender); } } else { Combat.Log.Add(string.Format("{0} não possui mana suficiente ({1}/{2})", Name, Mana, power.ManaConsumption)); AttackEnemy(defender); } power.Executed = true; if (this.Life <= 0) Combat.Log.Add(string.Format("<div class='rip'>{0} morreu por um erro crítico de combate</div>", this.Name)); return unitsAffected; }
private static bool IsHeroTurn(int turn, HeroPower power) { return (power != null && power.Turn == turn - 1); }