Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CSLight
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- const string CommandPhysicAttack = "1";
- const string CommandMagicAttack = "2";
- const string CommandExplosionAttack = "3";
- const string CommandCure = "4";
- int bossHealth = 100;
- int bossMinAttack = 5;
- int bossMaxAttack = 25;
- int playerMaxHealth = 100;
- int playerCurrentHealth = playerMaxHealth;
- int playerMaxMana = 100;
- int playerCurrentMana = playerMaxMana;
- int playerPhysicAttack = 10;
- int playerMagicAttack = 20;
- int playerMagicAttackManaCost = 5;
- int playerExplosionAttack = 30;
- bool isExplosionEnable = false;
- int playerCureHealth = 25;
- int playerCureMana = 20;
- int playerHealRestCount = 5;
- bool isBattleInProgress = true;
- while (isBattleInProgress)
- {
- Console.WriteLine($"У вас {playerCurrentHealth} жизней и {playerCurrentMana} маны \n У босса {bossHealth} жизней");
- Console.WriteLine($"Выберите действие" +
- $"\n {CommandPhysicAttack} - Физическая атака" +
- $"\n {CommandMagicAttack} - Магическая атака" +
- $"\n {CommandExplosionAttack} - Взрыв" +
- $"\n {CommandCure} - Лечение");
- string userInput = Console.ReadLine();
- switch (userInput)
- {
- case CommandPhysicAttack:
- bossHealth -= playerPhysicAttack;
- Console.WriteLine($"Вы нанесли {playerPhysicAttack} урона");
- break;
- case CommandMagicAttack:
- if (playerMaxMana >= playerMagicAttackManaCost)
- {
- bossHealth -= playerMagicAttack;
- playerMaxMana -= playerMagicAttackManaCost;
- isExplosionEnable = true;
- Console.WriteLine($"Вы нанесли {playerMagicAttack} урона");
- }
- else
- {
- Console.WriteLine($"Не хватает маны");
- }
- break;
- case CommandExplosionAttack:
- if (isExplosionEnable)
- {
- bossHealth -= playerExplosionAttack;
- isExplosionEnable = false;
- Console.WriteLine($"Вы нанесли {playerExplosionAttack} урона");
- }
- else
- {
- Console.WriteLine($"Способность не доступна");
- }
- break;
- case CommandCure:
- if(playerHealRestCount > 0)
- {
- playerCurrentHealth += playerCureHealth;
- if(playerCurrentHealth > playerMaxHealth)
- {
- playerCurrentHealth = playerMaxHealth;
- }
- playerCurrentMana += playerCureMana;
- if(playerCureMana > playerMaxMana)
- {
- playerCurrentMana = playerMaxMana;
- }
- Console.WriteLine($"Вы восстановили {playerCureHealth} здоровья и {playerCureMana} маны");
- }
- else
- {
- Console.WriteLine($"Невозможно использовать");
- }
- break;
- default:
- Console.WriteLine($"Вы пропускатет ход");
- break;
- }
- int bossAttack = random.Next(bossMinAttack, bossMaxAttack);
- playerCurrentHealth -= bossAttack;
- Console.WriteLine($"Босс наносит {bossAttack} урона");
- if(bossHealth <= 0 || playerCurrentHealth <= 0)
- {
- isBattleInProgress = false;
- }
- }
- if (bossHealth <= 0 && playerCurrentHealth > 0)
- {
- Console.WriteLine($"Босс повержен");
- }
- else if (bossHealth > 0 && playerCurrentHealth <= 0)
- {
- Console.WriteLine($"Игрок повержен");
- }
- else if (bossHealth <= 0 && playerCurrentHealth <= 0)
- {
- Console.WriteLine($"Ничья");
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement