Пример #1
0
        /// <summary>
        /// Damage is dealt from one Fighter to another.
        /// </summary>
        /// <param name="attacker">Attacking Fighter</param>
        /// <param name="receiver">Defending Fighter</param>
        private static void attack(IEngageable attacker, IEngageable receiver)
        {
            Console.WriteLine();
            Text.color(attacker.ToString(), Text.allianceColor(attacker));
            if (!(attacker is Cleric))
            {
                Console.Write(" attacks ");
            }
            else
            {
                Console.Write(" heals ");
            }

            Text.color(
                    ((receiver.getName().Equals(attacker.getName())) ? "themselves" : receiver.getName()) + "\n", Text.allianceColor(receiver));

            int newHP = (!(attacker is Cleric)) ?
                (receiver.getHP() - damage(attacker.getAttack(), receiver.getDefense(), attacker.getCritChance())) :
                (receiver.getHP() + damage(attacker.getAttack(), 0, 0));

            if (newHP <= 0)
            {
                newHP = 0;
            }
            if (newHP >= receiver.getMaxHP())
            {
                newHP = receiver.getMaxHP();
            }

            Text.color(receiver.ToString(), Text.allianceColor(receiver));
            Console.Write("'s health goes from ");
            Text.color(receiver.getHP().ToString(), Text.healthColor(receiver));
            Console.Write(" to ");
            receiver.setHP(newHP);
            Text.color(newHP.ToString(), Text.healthColor(receiver));

            if (attacker.getParty().isUser())
            {
                Console.WriteLine();
                Console.Write(attacker + " earned ");
                Text.color(attacker.earnEXP(receiver).ToString(), ConsoleColor.Yellow);
            }

            Text.userRead();
        }
Пример #2
0
 public static ConsoleColor healthColor(IEngageable engageable)
 {
     if (engageable.getHP() == 0)
     {
         return ConsoleColor.DarkRed;
     }
     else if (engageable.getHP() < engageable.getMaxHP() * (1.0 / 3.0))
     {
         return ConsoleColor.Red;
     }
     else if (engageable.getHP() < engageable.getMaxHP() * (2.0 / 3.0))
     {
         return ConsoleColor.Yellow;
     }
     else
     {
         return ConsoleColor.Green;
     }
 }