Advertisement
TravaMan

Basic_Task10

Nov 30th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.47 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Basic_Task10
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string username = "TravaMan";
  10.            
  11.             int maxHP = 100;
  12.             int currentHP = 100;
  13.            
  14.             int maxMana = 100;
  15.             int currentMana = 100;
  16.            
  17.             int countHealHP = 20;
  18.            
  19.             string str = "";
  20.             Random rnd = new Random();
  21.            
  22.             while (str != "ESC")
  23.             {
  24.                 Console.WriteLine("Имя: " + username);
  25.                 Console.WriteLine("ХП: " + currentHP + "/" + maxHP);
  26.                 Console.WriteLine("Мана: " + currentMana + "/" + maxMana);
  27.                 Console.WriteLine("Введите команду: ");
  28.                 str = Console.ReadLine();
  29.                 switch (str)
  30.                 {
  31.                     case "Heal":
  32.                         if (currentMana >= countHealHP)
  33.                         {
  34.                             currentMana -= countHealHP;
  35.                             if (currentHP + countHealHP >= maxHP)
  36.                             {
  37.                                 currentHP = maxHP;
  38.                             }
  39.                             else
  40.                             {
  41.                                 currentHP += countHealHP;
  42.                             }
  43.                         }
  44.                         break;
  45.                     case "Fight":
  46.                         if (currentHP > 0)
  47.                         {
  48.                             int damage = rnd.Next(0, 51);
  49.                             Console.WriteLine("Вам нанесли " + damage + " урона");
  50.                             if (currentHP - damage < 0)
  51.                             {
  52.                                 currentHP = 0;
  53.                                 break;
  54.                             }
  55.                             else
  56.                             {
  57.                                 currentHP -= damage;
  58.                             }
  59.                             int addMana = rnd.Next(0, 21);
  60.                             Console.WriteLine("Вы улучшили свой манапул на " + addMana + "ед.");
  61.                             maxMana += addMana;
  62.                         }
  63.                         else
  64.                         {
  65.                             Console.WriteLine("Вы в плохом состоянии. Вы не можете драться");
  66.                         }
  67.                         break;
  68.                     case "Meditate":
  69.                         int regenMana = rnd.Next(1, maxMana / 4);
  70.                         if (maxMana - currentMana <= regenMana)
  71.                         {
  72.                             currentMana = maxMana;
  73.                         }
  74.                         else
  75.                         {
  76.                             currentMana += regenMana;
  77.                         }
  78.                         break;
  79.                     case "SetName":
  80.                         Console.WriteLine("Введите новое имя: ");
  81.                         username = Console.ReadLine();
  82.                         break;
  83.                     case "ESC":
  84.                         break;
  85.                     default:
  86.                         Console.WriteLine("Данной команды нету.");
  87.                         break;
  88.                 }
  89.                 Console.WriteLine();
  90.             }
  91.         }
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement