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 Home_Work
- {
- class Program
- {
- static void Main(string[] args)
- {
- Coliseum coliseum = new Coliseum();
- coliseum.Work();
- }
- }
- class Coliseum
- {
- private Gladiator _firstGladiator;
- private Gladiator _secondGladiator;
- private int _countFight;
- public Coliseum()
- {
- _countFight = 0;
- }
- public void Work()
- {
- ShowGreeting();
- ManageBattles();
- ShowFinish();
- }
- private void ShowGreeting()
- {
- Console.WriteLine("Сегодня на бои будет смотреть сам Цезарь. Не разочаруйте его.");
- Console.WriteLine("Вам предстоит выбирать, кто будет сражаться.");
- }
- private void ManageBattles()
- {
- bool isWorking = true;
- while (isWorking == true)
- {
- Console.ReadKey();
- Console.Clear();
- Console.WriteLine("1. Провести бой. \n2. Выйти");
- switch (Console.ReadLine())
- {
- case "1":
- ArrangeFight();
- break;
- case "2":
- isWorking = false;
- break;
- default:
- Console.WriteLine("Такого варианта нет.");
- break;
- }
- }
- }
- private void ArrangeFight()
- {
- ChooseFighters();
- Fight();
- AnnounceWinner();
- _countFight++;
- }
- private void ChooseFighters()
- {
- GladiarotCreator gladiarotCreator = new GladiarotCreator();
- _firstGladiator = gladiarotCreator.ChooseGladiator();
- _secondGladiator = gladiarotCreator.ChooseGladiator();
- }
- private void Fight()
- {
- while (_firstGladiator.IsAlive == true && _secondGladiator.IsAlive == true)
- {
- Console.Clear();
- if (_firstGladiator.CanAttack == true)
- {
- _firstGladiator.Attack(_secondGladiator);
- }
- if (_secondGladiator.CanAttack == true)
- {
- _secondGladiator.Attack(_firstGladiator);
- }
- Console.ReadKey();
- }
- }
- private void AnnounceWinner()
- {
- if (_firstGladiator.IsAlive == false && _secondGladiator.IsAlive == false)
- {
- Console.WriteLine("Случилось невероятное! Ничья!");
- }
- else if (_firstGladiator.IsAlive == true)
- {
- Console.WriteLine($"Победил {_firstGladiator.FullName}");
- }
- else
- {
- Console.WriteLine($"Победил {_secondGladiator.FullName}");
- }
- }
- private void ShowFinish()
- {
- Console.WriteLine($"Вы провели {_countFight} боёв.");
- Console.WriteLine("Цезарь остался вами доволен. Ваша голова не будет висеть над воротами.");
- Console.ReadKey();
- }
- }
- class Gladiator
- {
- protected static Random Random;
- protected static int PresetMaximumPercentage;
- protected string ClassName;
- protected string Specification;
- protected string Name;
- protected float Health;
- protected int Damage;
- protected int Armor;
- protected int ChanceSpecialAttack;
- protected int ChanceDodge;
- protected bool IsTied;
- static Gladiator()
- {
- Random = new Random();
- PresetMaximumPercentage = 101;
- }
- public Gladiator(string name = "Ноунейм")
- {
- Name = name;
- ClassName = "Нищий";
- Specification = "О нём ничего не известно";
- Health = 50;
- Damage = 50;
- Armor = 1;
- ChanceSpecialAttack = 50;
- ChanceDodge = 50;
- IsTied = false;
- }
- public bool IsAlive => Health > 0;
- public bool CanAttack => IsTied == false && IsAlive == true;
- public string FullName => $"{ClassName} {Name}";
- public string ShowInfo()
- {
- return $"{ClassName} - {Specification}";
- }
- public void TakeDamage(float damage)
- {
- if (IsTied == true)
- {
- Health -= damage;
- IsTied = false;
- Console.WriteLine($"{FullName} связан сетью и не может защититься. Получает {damage} урона и освобождается.");
- }
- else if (ChanceDodge > Random.Next(PresetMaximumPercentage))
- {
- Console.WriteLine($"{FullName} уклонился от атаки.");
- }
- else
- {
- float realDamage = damage / Armor;
- Health -= realDamage;
- Console.WriteLine($"{FullName} защищается и получает {realDamage} урона.");
- }
- }
- public void GetOnNet()
- {
- IsTied = true;
- Console.WriteLine($"{FullName} попадается в сети.");
- }
- public virtual void Attack(Gladiator gladiator)
- {
- gladiator.TakeDamage(Damage);
- }
- }
- class Gaul : Gladiator
- {
- private int _strongHit;
- public Gaul(string name) : base(name)
- {
- ClassName = "Галл";
- Specification = "Средние показатели атаки, но хорошая защита. Использует копьё и маленький щит, большая часть тела закрыта броней.";
- Health = 70;
- Damage = 40;
- Armor = 7;
- ChanceSpecialAttack = 50;
- ChanceDodge = 30;
- _strongHit = 80;
- }
- public override void Attack(Gladiator gladiator)
- {
- float realDamage;
- if (ChanceSpecialAttack > Random.Next(PresetMaximumPercentage))
- {
- realDamage = _strongHit;
- Console.WriteLine($"{FullName} наносит сильный удар.");
- }
- else
- {
- realDamage = Damage;
- Console.WriteLine($"{FullName} наносит обычный удар.");
- }
- gladiator.TakeDamage(realDamage);
- }
- }
- class Diemaher : Gladiator
- {
- private int _damageForAdd;
- public Diemaher(string name) : base(name)
- {
- ClassName = "Димахер";
- Specification = "Высокие показатели атаки и слабая защита. Использует 2 меча, почти отсутсвует защита.";
- Health = 60;
- Damage = 100;
- Armor = 2;
- ChanceSpecialAttack = 50;
- ChanceDodge = 75;
- _damageForAdd = 10;
- }
- public override void Attack(Gladiator gladiator)
- {
- if (ChanceSpecialAttack > Random.Next(PresetMaximumPercentage))
- {
- Damage += _damageForAdd;
- Console.WriteLine($"{FullName} начинает бить с большей яростью.");
- }
- else
- {
- Console.WriteLine($"{FullName} наносит обычный удар.");
- }
- gladiator.TakeDamage(Damage);
- }
- }
- class Murmillion : Gladiator
- {
- private int _armorForAdd;
- public Murmillion(string name) : base(name)
- {
- ClassName = "Мурмиллон";
- Specification = "Самый тяжёлый боец, но слабые атаки. Оснащён одноручным мечом и огромным щитом.";
- Health = 90;
- Damage = 30;
- Armor = 10;
- ChanceSpecialAttack = 50;
- ChanceDodge = 30;
- _armorForAdd = 1;
- }
- public override void Attack(Gladiator gladiator)
- {
- if (ChanceSpecialAttack > Random.Next(PresetMaximumPercentage))
- {
- Armor += _armorForAdd;
- Console.Write($"{FullName} привык к атакам и улучшил защиту. ");
- }
- Console.WriteLine($"{FullName} наносит обычный удар.");
- gladiator.TakeDamage(Damage);
- }
- }
- class Thracian : Gladiator
- {
- private int _countAttack;
- public Thracian(string name) : base(name)
- {
- ClassName = "Фракиец";
- Specification = "Средние показатели атаки и защиты. Оснащён одноручным мечом и средним щитом, брони не много.";
- Health = 70;
- Damage = 50;
- Armor = 5;
- ChanceSpecialAttack = 50;
- ChanceDodge = 50;
- _countAttack = 2;
- }
- public override void Attack(Gladiator gladiator)
- {
- float realDamage;
- if (ChanceSpecialAttack > Random.Next(PresetMaximumPercentage))
- {
- realDamage = Damage * _countAttack;
- Console.WriteLine($"{FullName} успевает нанести {_countAttack} удара.");
- }
- else
- {
- realDamage = Damage;
- Console.WriteLine($"{FullName} наносит обычный удар.");
- }
- gladiator.TakeDamage(realDamage);
- }
- }
- class Retiary : Gladiator
- {
- public Retiary(string name) : base(name)
- {
- ClassName = "Ретиарий";
- Specification = "Слабые показатели атаки и защиты. Оснащён трезубцем и сетью, брони мало.";
- Health = 70;
- Damage = 30;
- Armor = 3;
- ChanceSpecialAttack = 45;
- ChanceDodge = 50;
- }
- public override void Attack(Gladiator gladiator)
- {
- if (ChanceSpecialAttack > Random.Next(PresetMaximumPercentage))
- {
- Console.WriteLine($"{FullName} кидает сеть и ловит противника.");
- gladiator.GetOnNet();
- }
- else
- {
- float realDamage = Damage;
- Console.WriteLine($"{FullName} наносит обычный удар.");
- gladiator.TakeDamage(realDamage);
- }
- }
- }
- class GladiarotCreator
- {
- private List<Gladiator> _allGladiators;
- public GladiarotCreator()
- {
- _allGladiators = new List<Gladiator> {
- new Gaul(""),
- new Diemaher(""),
- new Murmillion(""),
- new Thracian(""),
- new Retiary("") };
- }
- public Gladiator ChooseGladiator()
- {
- bool isChoosed = false;
- string name;
- Console.Clear();
- Console.Write("Введите, как объявить гладиатора: ");
- name = Console.ReadLine();
- while (isChoosed == false)
- {
- Gladiator gladiator;
- Console.Clear();
- Console.WriteLine($"Выберите тип гладиатора: ");
- ShowAllGladiator();
- gladiator = _allGladiators[GetIndex()];
- switch (gladiator)
- {
- case Gaul:
- return new Gaul(name);
- case Diemaher:
- return new Diemaher(name);
- case Murmillion:
- return new Murmillion(name);
- case Thracian:
- return new Thracian(name);
- case Retiary:
- return new Retiary(name);
- }
- Console.ReadKey();
- }
- return null;
- }
- private void ShowAllGladiator()
- {
- int index = 1;
- foreach (Gladiator gladiator in _allGladiators)
- {
- Console.WriteLine($"{index}. {gladiator.ShowInfo()}");
- index++;
- }
- }
- private int GetIndex()
- {
- int index = 0;
- bool isGetIndex = false;
- string userInput;
- while (isGetIndex == false)
- {
- Console.Write("\nВведите индекс: ");
- userInput = Console.ReadLine();
- if(Int32.TryParse(userInput, out index))
- {
- if (index > 0 && index <= _allGladiators.Count)
- {
- isGetIndex = true;
- }
- else
- {
- Console.WriteLine("Введите индекс гладиатора.");
- }
- }
- else
- {
- Console.WriteLine("Введите целое число.");
- }
- }
- return index - 1;
- }
- }
- }
Add Comment
Please, Sign In to add comment