Advertisement
dragonbs

MuOnline

Feb 18th, 2023
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. internal class Program
  5. {
  6.     static void Main()
  7.     {
  8.         string[] rooms = Console.ReadLine().Split('|');
  9.         int health = 100;
  10.         int bitcoins = 0;
  11.  
  12.  
  13.         for (int i = 0; i < rooms.Length; i++)
  14.         {
  15.             string[] thisInput = rooms[i].Split(' ');
  16.             string command = thisInput[0];
  17.             int number = int.Parse(thisInput[1]);
  18.  
  19.             switch (command)
  20.             {
  21.                 case "potion":
  22.                     int healedFor = number;
  23.                     if (health + number > 100) healedFor = 100 - health;
  24.                     health += healedFor;
  25.                     Console.WriteLine($"You healed for {healedFor} hp.");
  26.                     Console.WriteLine($"Current health: {health} hp.");
  27.                     break;
  28.                 case "chest":
  29.                     Console.WriteLine($"You found {number} bitcoins.");
  30.                     bitcoins += number;
  31.                     break;
  32.                 default:
  33.                     health -= number;
  34.                     if (health <= 0)
  35.                     {
  36.                         Console.WriteLine($"You died! Killed by {command}.");
  37.                         Console.WriteLine($"Best room: {i + 1}");
  38.                         return;
  39.                     }
  40.                     Console.WriteLine($"You slayed {command}.");
  41.                     break;
  42.             }
  43.         }
  44.         Console.WriteLine("You've made it!");
  45.         Console.WriteLine($"Bitcoins: {bitcoins}");
  46.         Console.WriteLine($"Health: {health}");
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement