Пример #1
0
    private void attack(BattleUnitStack attacker, BattleUnitStack defender)
    {
        double defence = defender.curDefence;
        double Alive   = (double)attacker.curHitPoints / attacker.minion.HitPoints;

        Alive = Math.Ceiling(Alive);
        int minDamage;
        int maxDamage;
        int damage;

        if (defender.isDefend == 1)
        {
            defence = Math.Ceiling(defender.curDefence * 1.3);
        }
        if (attacker.curAttack >= defence)
        {
            minDamage = Convert.ToInt32(Alive * attacker.minion.MinDamage * (1 + 0.05 * (attacker.curAttack - defence)));
            maxDamage = Convert.ToInt32(Alive * attacker.minion.MaxDamage * (1 + 0.05 * (attacker.curAttack - defence)));
            damage    = random.Next(minDamage, maxDamage);
        }
        else
        {
            minDamage = Convert.ToInt32(Alive * attacker.minion.MinDamage * (1 + 0.05 / (defence - attacker.curAttack)));
            maxDamage = Convert.ToInt32(Alive * attacker.minion.MaxDamage * (1 + 0.05 / (defence - attacker.curAttack)));
            damage    = random.Next(minDamage, maxDamage);
        }
        defender.changeHealth(-damage);
        if ((defender.curHitPoints != 0) && (defender.counter != 0))     //counter
        {
            Log log = Log.getInstance();
            log.sb.AppendLine($"{defender.ID}:{defender.minion.Type} counter attack");
            Alive = (double)defender.curHitPoints / defender.minion.HitPoints;
            Alive = Math.Ceiling(Alive);
            if (defender.curAttack >= attacker.curDefence)
            {
                minDamage = Convert.ToInt32(Alive * defender.minion.MinDamage * (1 + 0.05 * (defender.curAttack - defence)));
                maxDamage = Convert.ToInt32(Alive * defender.minion.MaxDamage * (1 + 0.05 * (defender.curAttack - defence)));
                damage    = random.Next(minDamage, maxDamage);
            }
            else
            {
                minDamage = Convert.ToInt32(Alive * defender.minion.MinDamage * (1 + 0.05 / (defence - defender.curAttack)));
                maxDamage = Convert.ToInt32(Alive * defender.minion.MaxDamage * (1 + 0.05 / (defence - defender.curAttack)));
                damage    = random.Next(minDamage, maxDamage);
            }
            attacker.changeHealth(-damage);
            defender.setCounter(0);
        }
    }
Пример #2
0
 public override bool Spell(BattleUnitStack me, BattleUnitStack target)
 {
     if ((me.Side == target.Side) && (me.ID != target.ID))
     {
         if (target.minion.Tribe == "undead")
         {
             double Alive   = (double)me.curHitPoints / me.minion.HitPoints;
             int    casters = (int)Math.Ceiling(Alive);
             target.changeHealth(100 * casters);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }