using System; namespace HelloWorld { class Spell { public int damage; public int manaCost; public Spell(int dmg, int mc) { damage = dmg; manaCost = mc; } public void castSpell(Hero target, Hero caster, bool both_used = false) { if(both_used) {target.hp -= damage/2;} else {target.hp -= damage;} caster.mana -= manaCost; } } class Fireball:Spell { public Fireball(int dmg, int mc) : base(dmg, mc){} public void castSpell(Hero target, Hero caster, bool both_used = false) { base.castSpell(target,caster,both_used); if(target.state == "wet"){target.state = "";} if(caster.state == "wet"){caster.state = "";} } } class WaterJet:Spell { public WaterJet(int dmg, int mc) : base(dmg, mc){} public void castSpell(Hero target, Hero caster, bool both_used = false) { base.castSpell(target,caster,both_used); if(target.state == ""){target.state = "wet";} } } class IceSpike:Spell { public IceSpike(int dmg, int mc) : base(dmg, mc){} public void castSpell(Hero target, Hero caster, bool both_used = false) { base.castSpell(target,caster,both_used); if(target.state == "wet"){target.state = "frozen";} } } class Hero { // Mainīgie (lauki) public int hp; public int mana; public int defense; //procentage public int manaRecovery; //per turn public string state; public string move; // Metode (funkcija), ko klase prot darīt public Hero(int hp_input, int mana_input, int defense_input, int manaRecovery_input) { hp = hp_input; mana = mana_input; defense = defense_input; manaRecovery = manaRecovery_input; state = ""; } } class Battle { Hero hero1; Hero hero2; void battleLogic() { Fireball fireball = new Fireball(15, 13); WaterJet water_jet = new WaterJet(8, 8); IceSpike ice_spike = new IceSpike(12, 10); Console.WriteLine("hero1: " + hero1.state); Console.WriteLine("hero2: " + hero2.state); Console.WriteLine("Player 1 ievada spell"); hero1.move = Console.ReadLine().ToLower(); Console.WriteLine("Player 2 ievada spell"); hero2.move = Console.ReadLine().ToLower(); if(hero1.move == hero2.move && hero1.state != "frozen" && hero2.state != "frozen"){ switch (hero1.move){ case "fireball": fireball.castSpell(hero1,hero2,true); fireball.castSpell(hero2,hero1,true); break; case "ice spike": ice_spike.castSpell(hero1,hero2,true); ice_spike.castSpell(hero2,hero1,true); break; case "water jet": water_jet.castSpell(hero1,hero2,true); water_jet.castSpell(hero2,hero1,true); break; } return; } if(hero1.state != "frozen"){ switch (hero1.move){ case "fireball": fireball.castSpell(hero2,hero1); break; case "ice spike": ice_spike.castSpell(hero2,hero1); break; case "water jet": water_jet.castSpell(hero2,hero1); break; } } if(hero2.state != "frozen"){ switch (hero2.move){ case "fireball": fireball.castSpell(hero1,hero2); break; case "ice spike": ice_spike.castSpell(hero1,hero2); break; case "water jet": water_jet.castSpell(hero1,hero2); break; } } if(hero1.state == "frozen"){hero1.state = "";} if(hero2.state == "frozen"){hero2.state = "";} } public Battle (Hero hero1_input, Hero hero2_input) { hero1 = hero1_input; hero2 = hero2_input; 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"); battleLogic(); } } } class Program { static void Main(string[] args) { Hero hero1 = new Hero(100, 100, 10, 8); Hero hero2 = new Hero(100, 100, 10, 8); Battle battle = new Battle(hero1, hero2); } } }