Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace GladiatorGames
- {
- class Program
- {
- static void Main(string[] args)
- {
- Arena arena = new Arena();
- arena.Work();
- }
- }
- class Arena
- {
- private List<Gladiator> _gladiators;
- public Arena()
- {
- _gladiators = new List<Gladiator>();
- }
- public void Work()
- {
- bool isOpen = true;
- string userInput;
- int gladiatorIndex = -1;
- Random rand = new Random();
- while (isOpen)
- {
- LoadGladiators();
- Console.WriteLine($"Ave, Caesar, morituri te salutant! (латынь)\nСлавься, Цезарь, идущие на смерть приветствуют тебя!");
- Console.WriteLine($"\nВыбери достойных сражаться в Колизее перед твоим взором\n");
- Console.Write($"нажми любую, что посмотреть гладиаторов или exit для выхода: ");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "учше":
- case "exit":
- isOpen = false;
- break;
- default:
- ShowAllGladiators();
- Console.Write($"\nВыберите гладиатора каменных ворот: ");
- gladiatorIndex = TryGetIndex(_gladiators.Count);
- Gladiator stoneGateGladiator = _gladiators[gladiatorIndex - 1];
- Console.Write($"Выберите гладиатора железных ворот: ");
- gladiatorIndex = TryGetIndex(_gladiators.Count);
- Gladiator ironGateGladiator = _gladiators[gladiatorIndex - 1];
- while (stoneGateGladiator.HitPoints > 0 && ironGateGladiator.HitPoints > 0)
- {
- stoneGateGladiator.TryUseSpeciality(rand);
- ironGateGladiator.TryUseSpeciality(rand);
- Console.WriteLine();
- stoneGateGladiator.TakeDamage(ironGateGladiator.Injury);
- ironGateGladiator.TakeDamage(stoneGateGladiator.Injury);
- stoneGateGladiator.ShowHeals();
- ironGateGladiator.ShowHeals();
- }
- if (stoneGateGladiator.HitPoints <= 0 && ironGateGladiator.HitPoints <= 0)
- {
- Console.WriteLine($"\nОба гладиатора пали на Арене");
- }
- else if (stoneGateGladiator.HitPoints <= 0)
- {
- stoneGateGladiator.ShowDeathCertificate();
- }
- else if (ironGateGladiator.HitPoints <= 0)
- {
- ironGateGladiator.ShowDeathCertificate();
- }
- Console.ReadKey();
- Console.Clear();
- _gladiators.RemoveRange(0, _gladiators.Count);
- break;
- }
- }
- }
- private void ShowAllGladiators()
- {
- Console.WriteLine();
- for (int i = 0; i < _gladiators.Count; i++)
- {
- Console.Write($"{i + 1}. ");
- _gladiators[i].ShowStats();
- }
- }
- private void LoadGladiators()
- {
- _gladiators.Add(new Berserk("Бъорн", 100, 10, 2));
- _gladiators.Add(new Berserk("Ульф", 100, 9, 3));
- _gladiators.Add(new Kamikaze("Ивао", 110, 10, 2));
- _gladiators.Add(new Kamikaze("Исаму", 90, 10, 2));
- _gladiators.Add(new Ambidexter("Мордо",110,7,2));
- _gladiators.Add(new Ambidexter("Кецилий",100,10,2));
- }
- private bool TryReadInt(out int number)
- {
- bool result = false;
- result = int.TryParse(Console.ReadLine(), out number);
- return result;
- }
- private int TryGetIndex(int size)
- {
- int minLimit = 0;
- int maxLimit = size;
- bool isGetIndex = false;
- int number;
- TryReadInt(out number);
- while (isGetIndex == false)
- {
- if (number > minLimit && number <= maxLimit)
- {
- isGetIndex = true;
- }
- else
- {
- Console.Write($"Введите число в диапазоне от {minLimit + 1} до {maxLimit}: ");
- TryReadInt(out number);
- }
- }
- return number;
- }
- }
- abstract class Gladiator
- {
- protected string Name;
- protected int Health;
- protected int Damage;
- protected int Armor;
- protected string Type;
- protected string Speciality;
- public int HitPoints
- {
- get
- {
- return Health;
- }
- }
- public int Injury
- {
- get
- {
- return Damage;
- }
- }
- public Gladiator(string name, int health, int damage, int armor)
- {
- Name = name;
- Health = health;
- Damage = damage;
- Armor = armor;
- }
- public abstract void UseSpeciality();
- public void TryUseSpeciality(Random rand)
- {
- int limit = 3;
- bool tryToUse;
- tryToUse = (rand.Next(0, limit) == 0);
- if (tryToUse)
- {
- UseSpeciality();
- }
- }
- public virtual void ShowDeathCertificate()
- {
- Console.WriteLine($"\nгладиатор {Name} отправился в царство Аида");
- }
- public void ShowStats()
- {
- Console.WriteLine($"{Type} {Name}\tздоровье {Health}\tурон {Damage}\tброня {Armor}");
- }
- public void ShowHeals()
- {
- Console.WriteLine($"{Type} {Name}\tздоровье {Health}");
- }
- public void TakeDamage(int damage)
- {
- Health -= damage - Armor;
- }
- }
- class Berserk : Gladiator
- {
- public Berserk(string name, int health, int damage, int armor) : base(name, health, damage, armor)
- {
- Type = "берсеркер";
- Speciality = "грызет щит, что уменьшает броню (-2), но увеличивает урон (+10)";
- }
- public override void UseSpeciality()
- {
- Console.WriteLine($"{Type} {Name} применил навык - {Speciality}");
- Armor -= 2;
- Damage += 10;
- }
- public override void ShowDeathCertificate()
- {
- Console.WriteLine($"\n{Type} {Name} отправился в Вальхаллу");
- }
- }
- class Kamikaze : Gladiator
- {
- public Kamikaze(string name, int health, int damage, int armor) : base(name, health, damage, armor)
- {
- Type = "камикадзе";
- Speciality = "дополнительно нанесет 50 единиц урона, но погибнет после такого удара";
- }
- public override void UseSpeciality()
- {
- Console.WriteLine($"{Type} {Name} применил навык - {Speciality}");
- Damage += 50;
- Health = 1;
- }
- public override void ShowDeathCertificate()
- {
- Console.WriteLine($"\n{Type} {Name} отправился к Будде");
- }
- }
- class Ambidexter: Gladiator
- {
- public Ambidexter(string name, int health, int damage, int armor): base (name, health, damage, armor)
- {
- Type = "амбидекстер";
- Speciality = "наносит двойной урон 2-мя мечами";
- }
- public override void UseSpeciality()
- {
- Console.WriteLine($"{Type} {Name} применил навык - {Speciality}");
- Damage *= 2;
- }
- }
- }
Add Comment
Please, Sign In to add comment