private static BaseHero CreateHero(string type, string name) { BaseHero hero = null; switch (type) { case nameof(Druid): hero = new Druid(name); break; case nameof(Paladin): hero = new Paladin(name); break; case nameof(Rogue): hero = new Rogue(name); break; case nameof(Warrior): hero = new Warrior(name); break; default: break; } return(hero); }
public static BaseHero CharacterCreation(string name, string type) { BaseHero current = null; switch (type) { case "Paladin": current = new Paladin(name); break; case "Warrior": current = new Warrior(name); break; case "Druid": current = new Druid(name); break; case "Rogue": current = new Rogue(name); break; default: throw new ArgumentException("Invalid hero!"); } return(current); }
private static BaseHero CreateHero(string type, string name) { BaseHero hero = null; if (type == nameof(Druid)) { hero = new Druid(name); } else if (type == nameof(Paladin)) { hero = new Paladin(name); } else if (type == nameof(Rogue)) { hero = new Rogue(name); } else if (type == nameof(Warrior)) { hero = new Warrior(name); } return(hero); }
public void MakeHero(string name, string heroType) { if (heroType == "Druid") { BaseHero hero = new Druid(name); raGroup.Add(hero); } else if (heroType == "Paladin") { BaseHero hero = new Paladin(name); raGroup.Add(hero); } else if (heroType == "Rogue") { BaseHero hero = new Rogue(name); raGroup.Add(hero); } else if (heroType == "Warrior") { BaseHero hero = new Warrior(name); raGroup.Add(hero); } }
public void Run() { int n = int.Parse(Console.ReadLine()); int counter = 0; List <BaseHero> heroesRaid = new List <BaseHero>(); BaseHero newHeroIsBorn; while (n != counter) { string name = Console.ReadLine(); string type = Console.ReadLine(); if (type == "Druid") { newHeroIsBorn = new Druid(name); heroesRaid.Add(newHeroIsBorn); counter++; } else if (type == "Paladin") { newHeroIsBorn = new Paladin(name); heroesRaid.Add(newHeroIsBorn); counter++; } else if (type == "Rogue") { newHeroIsBorn = new Rogue(name); heroesRaid.Add(newHeroIsBorn); counter++; } else if (type == "Warrior") { newHeroIsBorn = new Warrior(name); heroesRaid.Add(newHeroIsBorn); counter++; } else { Console.WriteLine("Invalid hero!"); } } int bossStreight = int.Parse(Console.ReadLine()); int heroesPower = 0; foreach (var hero in heroesRaid) { Console.WriteLine(hero.CastAbility()); heroesPower += hero.Power; } if (heroesPower >= bossStreight) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
static void Main(string[] args) { List <BaseHero> heroes = new List <BaseHero>(); int n = int.Parse(Console.ReadLine()); while (heroes.Count != n) { string nameOfHero = Console.ReadLine(); string typeOfHero = Console.ReadLine(); BaseHero hero; switch (typeOfHero) { case "Druid": hero = new Druid(nameOfHero); heroes.Add(hero); break; case "Paladin": hero = new Paladin(nameOfHero); heroes.Add(hero); break; case "Rogue": hero = new Rogue(nameOfHero); heroes.Add(hero); break; case "Warrior": hero = new Warrior(nameOfHero); heroes.Add(hero); break; default: Console.WriteLine("Invalid hero!"); break; } } int bossPower = int.Parse(Console.ReadLine()); foreach (var hero in heroes) { Console.WriteLine(hero.CastAbility()); } int sumOfheroesPower = heroes.Sum(x => x.Power); if (bossPower <= sumOfheroesPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
static void Main(string[] args) { List <BaseHero> heroes = new List <BaseHero>(); int num = int.Parse(Console.ReadLine()); while (num != 0) { string name = Console.ReadLine(); string type = Console.ReadLine(); BaseHero hero = null; if (type == nameof(Druid)) { hero = new Druid(name); } else if (type == nameof(Paladin)) { hero = new Paladin(name); } else if (type == nameof(Rogue)) { hero = new Rogue(name); } else if (type == nameof(Warrior)) { hero = new Warrior(name); } if (hero == null) { Console.WriteLine("Invalid hero!"); continue; } heroes.Add(hero); num--; } int bossPower = int.Parse(Console.ReadLine()); int sumHeroesPoer = heroes.Sum(x => x.Power); foreach (var hero in heroes) { Console.WriteLine(hero.CastAbility()); } if (sumHeroesPoer >= bossPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
static void Main(string[] args) { int numberOfOperations = int.Parse(Console.ReadLine()); int sumPoints = 0; List <BaseHero> heroes = new List <BaseHero>(); while (heroes.Count < numberOfOperations) { string name = Console.ReadLine(); string type = Console.ReadLine(); if (type == nameof(Paladin)) { BaseHero paladin = new Paladin(name); heroes.Add(paladin); } else if (type == nameof(Druid)) { BaseHero druid = new Druid(name); heroes.Add(druid); } else if (type == nameof(Warrior)) { BaseHero warrior = new Warrior(name); heroes.Add(warrior); } else if (type == nameof(Rogue)) { BaseHero rogue = new Rogue(name); heroes.Add(rogue); } else { Console.WriteLine("Invalid hero!"); } } int boosHealth = int.Parse(Console.ReadLine()); foreach (var item in heroes) { sumPoints += item.Power; Console.WriteLine(item.CastAbility()); } if (boosHealth > sumPoints) { Console.WriteLine("Defeat..."); } else { Console.WriteLine("Victory!"); } }
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; if (type == nameof(Druid)) { hero = new Druid(name); heroes.Add(hero); } else if (type == nameof(Paladin)) { hero = new Paladin(name); heroes.Add(hero); } else if (type == nameof(Rogue)) { hero = new Rogue(name); heroes.Add(hero); } else if (type == nameof(Warrior)) { hero = new Warrior(name); heroes.Add(hero); } else { Console.WriteLine("Invalid hero!"); continue; } } int bossPoints = int.Parse(Console.ReadLine()); foreach (var hero in heroes) { Console.WriteLine(hero.CastAbility()); bossPoints -= hero.Power; } if (bossPoints <= 0) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
static void Main(string[] args) { List <IHero> heroes = new List <IHero>(); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string name = Console.ReadLine(); string type = Console.ReadLine(); IHero hero = null; if (type == "Druid") { hero = new Druid(name); } else if (type == "Paladin") { hero = new Paladin(name); } else if (type == "Rogue") { hero = new Rogue(name); } else if (type == "Warrior") { hero = new Warrior(name); } else { Console.WriteLine("Invalid hero!"); i--; } if (hero != null) { heroes.Add(hero); } } int points = int.Parse(Console.ReadLine()); bool hasWon = false; foreach (var hero in heroes) { Console.WriteLine(hero.CastAbility()); points -= hero.Power; if (points <= 0) { hasWon = true; } } Console.WriteLine(hasWon == true ? "Victory!" : "Defeat..."); }
public static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List <BaseHero> raidGroup = new List <BaseHero>(); while (raidGroup.Count != n) { string name = Console.ReadLine(); string type = Console.ReadLine(); BaseHero hero = null; if (type == nameof(Druid)) { hero = new Druid(name); } else if (type == nameof(Paladin)) { hero = new Paladin(name); } else if (type == nameof(Rogue)) { hero = new Rogue(name); } else if (type == nameof(Warrior)) { hero = new Warrior(name); } else { Console.WriteLine("Invalid hero!"); continue; } raidGroup.Add(hero); } int bossPower = int.Parse(Console.ReadLine()); foreach (var hero in raidGroup) { Console.WriteLine(hero.CastAbility()); } int allHeroesPower = raidGroup.Sum(h => h.Power); if (allHeroesPower >= bossPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
public static void Main(string[] args) { var allHero = new List <BaseHero>(); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { var name = Console.ReadLine(); var type = Console.ReadLine(); if (type == "Druid") { var druid = new Druid(name); allHero.Add(druid); } else if (type == "Paladin") { var paladin = new Paladin(name); allHero.Add(paladin); } else if (type == "Rogue") { var rogue = new Rogue(name); allHero.Add(rogue); } else if (type == "Warrior") { var warrior = new Warrior(name); allHero.Add(warrior); } else { i--; Console.WriteLine("Invalid hero!"); } } int bossPower = int.Parse(Console.ReadLine()); int heroPower = 0; foreach (var hero in allHero) { Console.WriteLine(hero.CastAbility()); heroPower += hero.Power; } if (heroPower >= bossPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
static void Main() { var listOfHeroes = new List <BaseHero>(); BaseHero hero; int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string heroName = Console.ReadLine(); string heroType = Console.ReadLine(); switch (heroType) { case "Druid": hero = new Druid(heroName); break; case "Paladin": hero = new Paladin(heroName); break; case "Rogue": hero = new Rogue(heroName); break; case "Warrior": hero = new Warrior(heroName); break; default: Console.WriteLine("Invalid hero!"); continue; } listOfHeroes.Add(hero); } foreach (var item in listOfHeroes) { Console.WriteLine(item.CastAbility()); } int bossPower = int.Parse(Console.ReadLine()); bool isWinner = listOfHeroes.Sum(h => h.Power) >= bossPower; Console.WriteLine(isWinner ? "Victory!" : "Defeat..."); }
private static BaseHero CreateHero(string name, string type) { BaseHero hero = null; if (type == "Druid") { hero = new Druid(name); } else if (type == "Paladin") { hero = new Paladin(name); } else if (type == "Rogue") { hero = new Rogue(name); } else if (type == "Warrior") { hero = new Warrior(name); } return(hero); }
public static BaseHero NewHero(string type, string name) { switch (type) { case "Druid": Druid newDruid = new Druid(name); return(newDruid); case "Paladin": Paladin newPaladin = new Paladin(name); return(newPaladin); case "Rogue": Rogue newRogue = new Rogue(name); return(newRogue); case "Warrior": Warrior newWarrior = new Warrior(name); return(newWarrior); default: throw new Exception("Invalid hero!"); } }
static void Main(string[] args) { List <BaseHero> raid = new List <BaseHero>(); int heroesNum = int.Parse(Console.ReadLine()); for (int i = 0; i < heroesNum; i++) { string playerName = Console.ReadLine(); string heroType = Console.ReadLine(); if (heroType == "Druid" || heroType == "Paladin" || heroType == "Warrior" || heroType == "Rogue") { switch (heroType) { case "Druid": Druid druid = new Druid(playerName, heroType); raid.Add(druid); break; case "Paladin": Paladin paladin = new Paladin(playerName, heroType); raid.Add(paladin); break; case "Warrior": Warrior warrior = new Warrior(playerName, heroType); raid.Add(warrior); break; case "Rogue": Rogue rogue = new Rogue(playerName, heroType); raid.Add(rogue); break; } } else { Console.WriteLine("Invalid hero!"); } } int bossPower = int.Parse(Console.ReadLine()); int tottalHeroPower = 0; foreach (var hero in raid) { hero.CastAbility(); tottalHeroPower += hero.Power; } if (tottalHeroPower >= bossPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
static void Main(string[] args) { int dmg = 0; List <BaseHero> counter = new List <BaseHero>(); int n = int.Parse(Console.ReadLine()); while (true) { BaseHero currentHero = null; string name = Console.ReadLine(); string typeOfHero = Console.ReadLine(); if (typeOfHero == nameof(Druid)) { currentHero = new Druid(name); } else if (typeOfHero == nameof(Paladin)) { currentHero = new Paladin(name); } else if (typeOfHero == nameof(Rogue)) { currentHero = new Rogue(name); } else if (typeOfHero == nameof(Warrior)) { currentHero = new Warrior(name); } else { Console.WriteLine("Invalid hero!"); continue; } Console.WriteLine(currentHero.CastAbility()); dmg += currentHero.Power; if (currentHero != null) { counter.Add(currentHero); if (counter.Count == n) { break; } } } int bossHealth = int.Parse(Console.ReadLine()); if (dmg >= bossHealth) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
public static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List <BaseHero> heroes = new List <BaseHero>(); string heroName = Console.ReadLine(); string heroType = Console.ReadLine(); BaseHero hero = null; while (true) { if (!isHeroTypeValid(heroType)) { Console.WriteLine("Invalid hero!"); } else { if (heroType == "Druid") { hero = new Druid(heroName); } else if (heroType == "Paladin") { hero = new Paladin(heroName); } else if (heroType == "Rogue") { hero = new Rogue(heroName); } else if (heroType == "Warrior") { hero = new Warrior(heroName); } heroes.Add(hero); } if (heroes.Count == n) { break; } heroName = Console.ReadLine(); heroType = Console.ReadLine(); } int bossPower = int.Parse(Console.ReadLine()); int heroesPower = 0; foreach (BaseHero currentHero in heroes) { //must cast all heroes? Console.WriteLine(currentHero.CastAbility()); heroesPower += currentHero.Power; } if (heroesPower >= bossPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
static void Main(string[] args) { List <BaseHero> raiders = new List <BaseHero>(); BaseHero hero; int n = int.Parse(Console.ReadLine()); int counter = 0; while (counter != n) { string name = Console.ReadLine(); string type = Console.ReadLine(); try { if (type == "Druid") { hero = new Druid(name); } else if (type == "Paladin") { hero = new Paladin(name); } else if (type == "Rogue") { hero = new Rogue(name); } else if (type == "Warrior") { hero = new Warrior(name); } else { throw new ArgumentException("Invalid hero!"); } counter++; raiders.Add(hero); } catch (Exception ex) { Console.WriteLine(ex.Message); } } long bossPower = long.Parse(Console.ReadLine()); foreach (var r in raiders) { Console.WriteLine(r.CastAbility()); } long allPower = raiders.Select(x => x.Power).Sum(); if (allPower >= bossPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }
static void Main() { int amountOfHeroes = int.Parse(Console.ReadLine()); List <BaseHero> baseHeroes = new List <BaseHero>(); int totalPower = 0; for (int i = 0; i < amountOfHeroes; i++) { string name = Console.ReadLine(); string heroType = Console.ReadLine(); BaseHero hero = null; if (heroType == "Druid") { hero = new Druid(name); } else if (heroType == "Paladin") { hero = new Paladin(name); } else if (heroType == "Rogue") { hero = new Rogue(name); } else if (heroType == "Warrior") { hero = new Warrior(name); } else { Console.WriteLine("Invalid hero!"); } if (hero != null) { baseHeroes.Add(hero); totalPower += hero.Power; } else { i--; } } int bossPower = int.Parse(Console.ReadLine()); if (baseHeroes.Count == 0) { Console.WriteLine("Defeat..."); return; } foreach (BaseHero hero in baseHeroes) { Console.WriteLine(hero.CastAbility()); } if (bossPower <= totalPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } }