Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- Player player = new Player();
- Boss boss = new Boss();
- Battleground battleground = new Battleground();
- battleground.Battle(player, boss);
- }
- }
- class Player
- {
- private bool _isFierBallAttack = false;
- private int _quantityRecovers = 4;
- private int _health = 100;
- private int _mana = 100;
- private int _damage = 10;
- public void ChangeHealth(int value)
- {
- _health -= value;
- }
- public int GiveValueOfHealth()
- {
- return _health;
- }
- public int GiveValueOfMana()
- {
- return _mana;
- }
- public int DamageAttack()
- {
- return _damage;
- }
- public int DamageFierBallAttack()
- {
- int damageFierballAttack = 50;
- int manaPoints = 30;
- _mana -= manaPoints;
- _isFierBallAttack = true;
- return damageFierballAttack;
- }
- public void ManaRecovery()
- {
- int manaRecoverPerOneMove = 1;
- if (_mana < 100)
- {
- _mana += manaRecoverPerOneMove;
- }
- }
- public int DamageDetonation()
- {
- int damage = 100;
- int manaPoints = 90;
- if (_mana < manaPoints)
- {
- Console.WriteLine("У вас недостаточно маны.");
- return 0;
- }
- else if (_isFierBallAttack == true)
- {
- _mana -= manaPoints;
- _isFierBallAttack = false;
- return damage;
- }
- else
- {
- Console.WriteLine("Сначала нужно использовать удар огненым шаром.");
- return 0;
- }
- }
- public void RecoverManaAndHealth()
- {
- if (_quantityRecovers > 0)
- {
- _health = 100;
- _mana = 100;
- _quantityRecovers--;
- Console.WriteLine($"У вас осталось {_quantityRecovers} регенираций.");
- }
- else
- {
- Console.WriteLine("Вы больше не можете регенерировать свое здоровье и ману в этом бою.");
- }
- }
- }
- class Boss
- {
- private int _health = 600;
- private int _damage = 6;
- private int _berserkMode = 10;
- public void Attack(Player player)
- {
- if (_health <= _health / 2)
- {
- player.ChangeHealth(_berserkMode);
- }
- else
- {
- player.ChangeHealth(_damage);
- }
- }
- public int GiveValueOfHealth()
- {
- return _health;
- }
- public void ChangeHealth(int value)
- {
- _health -= value;
- }
- }
- class Battleground
- {
- public void Battle(Player player, Boss boss)
- {
- const string CommandAttack = "attack";
- const string CommandFierBall = "fier ball";
- const string CommandDetonation = "detonation";
- const string CommandRecover = "recover";
- int horizontallyEnemyConsoleHealthPosition = 20;
- int verticalsEnemyConsoleHealthPosition = 0;
- int horizontallyPlayerConsolePosition = 0;
- int verticalsPlayerConsoleHealthPosition = 0;
- bool isWorking = true;
- while (isWorking)
- {
- int bossHealth = boss.GiveValueOfHealth();
- int playerHealth = player.GiveValueOfHealth();
- int playerMana = player.GiveValueOfMana();
- Console.SetCursorPosition(horizontallyEnemyConsoleHealthPosition, verticalsEnemyConsoleHealthPosition);
- Console.ForegroundColor = ConsoleColor.DarkRed;
- Console.WriteLine($"{bossHealth} - здоровье врага");
- Console.ResetColor();
- Console.SetCursorPosition(horizontallyPlayerConsolePosition, verticalsPlayerConsoleHealthPosition);
- Console.WriteLine($"{playerHealth} - Здоровье\n{playerMana} - Мана\n\n\n");
- Console.WriteLine($"Чтобы нанести обычную атаку введите - {CommandAttack}");
- Console.WriteLine($"Чтобы нанести удар огненным мячом введите - {CommandFierBall}");
- Console.WriteLine($"Чтобы нанести удар взрывом - {CommandDetonation}");
- Console.WriteLine($"Чтобы восстановить здоровье и ману введите - {CommandRecover}");
- string userInput = Console.ReadLine();
- switch (userInput)
- {
- case CommandAttack:
- boss.ChangeHealth(player.DamageAttack());
- break;
- case CommandFierBall:
- boss.ChangeHealth(player.DamageFierBallAttack());
- break;
- case CommandDetonation:
- boss.ChangeHealth(player.DamageDetonation());
- break;
- case CommandRecover:
- player.RecoverManaAndHealth();
- break;
- default:
- Console.WriteLine("Введена неверная команда.");
- break;
- }
- player.ManaRecovery();
- if (player.GiveValueOfHealth() > 0 && boss.GiveValueOfHealth() > 0)
- {
- boss.Attack(player);
- }
- else if (player.GiveValueOfHealth() <= 0)
- {
- Console.WriteLine("Вы проиграли битву.");
- Console.ReadKey();
- isWorking = false;
- }
- else if (boss.GiveValueOfHealth() <= 0)
- {
- Console.WriteLine("Вы победили противника.");
- Console.ReadKey();
- isWorking = false;
- }
- else if (player.GiveValueOfHealth() <= 0 && boss.GiveValueOfHealth() <= 0)
- {
- Console.WriteLine("Это была равная битва.");
- Console.ReadKey();
- isWorking = false;
- }
- Console.ReadKey();
- Console.Clear();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement