Advertisement
nevenailievaa

MuOnline

Feb 16th, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. int health = 100;
  2. int bitcoins = 0;
  3. List<string> rooms = Console.ReadLine()
  4.                  .Split('|')
  5.                  .ToList();
  6.  
  7. for (int i = 0; i<rooms.Count; i++)
  8. {
  9.     string[] ROOM = rooms[i].Split().ToArray();
  10.     int number = int.Parse(ROOM[1]);
  11.     string command = ROOM[0];
  12.     int amount = 0;
  13.     if (command == "potion")
  14.     {
  15.         int previousHealth = health;
  16.         health += number;
  17.         if (health > 100)
  18.         {
  19.             amount = Math.Abs(100-previousHealth);
  20.  
  21.             Console.WriteLine($"You healed for {amount} hp.");
  22.             health = 100;
  23.             Console.WriteLine($"Current health: {health} hp.");
  24.         }
  25.         else if (health <= 100)
  26.         {
  27.             Console.WriteLine($"You healed for {number} hp.");
  28.             Console.WriteLine($"Current health: {health} hp.");
  29.         }
  30.     }
  31.     else if (command == "chest")
  32.     {
  33.         bitcoins+=number;
  34.         Console.WriteLine($"You found {number} bitcoins.");
  35.     }
  36.     else
  37.     {
  38.         health-=number;
  39.         if (health >0)
  40.         {
  41.             Console.WriteLine($"You slayed {command}.");
  42.  
  43.         }
  44.         else if (health <=0)
  45.         {
  46.             Console.WriteLine($"You died! Killed by {command}.");
  47.             Console.WriteLine($"Best room: {i+1}");
  48.             return;
  49.  
  50.         }
  51.     }
  52. }
  53. Console.WriteLine("You've made it!");
  54. Console.WriteLine($"Bitcoins: {bitcoins}");
  55. Console.WriteLine($"Health: {health}");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement