예제 #1
0
        static void Main(string[] args)
        {
            Random         rng      = new Random();
            List <Warrior> warriors = new List <Warrior>();

            var sword  = new Sword(rng.Next(11, 19));
            var spear  = new Spear(rng.Next(11, 19));
            var hammer = new Hammer(rng.Next(11, 19));

            var weaponType = new WeaponType(sword, spear, hammer);

            for (var i = 0; i < 5; i++)
            {
                var     hp          = rng.Next(90, 100);
                string  warriorName = "Sime " + i.ToString();
                Warrior warrior     = new Warrior(warriorName, hp, weaponType);
                warriors.Add(warrior);
            }

            Console.WriteLine("Starting battle...");
            var warIdx   = rng.Next(warriors.Count);
            var warrior1 = warriors[warIdx];

            var warIdx2  = rng.Next(warriors.Count);
            var warrior2 = warriors[warIdx2];

            var winner = StartBattle(warrior1, warrior2);

            Console.WriteLine($"The winner is {winner.WarriorName} with {winner.WarriorHealth} hp left!");
        }
예제 #2
0
 public WeaponType(Sword sword, Spear spear, Hammer hammer)
 {
     Sword  = sword;
     Spear  = spear;
     Hammer = hammer;
 }