/// <summary> /// Resolves one turn of the combat. /// </summary> protected void CombatTurn() { int index; bool flag; // Gets a skill using input manager do { PrintHeroSkills(); flag = int.TryParse(IOManager.AskForInput(), out index); }while (!flag || index < 0 || index >= Hero.Skills.Count); // Gets the damage assigned to the chosen skill Skill skill = SkillService.GetSkillByName(Hero.Skills[index]); int damage = skill.Damage; // Inflicts the damage to the enemy health Enemy.TakeDamage(damage); IOManager.PushOutput($"Enemy took {damage} point(s) of damage!"); // If enemy is still alive counterattacks if (Enemy.IsAlive) { // Chooses a random skill from the set of the enemy index = _random.Next(0, Enemy.Skills.Count); skill = SkillService.GetSkillByName(Enemy.Skills[index]); damage = skill.Damage; // Inflicts the damage to the hero health Hero.TakeDamage(damage); IOManager.PushOutput($"Hero took {damage} point(s) of damage!"); } }
/// <summary> /// Prints the entire Hero skill set. /// </summary> protected void PrintHeroSkills() { for (int i = 0; i < Hero.Skills.Count; i++) { Skill skill = SkillService.GetSkillByName(Hero.Skills[i]); // Skips all null skills if (skill == null) { IOManager.PushOutput($"{i}. UNKNOWN SKILL NAME"); continue; } IOManager.PushOutput($"{i}. {skill.Name}, Damage: {skill.Damage}, {skill.Description}"); } }