Advertisement
Fox_McCloud77

CSLight_Boss_Fight_HW

Feb 15th, 2020
857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CSLight_Boss_Fight_HW
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.OutputEncoding = Encoding.UTF8;
  14.  
  15.             Random rand = new Random();
  16.             string userName;
  17.             string bossName = "Арктур";
  18.             float userHealth = 1000;
  19.             float bossHealth = 1000;
  20.             int bossDamage = rand.Next(50, 101);
  21.             string readyForBattle;
  22.             string attack1 = "Рашамон";
  23.             string attack2 = "Хуганзакура";
  24.             string attack3 = "Межпространственный разлом";
  25.             string userInput;
  26.             bool darkSpirit = false;
  27.             bool userHeal = false;
  28.  
  29.             Console.ForegroundColor = ConsoleColor.White;
  30.             Console.WriteLine($"Приветствую тебя, Теневой Маг! Ты готов сразиться с нашим чемпионом по имени {bossName}?\n");
  31.             Console.Write("Но для начала представься: ");
  32.             userName = Console.ReadLine();
  33.  
  34.             Console.ForegroundColor = ConsoleColor.Magenta;
  35.             Console.WriteLine($"\nПоприветсвуйте нашего нового участника по имени {userName}! Возможно, наш новый чемпион!");
  36.             Console.ForegroundColor = ConsoleColor.White;
  37.             Console.WriteLine($"\nЯ слышал что ты умеешь делать такие вещи: ");
  38.             Console.ForegroundColor = ConsoleColor.Cyan;
  39.             Console.WriteLine($"\n1 - {attack1} - Призыв Теневого Духа (Отнимает 100 ед. хп юзеру).");
  40.             Console.WriteLine($"2 - {attack2} - Можно использовать только после призыва Теневого Духа (Наносит 100 ед. урона противнику).");
  41.             Console.WriteLine($"3 - {attack3} (Восстанавливает 250 ед. хп юзеру, при этом защищает от 1-ой атаки противника)");
  42.             Console.ForegroundColor = ConsoleColor.White;
  43.  
  44.             Console.Write($"\nНу что, {userName}. Ты готов сразиться с {bossName + "ом"} (Yes/No): ");
  45.             readyForBattle = Console.ReadLine();
  46.  
  47.             if (readyForBattle == "No")
  48.             {
  49.                 Console.ForegroundColor = ConsoleColor.Red;
  50.                 Console.WriteLine($"\nЧтож, {userName}, очень жаль... Тогда прощай...");
  51.             }
  52.             else if (readyForBattle == "Yes")
  53.             {
  54.                 Console.ForegroundColor = ConsoleColor.Green;
  55.                 Console.WriteLine($"\nОтлично, {userName}! Да начнется битва!\n");
  56.                 Console.ForegroundColor = ConsoleColor.White;
  57.             }
  58.             else
  59.             {
  60.                 Console.ForegroundColor = ConsoleColor.DarkYellow;
  61.                 Console.WriteLine("\nЧто то не так... Приходи в следующий раз!");
  62.             }
  63.  
  64.             while (readyForBattle == "Yes")
  65.             {
  66.                 Console.ForegroundColor = ConsoleColor.White;
  67.  
  68.                 if (userHealth > 0 && bossHealth > 0)
  69.                 {
  70.                     Console.WriteLine($"{userName} - {userHealth} хп");
  71.                     Console.WriteLine($"{bossName} - {bossHealth} хп");
  72.                 }
  73.                 else if (userHealth <= 0)
  74.                 {
  75.                     Console.ForegroundColor = ConsoleColor.Red;
  76.                     Console.WriteLine($"Увы, но {userName} пал от руки {bossName + "а"}.");
  77.                     break;
  78.                 }
  79.                 else if (bossHealth <= 0)
  80.                 {
  81.                     Console.ForegroundColor = ConsoleColor.Green;
  82.                     Console.WriteLine($"Поздравляю, {userName}! Ты смог одолеть {bossName + "а"} своей Темной Магией!");
  83.                     break;
  84.                 }
  85.                 else if (userHealth <= 0 && bossHealth <= 0)
  86.                 {
  87.                     Console.ForegroundColor = ConsoleColor.Yellow;
  88.                     Console.WriteLine("Ничья!");
  89.                     break;
  90.                 }
  91.  
  92.                 Console.Write($"\nХодит {userName}: ");
  93.                 userInput = Console.ReadLine();
  94.  
  95.                 if (userInput == "1")
  96.                 {
  97.                     userHealth -= 100;
  98.                     darkSpirit = true;
  99.                     userHeal = true;
  100.                     Console.ForegroundColor = ConsoleColor.DarkCyan;
  101.                     Console.WriteLine("\nВы призвали Теневого Духа.\n");
  102.                     Console.ForegroundColor = ConsoleColor.White;
  103.                 }
  104.  
  105.                 switch (userInput)
  106.                 {
  107.                     case "2":
  108.                         userHeal = true;
  109.  
  110.                         if (darkSpirit == true)
  111.                         {
  112.                             bossHealth -= 100;
  113.                             darkSpirit = false;
  114.                             Console.ForegroundColor = ConsoleColor.DarkCyan;
  115.                             Console.WriteLine("\nТемный Дух нанес 100 уд. урона противнику.\n");
  116.                             Console.ForegroundColor = ConsoleColor.White;
  117.                         }
  118.                         else
  119.                         {
  120.                             Console.ForegroundColor = ConsoleColor.DarkYellow;
  121.                             Console.WriteLine("\nСначала призовите Теневого Духа!\n");
  122.                             Console.ForegroundColor = ConsoleColor.White;
  123.                         }
  124.  
  125.                         break;
  126.                     case "3":
  127.  
  128.                         if (userHeal == true)
  129.                         {
  130.                             if (userHealth >= 1000)
  131.                             {
  132.                                 Console.ForegroundColor = ConsoleColor.DarkYellow;
  133.                                 Console.WriteLine("\nУ вас и так достаточно здоровья.\n");
  134.                                 Console.ForegroundColor = ConsoleColor.White;
  135.                             }
  136.                             else
  137.                             {
  138.                                 userHealth += 250;
  139.                                 Console.ForegroundColor = ConsoleColor.DarkGreen;
  140.                                 Console.WriteLine($"\nВаш запас здоровья полопнен!\n");
  141.                                 Console.ForegroundColor = ConsoleColor.White;
  142.                             }
  143.  
  144.                             userHeal = false;
  145.                         }
  146.                         else
  147.                         {
  148.                             Console.ForegroundColor = ConsoleColor.DarkYellow;
  149.                             Console.WriteLine("\nНевозможно выполнить действие!\n");
  150.                             Console.ForegroundColor = ConsoleColor.White;
  151.                         }
  152.  
  153.                         break;
  154.                 }
  155.  
  156.                 Console.Write($"Ходит {bossName}: ");
  157.                 userHealth -= bossDamage;
  158.                 Console.ForegroundColor = ConsoleColor.DarkRed;
  159.                 Console.WriteLine($"\n\n{bossName} нанес {bossDamage} урона!\n");
  160.                 Console.ForegroundColor = ConsoleColor.White;
  161.             }
  162.             Console.ReadKey();
  163.         }
  164.     }
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement