예제 #1
0
    /// <summary>
    /// performs an attack and returns total damage, check the slides for how to calculate the damage
    /// IMPORTANT: should also apply the damage to the enemy pokemon
    /// </summary>
    /// <param name="enemy">This is the enemy pokemon that we are attacking</param>
    /// <returns>The amount of damage that was applied so we can print it for the user</returns>
    public int Attack(Pokemon enemy)
    {
        //calculate attack
        int attack = baseAttack * level;

        attack = CalculateElementalEffects(attack, enemy.element);
        int defence = enemy.CalculateDefence();
        int damage  = (attack - defence) / 10;

        if (damage < 0)
        {
            return(0);
        }
        else
        {
            enemy.ApplyDamage(damage);
            return(damage);
        }
    }