Advertisement
Rodunskiy

Untitled

May 2nd, 2023
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.82 KB | None | 0 0
  1. const string SwordStrikeCommand = "1";
  2. const string CrossbowShotCommand = "2";
  3. const string SwordStrikeFromShadowsCommand = "3";
  4. const string HideInShadowsAndHealthingCommand = "4";
  5.  
  6. Random random = new Random();
  7.  
  8. int swordStrike = 100;
  9. int crossbowShotAttackMin = 50;
  10. int crossbowShotAttackMax = 150;
  11. int swordStrikeFromShadows = 300;
  12. int hideInShadowsAndHealthing = 100;
  13. int heroLife = 400;
  14. int bossLife = 1000;
  15. int bossAttackMin = 50;
  16. int bossAttackMax = 200;
  17. bool isWorkingHideInShadows = false;
  18. string typeAttack;
  19.  
  20. while (heroLife > 0 && bossLife > 0)
  21. {
  22.     Console.Clear();
  23.     Console.WriteLine($"Жизни героя:{heroLife}\nЖизни босса:{bossLife}\nВыберите действие:\n{SwordStrikeCommand} <-- удар мечем.\n{CrossbowShotCommand} <-- выстрел из арбалета." +
  24.         $"\n{SwordStrikeFromShadowsCommand} <-- удар мечем из тени.\n{HideInShadowsAndHealthingCommand} <-- спрятаться в тени.");
  25.     typeAttack = Console.ReadLine();
  26.  
  27.     switch (typeAttack)
  28.     {
  29.         case SwordStrikeCommand:
  30.             Console.WriteLine($"Удар мечем!");
  31.             bossLife -= swordStrike;
  32.             heroLife -= random.Next(bossAttackMin, bossAttackMax);
  33.             Console.ReadKey();
  34.             break;
  35.  
  36.         case CrossbowShotCommand:
  37.             Console.WriteLine($"Выстрел из арбалета!");
  38.             bossLife -= random.Next(crossbowShotAttackMin,crossbowShotAttackMax);
  39.             heroLife -= random.Next(bossAttackMin, bossAttackMax);
  40.             Console.ReadKey();
  41.             break;
  42.  
  43.         case SwordStrikeFromShadowsCommand:
  44.             if (isWorkingHideInShadows == true)
  45.             {
  46.                 Console.WriteLine($"Удар мечем из тени!");
  47.                 bossLife -= swordStrikeFromShadows;
  48.                 heroLife -= random.Next(bossAttackMin, bossAttackMax);
  49.                 isWorkingHideInShadows = false;
  50.                 Console.ReadKey();
  51.             }
  52.             else
  53.             {
  54.                 Console.WriteLine($"Атака не сработала!");
  55.                 heroLife -= random.Next(bossAttackMin, bossAttackMax);
  56.                 Console.ReadKey();
  57.             }
  58.             break;
  59.  
  60.         case HideInShadowsAndHealthingCommand:
  61.             Console.WriteLine($"Герой спрятался в тени и восстановил 100 жизней!");
  62.             heroLife += hideInShadowsAndHealthing;
  63.             isWorkingHideInShadows = true;
  64.             Console.ReadKey();
  65.             break;
  66.     }
  67. }
  68.  
  69. if (bossLife <= 0 && heroLife <= 0)
  70. {
  71.     Console.WriteLine("Ничья!");
  72. }
  73. else if (bossLife > 0)
  74. {
  75.     Console.WriteLine("Босс побеждает!");
  76. }
  77. else if (heroLife > 0)
  78. {
  79.     Console.WriteLine("Герой побеждает!");
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement