Advertisement
MaoChessy

Task 14 -fixed

Oct 26th, 2020 (edited)
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace C_sharp_Light
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Random rand = new Random();
  10.  
  11.             int playerHp = rand.Next(185, 215);
  12.             int playerManaMax = rand.Next(80, 180);
  13.             int playerMana = playerManaMax;
  14.             int playerForce = rand.Next(1, 11);
  15.  
  16.             int bossHp = rand.Next(185, 215);
  17.             int bossManaMax = rand.Next(80, 180);
  18.             int bossMana = bossManaMax;
  19.             int bossForce = rand.Next(1, 11);
  20.             //Fire Ball, Regain, FireStorm, Skip, ForceUp, IceSpike
  21.  
  22.             int manaFireBall = 10;
  23.             int damageFireBall = 18;
  24.  
  25.             int manaRegain = 35;
  26.             int recoveryOfRegain = 40;
  27.  
  28.             int manaFireStorm = 40;
  29.             int damageFireStorm = 30;
  30.             int requiredForceFireStorm = 7;
  31.  
  32.             int recoveryManeOfSkip = 40;
  33.  
  34.             int manaForceUp = 10;
  35.             int improveForce = 1;
  36.  
  37.             int manaIceSpike = 30;
  38.             int damageIceSpike = 45;
  39.             int requiredForceIceSpike = 5;
  40.  
  41.             int damage;
  42.             int recoveryHp;
  43.             while (playerHp > 0 && bossHp > 0)
  44.             {
  45.                 Console.Clear();
  46.  
  47.                 // Описание заклинаний игрока
  48.                 Console.SetCursorPosition(0, 15);
  49.                 Console.ForegroundColor = ConsoleColor.Red;
  50.                 Console.WriteLine($"Заклинания:\n" +
  51.                     $"1 - Огненный шар - {manaFireBall} манны; урон базовый {damageFireBall}\n" +
  52.                     $"2 - Восстановление - {manaRegain} манны; восстановление {recoveryOfRegain}\n" +
  53.                     $"3 - Огненный шторм (требования: сила >= {requiredForceFireStorm}) - {manaFireStorm} манны; базовый урон {damageFireStorm} (всем)\n" +
  54.                     $"4 - пропуск хода - восстановление манны {recoveryManeOfSkip} +- 5\n" +
  55.                     $"5 - Заклинание силы - {manaForceUp} манны; +{improveForce} силы \n" +
  56.                     $"6 - Шипы из льда (требования: сила >= {requiredForceIceSpike}) - манны{manaIceSpike}; Базовый урон {damageIceSpike}");
  57.  
  58.                 // Вывод информации о боссе и о игроке
  59.                 Console.ForegroundColor = ConsoleColor.Blue;
  60.                 {
  61.                     Console.SetCursorPosition(0, 0);
  62.                     Console.Write($"Здоровье игрока = {playerHp}");
  63.                     Console.SetCursorPosition(28, 0);
  64.                     Console.Write($"Здоровье Ктулху = {bossHp}");
  65.                 }
  66.                 {
  67.                     Console.SetCursorPosition(0, 1);
  68.                     Console.Write($"Манна игрока = {playerMana}");
  69.                     Console.SetCursorPosition(28, 1);
  70.                     Console.Write($"Манна Ктулху = {bossMana}");
  71.                 }
  72.                 {
  73.                     Console.SetCursorPosition(0, 2);
  74.                     Console.Write($"Сила игрока = {playerForce}");
  75.                     Console.SetCursorPosition(28, 2);
  76.                     Console.Write($"Сила Ктулху = {bossForce}");
  77.                 }
  78.  
  79.                 // Ход игрока
  80.                 Console.ForegroundColor = ConsoleColor.White;
  81.                 Console.Write("\n\nВаш ход. Какое заклинание вы выберите? - ");
  82.                 Console.ForegroundColor = ConsoleColor.Green;
  83.                 switch (Convert.ToInt32(Console.ReadLine()))
  84.                 {
  85.                     case 1:
  86.                         if ((playerMana - manaFireBall) >= 0)
  87.                         {
  88.                             playerMana -= manaFireBall;
  89.                             damage = damageFireBall + rand.Next(playerForce / 2 + playerForce);
  90.                             bossHp -= damage;
  91.                             Console.WriteLine($"Ваш огненный шар нанос урон в {damage} единиц");
  92.                         }
  93.                         else
  94.                         {
  95.                             Console.WriteLine("У вас недостаточно манны. Пропускайте ход");
  96.                         }
  97.                         break;
  98.                     case 2:
  99.                         if ((playerMana - manaRegain) >= 0)
  100.                         {
  101.                             recoveryHp = recoveryOfRegain;
  102.                             playerHp += recoveryHp;
  103.                             playerMana -= manaRegain;
  104.                             Console.WriteLine($"Вы восстанавливайте себе {recoveryHp} здоровья");
  105.                         }
  106.                         else
  107.                         {
  108.                             Console.WriteLine("У вас недостаточно манны. Пропускайте ход");
  109.                         }
  110.                         break;
  111.                     case 3:
  112.                         if (playerForce >= requiredForceFireStorm)
  113.                         {
  114.                             if ((playerMana - manaFireStorm) >= 0)
  115.                             {
  116.                                 playerMana -= manaFireStorm;
  117.                                 damage = damageFireStorm + rand.Next(playerForce * 3);
  118.                                 bossHp -= damage;
  119.                                 playerHp -= damage;
  120.                                 Console.WriteLine($"Ваш огненный шторм нанос урон в {damage} единиц всем");
  121.                             }
  122.                             else
  123.                             {
  124.                                 Console.WriteLine("У вас недостаточно манны. Пропускайте ход");
  125.                             }
  126.                         }
  127.                         else
  128.                         {
  129.                             Console.WriteLine("У вас недостаточно силы, вы пропускайте ход");
  130.                         }
  131.                         break;
  132.                     case 4:
  133.                         int recoveryMana = rand.Next(recoveryManeOfSkip - 5, recoveryManeOfSkip + 6);
  134.                         Console.WriteLine($"Вы отдыхайте и восстанавливайте себе {recoveryMana} манны");
  135.                         playerMana += recoveryMana;
  136.                         if (playerMana > playerManaMax)
  137.                             playerMana = playerManaMax;
  138.                         break;
  139.                     case 5:
  140.                         if ((playerMana - manaForceUp) >= 0)
  141.                         {
  142.                             playerForce += improveForce;
  143.                             playerMana -= manaForceUp;
  144.                             Console.WriteLine($"Вы поднимайте свою силу на 1");
  145.                         }
  146.                         else
  147.                         {
  148.                             Console.WriteLine("У вас недостаточно манны, вы пропускайте ход");
  149.                         }
  150.                         break;
  151.                     case 6:
  152.                         if (playerForce >= requiredForceIceSpike)
  153.                         {
  154.                             if ((playerMana - manaIceSpike) >= 0)
  155.                             {
  156.                                 playerMana -= manaIceSpike;
  157.                                 damage = damageIceSpike + rand.Next(playerForce / 2 + playerForce);
  158.                                 bossHp -= damage;
  159.                                 Console.WriteLine($"Ваши шипы наносят {damage} ктухлу");
  160.                             }
  161.                             else
  162.                             {
  163.                                 Console.WriteLine("У вас недостаточно манны, вы пропускайте ход");
  164.                             }
  165.                         }
  166.                         else
  167.                         {
  168.                             Console.WriteLine("У вас недостаточно силы, вы пропускайте ход");
  169.                         }
  170.                         break;
  171.                 }
  172.  
  173.                 // Ход ктулху
  174.                 Console.WriteLine();
  175.                 Console.ForegroundColor = ConsoleColor.White;
  176.                 Console.Write("Ктулху выбирает - ");
  177.                 if (bossMana >= 20)
  178.                 {
  179.  
  180.                     switch (rand.Next(0, 4))
  181.                     {
  182.                         case 0:
  183.                             damage = 15 + rand.Next(-bossForce / 2, bossForce);
  184.                             Console.WriteLine("Удар щупальцем - 15 базовый урон");
  185.                             playerHp -= damage;
  186.                             Console.WriteLine($"Ктулху нанес урон в {damage} единиц.");
  187.                             break;
  188.                         case 1:
  189.                             Console.WriteLine("Проклятие утраты силы (постоянное)");
  190.                             Console.WriteLine($"Ктухлу понизил вашу силу на 1");
  191.                             playerForce--;
  192.                             break;
  193.                         case 2:
  194.                             Console.WriteLine("Восстанавливает себя - базовое восстановление 20");
  195.                             recoveryHp = rand.Next(20, 20 + bossForce * 3);
  196.                             bossHp += recoveryHp;
  197.                             Console.WriteLine($"Ктулху восстановил себе здоровье на {recoveryHp} ");
  198.                             break;
  199.                         case 3:
  200.                             damage = 45 + rand.Next(-bossForce / 2, bossForce) * 3;
  201.                             Console.WriteLine("Серия ударов щупальцев - 45 базовый урон");
  202.                             playerHp -= damage;
  203.                             Console.WriteLine($"Ктулху нанес урон в {damage} единиц.");
  204.                             break;
  205.                     }
  206.                     bossMana -= 20;
  207.                 }
  208.                 else
  209.                 {
  210.                     int recoveryMana = rand.Next(15, 81);
  211.                     Console.WriteLine($"Ктулху отдыхает и восстанавливает свою манну в {recoveryMana} единиц");
  212.                     bossMana += recoveryMana;
  213.                     if (bossMana > bossManaMax)
  214.                         bossMana = bossManaMax;
  215.                 }
  216.                 Console.ReadKey();
  217.             }
  218.  
  219.             //Вывод результата битвы
  220.             Console.Clear();
  221.             if (playerHp <= 0 && bossHp <= 0)
  222.                 Console.WriteLine("Ничья");
  223.             else if (playerHp <= 0)
  224.                 Console.WriteLine("Вы проиграли");
  225.             else
  226.                 Console.WriteLine("Ктулху проиграл");
  227.  
  228.             Console.ReadKey();
  229.         }
  230.     }
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement