using System;

namespace HelloWorld
{
  class Hero
  {
    // Mainīgie (lauki)
    public int hp;
    public int mana;
    public int defense; //procentage
    public int manaRecovery; //per turn

    // Metode (funkcija), ko klase prot darīt
    public void Create(int hp_input, int mana_input, int defense_input, int manaRecovery_input)
    {
      hp = hp_input;
      mana = mana_input;
      defense = defense_input;
      manaRecovery = manaRecovery_input;
    }
  }

  class Spell
  {
    public string Name;
    public int Damage;
    public int ManaCost;

    // Konstruktors, lai vieglāk izveidot burvestību
    public Spell(string name, int damage, int manaCost)
    {
      Name = name;
      Damage = damage;
      ManaCost = manaCost;
    }
  }

  class Arena
  {
    Hero hero1;
    Hero hero2;

    Spell[] spellBook = new Spell[3];

    void battleMath()
    {
      Console.WriteLine("Player 1 ievada spell");
      string hero1Move = Console.ReadLine();
      Console.WriteLine("Player 2 ievada spell");
      string hero2Move = Console.ReadLine();

      foreach (Spell s in spellBook)
      {
        if (s.Name.ToLower() == hero1Move.ToLower())
        {
            if (hero1Move == hero2Move)
              {
                Console.WriteLine($"Abi izmantoji {s.Name} un nodarīji {s.Damage/2} bojājumus!");
                hero2.hp -= s.Damage/2;
                hero1.hp -= s.Damage/2;
                hero1.mana -= s.ManaCost;
                hero2.mana -= s.ManaCost;
              }
              else if(hero1Move=="fireball" && hero2Move == "ice spike")
              {
                Console.WriteLine($"Tu izmantoji {s.Name} un nodarīji {s.Damage} bojājumus!");
                hero2.hp -= s.Damage;
                hero1.mana -= s.ManaCost;
                hero2.mana -= s.ManaCost;
              }
              else if(hero1Move=="ice spike" && hero2Move == "fireball")
              {
                Console.WriteLine($"Tu izmantoji {s.Name} un nodarīji {s.Damage} bojājumus!");
                hero1.hp -= s.Damage;
                hero1.mana -= s.ManaCost;
                hero2.mana -= s.ManaCost;
              }
              else if(hero1Move=="ice spike" && hero2Move == "water jet")
              {
                Console.WriteLine($"Tu izmantoji {s.Name} un nodarīji {s.Damage} bojājumus!");
                hero2.hp -= s.Damage;
                hero1.mana -= s.ManaCost;
                hero2.mana -= s.ManaCost;
              }
              else if(hero1Move=="water jet" && hero2Move == "ice spike")
              {
                Console.WriteLine($"Tu izmantoji {s.Name} un nodarīji {s.Damage} bojājumus!");
                hero1.hp -= s.Damage;
                hero1.mana -= s.ManaCost;
                hero2.mana -= s.ManaCost;
              }
              else if(hero1Move=="fireball" && hero2Move == "water jet")
              {
                Console.WriteLine($"Tu izmantoji {s.Name} un nodarīji {s.Damage} bojājumus!");
                hero1.hp -= s.Damage;
                hero1.mana -= s.ManaCost;
                hero2.mana -= s.ManaCost;
              }
              else if(hero1Move=="water jet" && hero2Move == "fireball")
              {
                Console.WriteLine($"Tu izmantoji {s.Name} un nodarīji {s.Damage} bojājumus!");
                hero2.hp -= s.Damage;
                hero1.mana -= s.ManaCost;
                hero2.mana -= s.ManaCost;
              }
              System.Threading.Thread.Sleep(5000);
            }
        }
    }

    public void battle (Hero hero1_input, Hero hero2_input)
    {
      hero1 = hero1_input;
      hero2 = hero2_input;

      spellBook[0] = new Spell("fireball", 15, 13);
      spellBook[1] = new Spell("water jet", 8, 8);
      spellBook[2] = new Spell("ice spike", 12, 10);

      int turn = 0;
      bool gameOver = false;
      while(!gameOver)
      {
        turn++;
        Console.Clear();
        Console.WriteLine($"Turn {turn}");
        Console.WriteLine($"[P1] HP: {hero1.hp}, Mana: {hero1.mana}  |  [P2] HP: {hero2.hp}, Mana: {hero2.mana}");
        Console.WriteLine("Spells: Fireball, Water Jet, Ice spike");
        battleMath();
      }
    }
  }
  class Program
  {
    static void Main(string[] args)
    {
      Hero hero1 = new Hero();
      hero1.Create(100, 100, 10, 8);
      Hero hero2 = new Hero();
      hero2.Create(100, 100, 10, 8);

      Arena battle = new Arena();
      battle.battle(hero1, hero2);
    }
  }
}
