Vapio

task13

Apr 2nd, 2021 (edited)
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.18 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. public class Program
  5. {
  6.     public static void Main()
  7.     {
  8.         int percent = 100;
  9.  
  10.         int heroHealth = 400;
  11.         int heroDamage = 150;
  12.         int heroDamagePercent = 70;
  13.         int heroChargeDamage = 225;
  14.         int heroChargeDamagePercent = 57;
  15.         int heroHealthHeal = 100;
  16.         int heroDamageSetup;
  17.         int heroDamagePercentSetup;
  18.         bool isHeroRun = false;
  19.         bool isHeroErrorType = false;
  20.         bool isHeroCharge = false;
  21.  
  22.         int bossHealth = 435;
  23.         int bossDamage = 125;
  24.         int bossDamagePercent = 90;
  25.         int bossDamagePercentError = 100;
  26.         int bossDecreaseDamagePercent = 60;
  27.         int bossDamagePercentSetup;
  28.         bool isBossDecreaseDamage = false;
  29.  
  30.         bool isRun = true;
  31.  
  32.         ConsoleColor winColor = ConsoleColor.DarkYellow;
  33.         ConsoleColor defeatColor = ConsoleColor.DarkRed;
  34.         StringBuilder turnsLog = new StringBuilder();
  35.  
  36.         Random randomDamage = new Random();
  37.         int randomNumber;
  38.  
  39.         int damage;
  40.         int turn = 1;
  41.         int bossDamagePrevious = 0;
  42.         int heroDamagePrevious = 0;
  43.         uint chooseInput;
  44.  
  45.         while (isRun)
  46.         {
  47.             Console.Clear();
  48.             Console.SetCursorPosition(0, 0);
  49.  
  50.             Console.WriteLine("Turn : " + turn);
  51.  
  52.             Console.Write(" " + String.Format("{0,19}", " ").Replace(" ", "_") + " \n");
  53.             Console.Write("| Boss Health : " + String.Format("{0,3}", bossHealth) + " |\n");
  54.             Console.Write("| Hero Health : " + String.Format("{0,3}", heroHealth) + " |\n");
  55.             Console.Write("|" + String.Format("{0,19}", " ").Replace(" ", "_") + "|\n");
  56.  
  57.             Console.WriteLine(turnsLog);
  58.             turnsLog.Clear();
  59.  
  60.             Console.WriteLine("\nWhat spell you want to use : ");
  61.             Console.WriteLine("1. ABOBA\n" +
  62.                               "2. ZA WARDO\n" +
  63.                               "3. EPITAPHIA\n" +
  64.                               "4. OVERDRIVE");
  65.             chooseInput = Convert.ToUInt32(Console.ReadLine());
  66.  
  67.             if (isHeroCharge)
  68.             {
  69.                 heroDamageSetup = heroChargeDamage;
  70.                 heroDamagePercentSetup = heroChargeDamagePercent;
  71.                 isBossDecreaseDamage = true;
  72.                 isHeroCharge = false;
  73.             }
  74.             else
  75.             {
  76.                 heroDamageSetup = heroDamage;
  77.                 heroDamagePercentSetup = heroDamagePercent;
  78.             }
  79.  
  80.             if (isHeroRun)
  81.             {
  82.                 isHeroRun = false;
  83.             }
  84.  
  85.             switch (chooseInput)
  86.             {
  87.                 case 1:
  88.                     turnsLog.Append("You used spell ABOBA .\n");
  89.                     isHeroCharge = true;
  90.                     heroDamagePrevious = 0;
  91.                     turnsLog.Append("You charge attack and skip turn.\n");
  92.                     break;
  93.                 case 2:
  94.                     turnsLog.Append("You used spell ZA WARDO .\n");
  95.                     isHeroRun = true;
  96.                     heroHealth += heroHealthHeal;
  97.                     heroDamagePrevious = 0;
  98.                     bossDamagePrevious = -heroHealthHeal;
  99.                     turnsLog.Append("You run away on one turn and heal " + heroHealthHeal + "HP.\n");
  100.                     break;
  101.                 case 3:
  102.                     turnsLog.Append("You used spell EPITATHIA .\n");
  103.  
  104.                     if (turn == 1)
  105.                         turn = 0;
  106.                     else
  107.                         turn -= 2;
  108.  
  109.                     bossHealth += heroDamagePrevious;
  110.                     heroHealth += bossDamagePrevious;
  111.                     heroDamagePrevious = 0;
  112.                     bossDamagePrevious = 0;
  113.                     isHeroRun = true;
  114.                     turnsLog.Append("You turned back a turn.\n");
  115.                     break;
  116.                 case 4:
  117.                     turnsLog.Append("You used spell OVERDRIVE .\n");
  118.                     randomNumber = randomDamage.Next(0, heroDamagePercentSetup);
  119.                     damage = heroDamageSetup * randomNumber / percent;
  120.                     bossHealth -= damage;
  121.                     heroDamagePrevious = damage;
  122.                     turnsLog.Append("You atack and decrease: " + damage + "HP.\n");
  123.                     break;
  124.                 default:
  125.                     isHeroErrorType = true;
  126.                     turnsLog.Append("You write wrong spell\n");
  127.                     break;
  128.             }
  129.  
  130.             if (isHeroRun != true)
  131.             {
  132.                 if (isHeroErrorType)
  133.                 {
  134.                     isHeroErrorType = false;
  135.                     bossDamagePercentSetup = bossDamagePercentError;
  136.                     randomNumber = bossDamagePercentSetup;
  137.                 }
  138.                 else if (isBossDecreaseDamage)
  139.                 {
  140.                     bossDamagePercentSetup = bossDecreaseDamagePercent;
  141.                     randomNumber = randomDamage.Next(0, bossDamagePercentSetup);
  142.                     isBossDecreaseDamage = false;
  143.                 }
  144.                 else
  145.                 {
  146.                     bossDamagePercentSetup = bossDamagePercent;
  147.                     randomNumber = randomDamage.Next(0, bossDamagePercentSetup);
  148.                 }
  149.  
  150.                 damage = bossDamage * randomNumber / percent;
  151.                 heroHealth -= damage;
  152.                 bossDamagePrevious = damage;
  153.                 turnsLog.Append("Boss attack and decrease : " + damage + "HP.\n");
  154.             }
  155.  
  156.             if (bossHealth <= 0)
  157.             {
  158.                 isRun = false;
  159.  
  160.                 Console.Clear();
  161.                 Console.SetCursorPosition(0, 0);
  162.                 Console.ForegroundColor = winColor;
  163.                 Console.WriteLine("!!!Congratulation you defeat boss!!!");
  164.             }
  165.             else if (heroHealth <= 0)
  166.             {
  167.                 isRun = false;
  168.  
  169.                 Console.Clear();
  170.                 Console.SetCursorPosition(0, 0);
  171.                 Console.ForegroundColor = defeatColor;
  172.                 Console.WriteLine("  YOU DEAD  ");
  173.             }
  174.  
  175.             ++turn;
  176.         }
  177.     }
  178. }
Add Comment
Please, Sign In to add comment