Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading.Channels;
- using static System.Net.Mime.MediaTypeNames;
- namespace Гладиаторские_бои
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Arena arena = new();
- arena.Battle();
- }
- }
- abstract class Fighter
- {
- private Random _random = new Random();
- public Fighter(int id, int health, string name, int damage, int armor)
- {
- Id = id;
- Health = health;
- Name = name;
- Damage = damage;
- Armor = armor;
- }
- public int Id { get; protected set; }
- public string Name { get; protected set; }
- public int Health { get; protected set; }
- public int Damage { get; protected set; }
- public int Armor { get; protected set; }
- public virtual void ShowStats()
- {
- Console.WriteLine($"<{Id}> {Name}: \n HitPoint: {Health} Damage: {Damage} Armor: {Armor}");
- }
- public void Attack(Fighter fighter)
- {
- UseSpecialAttack(fighter);
- }
- private void UseSpecialAttack(Fighter fighter)
- {
- int switchSkill = Utility.GenerateRandomNumber(0, 3);
- if (switchSkill == 0)
- {
- UseSkill1();
- }
- else if (switchSkill == 1)
- {
- UseSkill2();
- }
- else
- {
- TakeDamage(fighter.Damage);
- }
- }
- protected abstract void UseSkill1();
- protected abstract void UseSkill2();
- protected virtual void TakeDamage(int damage)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine($"\nНеудача! {Name} получает {damage - Armor} урона");
- Console.ForegroundColor = ConsoleColor.White;
- Health -= (damage - Armor);
- }
- }
- class CyborgEngineer : Fighter
- {
- private int _energy;
- private int _damageBuff = 5;
- private int _healthBuff = 10;
- private int _energyDecrease = 25;
- private int _maxEnergyLimit = 76;
- private int _minEnergyLimit = 0;
- public CyborgEngineer(int id, int health, string name, int energy, int damage, int armor) : base(id, health, name, damage, armor)
- {
- _energy = energy;
- }
- protected override void UseSkill1()
- {
- Console.WriteLine($"\n{Name} использует паровые ускорители, Damage +{_damageBuff}");
- Damage += _damageBuff;
- }
- protected override void UseSkill2()
- {
- Console.WriteLine($"\n{Name} использует реконструкция: Health +{_healthBuff}, Energy -{_energyDecrease}");
- if (_energy > _minEnergyLimit && _energy < _maxEnergyLimit)
- {
- Health += _healthBuff;
- _energy -= _energyDecrease;
- }
- else
- {
- Console.WriteLine("\nНехватка энергии");
- }
- }
- public override void ShowStats()
- {
- Console.WriteLine($"<{Id}> {Name}: \n HitPoint: {Health} Damage: {Damage} Armor: {Armor} Energy: {_energy}");
- }
- }
- class ElectromagneticMage : Fighter
- {
- private Random _random = new Random();
- private int _mana;
- private int _armorBuff = 1;
- private int _manaDecrease = 10;
- private int _healthBuff = 10;
- private int _criticalChanceLimit = 20;
- private int _manaLimit = 41;
- private int _manaCheckLimit = 0;
- private int _criticalChanceMin = 0;
- private int _criticalChanceMax = 100;
- public ElectromagneticMage(int id, int health, string name, int mana, int damage, int armor) : base(id, health, name, damage, armor)
- {
- _mana = mana;
- }
- protected override void UseSkill1()
- {
- Console.WriteLine($"\n{Name} использует магнитное поле: Armor +{_armorBuff}, Mana -{_manaDecrease}");
- if (_mana > _manaCheckLimit && _mana < _manaLimit)
- {
- Armor += _armorBuff;
- _mana -= _manaDecrease;
- }
- else
- {
- Console.WriteLine("\nНехватка маны");
- }
- }
- protected override void UseSkill2()
- {
- Console.Write($"\n{Name} использует электрический щит: ");
- int CriticalChance = _random.Next(_criticalChanceMin, _criticalChanceMax);
- if (CriticalChance < _criticalChanceLimit && _mana > _manaCheckLimit && _mana < _manaLimit)
- {
- Console.WriteLine($"...сработал крит шанс! Health +{_healthBuff}, Armor + {_armorBuff}, Mana -{_manaDecrease}");
- Armor += _armorBuff;
- Health += _healthBuff;
- _mana -= _manaDecrease;
- }
- else if (_mana > _manaCheckLimit && _mana < _manaLimit)
- {
- Console.WriteLine($"Health +{_healthBuff}, Mana -{_manaDecrease}");
- Health += _healthBuff;
- _mana -= _manaDecrease;
- }
- else
- {
- Console.WriteLine("Нехватка маны");
- }
- }
- public override void ShowStats()
- {
- Console.WriteLine($"<{Id}> {Name}: \n HitPoint: {Health} Damage: {Damage} Armor: {Armor} Mana: {_mana}");
- }
- }
- class SteamNinja : Fighter
- {
- private int _damageBuff = 10;
- private int _healthDecrease = 10;
- private int _healthLimit = 40;
- public SteamNinja(int id, int health, string name, int damage, int armor) : base(id, health, name, damage, armor) { }
- protected override void UseSkill1()
- {
- Console.WriteLine($"\n{Name} использует заточка катаны: Damage +{_damageBuff}");
- Damage += _damageBuff;
- }
- protected override void UseSkill2()
- {
- if (Health >= _healthLimit)
- {
- Console.WriteLine($"\n{Name} использует харакири: Health -{_healthDecrease}, Damage +{_damageBuff}");
- Health -= _healthDecrease;
- Damage += _damageBuff;
- }
- else
- {
- UseSkill1();
- }
- }
- protected override void TakeDamage(int damage)
- {
- Random random = new Random();
- int tryUseAbility = Utility.GenerateRandomNumber(0, 2);
- if (tryUseAbility == 0)
- {
- Console.WriteLine($"\n{Name} скрывается в паровом облаке и избегает урона");
- }
- else
- {
- base.TakeDamage(damage);
- }
- }
- }
- class MechanicalAlchemist : Fighter
- {
- private int _healthBuff = 10;
- private int _armorBuff = 1;
- public MechanicalAlchemist(int id, int health, string name, int damage, int armor) : base(id, health, name, damage, armor)
- {
- }
- protected override void UseSkill1()
- {
- Console.WriteLine($"\n{Name} использует эликсир здоровья: Health +{_healthBuff}");
- Health += _healthBuff;
- }
- protected override void UseSkill2()
- {
- Console.WriteLine($"\n{Name} использует эликсир брони: Armor +{_armorBuff}");
- Armor += _armorBuff;
- }
- public override void ShowStats()
- {
- Console.WriteLine($"<{Id}> {Name}: \n HitPoint: {Health} Damage: {Damage} Armor: {Armor}");
- }
- }
- class HydraulicConjurer : Fighter
- {
- private Random _random = new Random();
- private int _armorBuff = 1;
- public HydraulicConjurer(int id, int health, string name, int damage, int armor) : base(id, health, name, damage, armor) { }
- protected override void UseSkill1()
- {
- Console.WriteLine($"\n{Name} укрепляет гидравлическую броню Armor +{_armorBuff}");
- Armor += _armorBuff;
- }
- protected override void UseSkill2()
- {
- UseSkill1();
- UseSkill1();
- }
- protected override void TakeDamage(int damage)
- {
- int armorModifier = 2;
- int tryCreateIllusion = Utility.GenerateRandomNumber(0, 2);
- if (tryCreateIllusion == 0)
- {
- Console.WriteLine($"\n{Name} создает иллюзию и получает только половину урона");
- Health -= damage / armorModifier;
- Console.WriteLine($"\n{Name} получает {damage / armorModifier} урона");
- }
- else
- {
- base.TakeDamage(damage);
- }
- }
- public override void ShowStats()
- {
- Console.WriteLine($"<{Id}> {Name}: \n HitPoint: {Health} Damage: {Damage} Armor: {Armor}");
- }
- }
- class Arena
- {
- private Fighter _fighter1;
- private Fighter _fighter2;
- private List<Fighter> _fighters = new List<Fighter>();
- public Arena()
- {
- FillFightersList();
- }
- public void Battle()
- {
- ShowAllFightersStats();
- TryCreateFighters();
- Fight();
- ShowResult();
- }
- private void FillFightersList()
- {
- _fighters.Add(new CyborgEngineer(1, 100, "CyborgEngineer", 75, 15, 10));
- _fighters.Add(new SteamNinja(2, 120, "SteamNinja", 20, 5));
- _fighters.Add(new ElectromagneticMage(3, 100, "ElectromagneticMage", 40, 25, 10));
- _fighters.Add(new MechanicalAlchemist(4, 100, "MechanicalAlchemist", 5, 20));
- _fighters.Add(new HydraulicConjurer(5, 100, "HydraulicConjurer", 15, 10));
- }
- private void TryCreateFighters()
- {
- Console.WriteLine("\nБоец 1");
- _fighter1 = ChooseFighter();
- Console.WriteLine("\nБоец 2");
- _fighter2 = ChooseFighter();
- if (_fighter1 == null || _fighter2 == null)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Ошибка выбора бойцов");
- Console.ForegroundColor = ConsoleColor.White;
- _fighters.Clear();
- FillFightersList();
- TryCreateFighters();
- }
- }
- private void Fight()
- {
- int turnNumber = 1;
- while (_fighter1.Health > 0 && _fighter2.Health > 0)
- {
- Console.ForegroundColor = ConsoleColor.DarkYellow;
- Console.WriteLine($"\nХод номер {turnNumber++}");
- Console.ForegroundColor = ConsoleColor.White;
- _fighter1.ShowStats();
- _fighter2.ShowStats();
- if (_fighter1.Health > 0)
- {
- _fighter1.Attack(_fighter2);
- }
- if (_fighter2.Health > 0)
- {
- _fighter2.Attack(_fighter1);
- }
- Thread.Sleep(500);
- }
- }
- private void ShowAllFightersStats()
- {
- Console.WriteLine("\nВ мире, где технологии паровых машин и механических устройств слились с боевыми искусствами\n" +
- "проходит турнир, собравший лучших бойцов со всего мира. Пять уникальных персонажей решили\n" +
- "принять участие и доказать свое превосходство\n");
- Console.WriteLine("Паровой Киборг-инженер - обладает способность к самовосстановлению, использует паровые ускорители\n\n" +
- "Электромагнетический Маг - способен манипулировать электричеством и магнитными полями\n\n" +
- "Ниндзя-ассасин - скрывается в паровых облаках. Слабо защищен, но имеет большой урон, который может разгонять\n\n" +
- "Механический алхимик - способен создавать элексиры для усиления\n\n" +
- "Гидравлический фокусник - может создавать иллюзии, носит гидравлическую броню.\n\n");
- for (int i = 0; i < _fighters.Count; i++)
- {
- Console.ForegroundColor = ConsoleColor.DarkYellow;
- _fighters[i].ShowStats();
- Console.ForegroundColor = ConsoleColor.White;
- }
- }
- private void ShowResult()
- {
- if (_fighter1.Health < 0 && _fighter2.Health < 0)
- {
- Console.ForegroundColor = ConsoleColor.DarkGreen;
- Console.WriteLine("\nНичья");
- Console.ForegroundColor = ConsoleColor.White;
- }
- else if (_fighter2.Health <= 0)
- {
- Console.ForegroundColor = ConsoleColor.DarkGreen;
- Console.WriteLine($"\n{_fighter1.Name} Победил");
- Console.ForegroundColor = ConsoleColor.White;
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.DarkGreen;
- Console.WriteLine($"\n{_fighter2.Name} Победил");
- Console.ForegroundColor = ConsoleColor.White;
- }
- }
- private Fighter ChooseFighter()
- {
- Fighter selectFighter = null;
- Console.ForegroundColor = ConsoleColor.DarkGreen;
- Console.WriteLine("Выбери героя по ID:");
- Console.ForegroundColor = ConsoleColor.White;
- while (selectFighter == null)
- {
- int userInput = Utility.ReturnInputNumber();
- foreach (var fighter in _fighters)
- {
- if (userInput == fighter.Id)
- {
- selectFighter = fighter;
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.WriteLine($"Выбран {fighter.Name}");
- Console.ForegroundColor = ConsoleColor.White;
- _fighters.Remove(fighter);
- break;
- }
- }
- }
- return selectFighter;
- }
- }
- class Utility
- {
- private static Random _random = new Random();
- public static int GenerateRandomNumber(int min, int max)
- {
- int randomNumber = _random.Next(min, max);
- return randomNumber;
- }
- public static int ReturnInputNumber()
- {
- int number;
- while (int.TryParse(Console.ReadLine(), out number) == false)
- {
- Console.WriteLine("Введено не число, попробуйте еще раз: ");
- }
- return number;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement