Exemplo n.º 1
0
        public static string GetAttackResult(Warrior warrior1, Warrior warrior2)
        {
            double warrior1AttackAmount = warrior1.Attack();
            double warrior2BlackAmount  = warrior2.Block();

            double damageToWarrior2 = warrior1AttackAmount - warrior2BlackAmount;

            if (damageToWarrior2 > 0)
            {
                warrior2.HP = warrior2.HP - damageToWarrior2;
                Console.ReadLine();
            }
            else
            {
                damageToWarrior2 = 0;
                Console.ReadLine();
            }

            Console.WriteLine("{0} attacks {1} and deals {2} damage", warrior1.Name, warrior2.Name, damageToWarrior2);

            Console.WriteLine("{0} has {1} health left", warrior2.Name, warrior2.HP);

            if (warrior2.HP <= 0)
            {
                Console.WriteLine("{0} has died", warrior2.Name);
                return("Game Over");
            }
            else
            {
                return("Fight again");

                ;
            }
        }
Exemplo n.º 2
0
        public static string GetAttackResult(Warrior warriorA, Warrior warriorB)
        {
            double warAAttkAmt = warriorA.Attack();
            double warBBlkAmt  = warriorB.Block();

            double dmgWarB = warAAttkAmt - warBBlkAmt;

            if (dmgWarB > 0)
            {
                warriorB.Health = warriorB.Health - dmgWarB;
            }
            else
            {
                dmgWarB = 0;
            }

            Console.WriteLine("{0} Attacks {1} and Deals {2} Damage", warriorA.Name, warriorB.Name, dmgWarB);
            Console.WriteLine("{0} Has {1} Healt\n", warriorB.Name, warriorB.Health);
            if (warriorB.Health <= 0)
            {
                Console.WriteLine("{0} has Died and {1} is Victorius\n", warriorB.Name, warriorA.Name);
                return("Game Over");
            }
            else
            {
                return("Fight Again");
            }
        }