Advertisement
holllowknight

ДЗ: Бой с боссом

Mar 11th, 2020 (edited)
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.89 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Boss
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             const string SpellCardamon = "кардамон";
  10.             const string SpellCurkuma = "куркума";
  11.             const string SpellSunely = "сунели";
  12.             const string SpellPaprika = "паприка";
  13.  
  14.             int DurationWetLand = 3;
  15.             int FlashDamage = 200;
  16.             int KappaDamage = 300;
  17.             int HealthRestore = 50;
  18.             int bossAttackMin = 100;
  19.             int bossAttackMax = 200;
  20.             int bossAttack = 0;
  21.             int bossHealth = 1000;
  22.             int heroHealth = 800;
  23.             int heroAttack;
  24.             int wetLandCount = 0;
  25.             bool shieldPlaced = false;
  26.             bool shieldRecharging = false;
  27.             bool isSpellWrong = true;
  28.             string heroSpell;
  29.             Random random = new Random();
  30.  
  31.             Console.WriteLine($"{SpellCardamon} - проливает дождь над врагом, земля под ногами цели становится сырой на {DurationWetLand - 1} хода\n" +
  32.                               $"{SpellCurkuma} - удар молний - по всем бойцам {FlashDamage}хр, стоящим на сырой земле - двойной урон\n" +
  33.                               $"{SpellSunely} - призыв каппы (только в сырую погоду, в течение хода после дождя) наносит урон врагу {KappaDamage}хр\n" +
  34.                               $"{SpellPaprika} - устанавливает огненный щит - неуязвимость в течение хода, восстановление здоровья на {HealthRestore}хр (время перезарядки - 1 ход)");
  35.             Console.WriteLine($"Герой: {heroHealth}. Босс: {bossHealth}.");
  36.  
  37.             while ((heroHealth > 0) && (bossHealth > 0))
  38.             {
  39.                 if (wetLandCount != 0)
  40.                 {
  41.                     wetLandCount--;
  42.                 }
  43.  
  44.                 if (shieldRecharging)
  45.                 {
  46.                     shieldRecharging = false;
  47.                 }
  48.  
  49.                 if (shieldPlaced)
  50.                 {
  51.                     shieldPlaced = false;
  52.                     shieldRecharging = true;
  53.                 }
  54.  
  55.                 heroAttack = 0;
  56.                 bossAttack = 0;
  57.                 isSpellWrong = true;
  58.  
  59.                 while (isSpellWrong)
  60.                 {
  61.                     Console.Write("Введите заклинание: ");
  62.                     heroSpell = Console.ReadLine();
  63.  
  64.                     switch (heroSpell)
  65.                     {
  66.                         case SpellCardamon:
  67.                             wetLandCount = DurationWetLand;
  68.                             isSpellWrong = false;
  69.                             break;
  70.  
  71.                         case SpellCurkuma:
  72.                             heroAttack += FlashDamage;
  73.                             bossAttack += FlashDamage;
  74.                             isSpellWrong = false;
  75.  
  76.                             if (wetLandCount != 0)
  77.                                 heroAttack += FlashDamage;
  78.                             break;
  79.  
  80.                         case SpellSunely:
  81.                             if (wetLandCount == 0)
  82.                             {
  83.                                 break;
  84.                             }
  85.  
  86.                             heroAttack += KappaDamage;
  87.                             isSpellWrong = false;
  88.                             break;
  89.  
  90.                         case SpellPaprika:
  91.                             if (shieldRecharging)
  92.                             {
  93.                                 break;
  94.                             }
  95.  
  96.                             shieldPlaced = true;
  97.                             heroHealth += HealthRestore;
  98.                             isSpellWrong = false;
  99.                             break;
  100.                     }
  101.                 }
  102.  
  103.                 bossAttack += random.Next(bossAttackMin, bossAttackMax);
  104.  
  105.                 if (shieldPlaced)
  106.                     bossAttack = 0;
  107.  
  108.                 heroHealth -= bossAttack;
  109.                 bossHealth -= heroAttack;
  110.                 Console.WriteLine($"Герой: {heroHealth}. Босс: {bossHealth}.");
  111.             }
  112.  
  113.             if ((heroHealth <= 0) && (bossHealth <= 0))
  114.             {
  115.                 Console.WriteLine("Герой погиб, но защитил мир ценой своей жизни!");
  116.             }
  117.             else if (heroHealth <= 0)
  118.             {
  119.                 Console.WriteLine("Герой погиб, Владыка демонов захватил мир!");
  120.             }
  121.             else
  122.             {
  123.                 Console.WriteLine("Владыка демонов повержен!");
  124.             }
  125.         }
  126.     }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement