Пример #1
0
 public void applyAttack(MiddleEarthCitizen enemy)
 {
     enemy.setPower(enemy.getPower() - getPower());
 }
Пример #2
0
        public bool firstRoundAttack(Army oppo)
        { //Loop through alive units
            int k = -1, e = -1;

            while (getFirstArmyAlives() > 0 && oppo.getFirstArmyAlives() > 0)
            {
                int kw = getNextFAAlive(k);
                if (kw == -1)
                {
                    return(false); //defender won
                }

                int ew = oppo.getNextFAAlive(e);
                if (ew == -1)
                {
                    return(true); //attacker won
                }

                MiddleEarthCitizen warrior = (MiddleEarthCitizen)getFirstArmy()[kw];
                MiddleEarthCitizen enemy   = (MiddleEarthCitizen)oppo.getFirstArmy()[ew];

#if (DEBUG)
                Console.WriteLine(warrior.getName() + " attacked " + enemy.getName() + " with " + Convert.ToString(warrior.getPower()) + " to " + Convert.ToString((enemy.getPower() - warrior.getPower())) + "hp");
#endif
                warrior.applyAttack(enemy);
                if (!enemy.isDead())
                {
#if (DEBUG)
                    Console.WriteLine(enemy.getName() + " attacked " + warrior.getName() + " with " + Convert.ToString(enemy.getPower()) + " to " + Convert.ToString((warrior.getPower() - enemy.getPower())) + "hp");
#endif
                    enemy.applyAttack(warrior);
                }
                else
                {
                    Console.WriteLine(">>>>>>>>>> [" + enemy.getName() + " is not survived!] <<<<<<<<<<");
                }

                k = kw;
                e = ew;
            }

            return(true); //will not even be called
        }