Advertisement
Rodunskiy

Untitled

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