Пример #1
0
        static void Main(string[] args)
        {
            int             number     = int.Parse(Console.ReadLine());
            List <BaseHero> listOFHero = new List <BaseHero>();
            int             totalSum   = 0;

            for (int i = 1; i <= number; i++)
            {
                string name       = Console.ReadLine();
                string typeOfHero = Console.ReadLine();
                try
                {
                    BaseHero hero = CreateNewHero(name, typeOfHero);
                    listOFHero.Add(hero);
                    totalSum += hero.Power;
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message);
                    i--;
                }
            }
            int powerOfBoss = int.Parse(Console.ReadLine());

            foreach (var hero in listOFHero)
            {
                Console.WriteLine(hero.CastAbility());
            }
            Console.WriteLine(Result(powerOfBoss, totalSum));
        }
Пример #2
0
        public static void Main(string[] args)
        {
            var heroFactory = new HeroCreatorFactory();

            int             count  = int.Parse(Console.ReadLine());
            List <BaseHero> heroes = new List <BaseHero>();

            while (count > 0)
            {
                try
                {
                    string   name = Console.ReadLine();
                    string   type = Console.ReadLine();
                    BaseHero hero = heroFactory.CreateBaseHero(name, type);
                    heroes.Add(hero);
                    count--;
                }
                catch (ArgumentException exception)
                {
                    Console.WriteLine(exception.Message);
                }
            }

            long bossPower = long.Parse(Console.ReadLine());

            foreach (var hero in heroes)
            {
                Console.WriteLine(hero.CastAbility());
            }

            long heroesPower = heroes.Sum(h => h.Power);

            if (heroesPower >= bossPower)
            {
                Console.WriteLine("Victory!");
            }
            else
            {
                Console.WriteLine("Defeat...");
            }
        }
        public static void Main()
        {
            int players = int.Parse(Console.ReadLine());
            Dictionary <string, BaseHero> heroes = new Dictionary <string, BaseHero>();

            while (heroes.Count < players)
            {
                string   name = Console.ReadLine();
                string   type = Console.ReadLine();
                BaseHero hero = CreateHero(type, name);
                if (hero == null)
                {
                    Console.WriteLine("Invalid hero!");
                }
                else
                {
                    heroes.Add(name, hero);
                }
            }
            int bossPoints = int.Parse(Console.ReadLine());
            int raidPoints = 0;

            if (heroes.Any())
            {
                foreach (var hero in heroes.Values)
                {
                    string ability = hero.CastAbility();
                    Console.WriteLine(ability);
                    raidPoints += hero.Power;
                }
            }
            if (raidPoints >= bossPoints)
            {
                Console.WriteLine("Victory!");
            }
            else
            {
                Console.WriteLine("Defeat...");
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            List <BaseHero> heroes = new List <BaseHero>();

            int n = int.Parse(Console.ReadLine());

            while (heroes.Count < n)
            {
                string name = Console.ReadLine();
                string type = Console.ReadLine();

                BaseHero hero = CreateHero(type, name);

                if (hero == null)
                {
                    Console.WriteLine("Invalid hero!");
                    continue;
                }

                heroes.Add(hero);
            }

            int bossHealthPoints = int.Parse(Console.ReadLine());

            foreach (var hero in heroes)
            {
                Console.WriteLine(hero.CastAbility());

                bossHealthPoints -= hero.Power;
            }

            if (bossHealthPoints <= 0)
            {
                Console.WriteLine("Victory!");
            }
            else
            {
                Console.WriteLine("Defeat...");
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            int             lines   = int.Parse(Console.ReadLine());
            HeroCreator     creator = null;
            List <BaseHero> group   = new List <BaseHero>();
            BaseHero        hero    = null;


            for (int i = 0; i < lines; i++)
            {
                string name = Console.ReadLine();
                string type = Console.ReadLine();

                switch (type.ToLower())
                {
                case "druid":
                    creator = new DruidCreator(name);
                    hero    = creator.CreateHero();
                    group.Add(hero);
                    Console.WriteLine(hero.CastAbility());
                    break;

                case "paladin":
                    creator = new PaladinCreator(name);
                    hero    = creator.CreateHero();
                    group.Add(hero);
                    Console.WriteLine(hero.CastAbility());
                    break;

                case "rogue":
                    creator = new RogueCreator(name);
                    hero    = creator.CreateHero();
                    group.Add(hero);
                    Console.WriteLine(hero.CastAbility());
                    break;

                case "warrior":
                    creator = new WarriorCreator(name);
                    hero    = creator.CreateHero();
                    group.Add(hero);
                    Console.WriteLine(hero.CastAbility());
                    break;

                default:
                    Console.WriteLine("Invalid hero!");
                    lines++;
                    break;
                }
            }

            int bossPower  = int.Parse(Console.ReadLine());
            int groupPower = 0;

            if (group.Count > 0)
            {
                foreach (var unit in group)
                {
                    groupPower += unit.Power;
                }
            }

            if (bossPower <= groupPower)
            {
                Console.WriteLine("Victory!");
            }

            else
            {
                Console.WriteLine("Defeat...");
            }
        }