Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace HomeWork
- {
- public class Program
- {
- static void Main(string[] args)
- {
- const string CommandAttack = "1";
- const string CommandFireball = "2";
- const string CommandExplosion = "3";
- const string CommandRecovery = "4";
- Random random = new Random();
- string playerInput;
- int playerMaxHealth = 100;
- int playerHealth = playerMaxHealth;
- int playerMaxMana = 200;
- int playerMana = playerMaxMana;
- int playerMinAttack = 1;
- int playerMaxAttack = 8;
- int playerCurrentAttack;
- int fireBallAttack = 25;
- int fireBallManaCost = 50;
- int explosionAttack = 45;
- int healthRecovery = 20;
- int manaRecovery = 40;
- int recoveryUsesNumber = 3;
- bool isFireBallUsed = false;
- int bossHealth = 200;
- int bossAttack = 10;
- while (playerHealth > 0 && bossHealth > 0)
- {
- Console.WriteLine($"У игрока {playerHealth} здоровья и {playerMana} маны");
- Console.WriteLine($"У босса {bossHealth} здоровья");
- Console.WriteLine("Для продолжения нажмите любую клавишу...");
- Console.ReadKey();
- Console.Clear();
- Console.WriteLine("Выберите действие:");
- Console.WriteLine($"{CommandAttack} - Обычная атака");
- Console.WriteLine($"{CommandFireball} - Огненный шар");
- Console.WriteLine($"{CommandExplosion} - Взрыв");
- Console.WriteLine($"{CommandRecovery} - Восстановить хп и ману");
- playerInput = Console.ReadLine();
- Console.Clear();
- switch (playerInput)
- {
- case CommandAttack:
- playerCurrentAttack = random.Next(playerMinAttack, playerMaxAttack + 1);
- bossHealth -= playerCurrentAttack;
- Console.WriteLine($"Обычная атака наносит {playerCurrentAttack} урона");
- break;
- case CommandFireball:
- if (playerMana >= fireBallManaCost)
- {
- bossHealth -= fireBallAttack;
- playerMana -= fireBallManaCost;
- isFireBallUsed = true;
- Console.WriteLine($"Огненный шар наносит {fireBallAttack} урона");
- }
- else
- {
- Console.WriteLine("Не хватает маны. Пропуск хода");
- }
- break;
- case CommandExplosion:
- if (isFireBallUsed)
- {
- bossHealth -= explosionAttack;
- isFireBallUsed = false;
- Console.WriteLine($"Взрыв наносит {explosionAttack} урона");
- }
- else
- {
- Console.WriteLine("Cперва нужно использовать огненный шар. Пропуск хода");
- }
- break;
- case CommandRecovery:
- if (recoveryUsesNumber > 0)
- {
- playerHealth += healthRecovery;
- if (playerHealth > playerMaxHealth)
- playerHealth = playerMaxHealth;
- playerMana += manaRecovery;
- if (playerMana > playerMaxMana)
- playerMana = playerMaxMana;
- recoveryUsesNumber--;
- Console.WriteLine($"Вы восстановили хр и ману. Осталось {recoveryUsesNumber} зарядов заклинания");
- }
- else
- {
- Console.WriteLine("Закончились заряды заклинания. Пропуск хода");
- }
- break;
- default:
- Console.WriteLine("Такой команды нет. Пропуск хода");
- break;
- }
- playerHealth -= bossAttack;
- Console.WriteLine($"Босс наносит {bossAttack} урона");
- }
- if (playerHealth <= 0 && bossHealth <= 0)
- Console.WriteLine("Ничья");
- else if (playerHealth <= 0)
- Console.WriteLine("Вы проиграли");
- else if (bossHealth <= 0)
- Console.WriteLine("Вы победили босса");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement