private static void AddHeroes(List <BaseHero> heroes)
        {
            HeroCreator newHero = null;
            string      name    = Console.ReadLine();
            string      type    = Console.ReadLine();

            switch (type)
            {
            case "Druid":
                newHero = new DruidFactory(name);
                break;

            case "Paladin":
                newHero = new PaladinFactory(name);
                break;

            case "Rogue":
                newHero = new RogueFactory(name);
                break;

            case "Warrior":
                newHero = new WarriorFactory(name);
                break;

            default:
                Console.WriteLine("Invalid hero!");
                break;
            }
            if (newHero != null)
            {
                heroes.Add(newHero.CreateHero());
            }
        }
Example #2
0
        public Hero CreateHero(string name, RaceType race, HeroType selectedHeroType)
        {
            HeroFactory heroFactory;

            switch (selectedHeroType)
            {
            case HeroType.DeathKnight:
                heroFactory = new DeathKnightFactory();
                return(heroFactory.CreateHero(name, race));

            case HeroType.Hunter:
                heroFactory = new HunterFactory();
                return(heroFactory.CreateHero(name, race));

            case HeroType.Mage:
                heroFactory = new MageFactory();
                return(heroFactory.CreateHero(name, race));

            case HeroType.Monk:
                heroFactory = new MonkFactory();
                return(heroFactory.CreateHero(name, race));

            case HeroType.Paladin:
                heroFactory = new PaladinFactory();
                return(heroFactory.CreateHero(name, race));

            case HeroType.Priest:
                heroFactory = new PriestFactory();
                return(heroFactory.CreateHero(name, race));

            case HeroType.Rogue:
                heroFactory = new RogueFactory();
                return(heroFactory.CreateHero(name, race));

            case HeroType.Warlock:
                heroFactory = new WarlockFactory();
                return(heroFactory.CreateHero(name, race));

            case HeroType.Warrior:
                heroFactory = new WarriorFactory();
                return(heroFactory.CreateHero(name, race));

            default:
                return(null);
            }
        }
Example #3
0
        private static HeroFactory CreateHero(List <HeroFactory> list, HeroFactory hero, string nameHero, string typeHero)
        {
            switch (typeHero)
            {
            case "Druid":
                hero = new DruidFactory(nameHero);
                break;

            case "Paladin":
                hero = new PaladinFactory(nameHero);
                break;

            case "Rogue":
                hero = new RogueFactory(nameHero);
                break;

            case "Warrior":
                hero = new WarriorFactory(nameHero);
                break;
            }

            list.Add(hero);
            return(hero);
        }
Example #4
0
        public void Run()
        {
            HeroFactory factory = null;

            int             heroCount = 0;
            List <BaseHero> Heroes    = new List <BaseHero>();

            int N = int.Parse(reader.ReadLine());

            while (heroCount < N)
            {
                string heroName = reader.ReadLine();
                string heroType = reader.ReadLine();

                try
                {
                    switch (heroType)
                    {
                    case "Druid":
                        factory = new DruidFactory(heroName);
                        break;

                    case "Paladin":
                        factory = new PaladinFactory(heroName);
                        break;

                    case "Rogue":
                        factory = new RogueFactory(heroName);
                        break;

                    case "Warrior":
                        factory = new WarriorFactory(heroName);
                        break;

                    default:
                        throw new InvalidHeroException();
                    }
                    Heroes.Add(factory.GetBaseHero());
                    heroCount++;
                }
                catch (InvalidHeroException ihe)
                {
                    writer.WriteLine(ihe.Message);
                }
            }

            int bossPower  = int.Parse(reader.ReadLine());
            int totalPower = 0;

            foreach (var hero in Heroes)
            {
                writer.WriteLine(hero.CastAbility());
                totalPower += hero.Power;
            }

            if (totalPower >= bossPower)
            {
                writer.WriteLine("Victory!");
            }
            else
            {
                writer.WriteLine("Defeat...");
            }
        }