Advertisement
AreWe

MuOnline C#

Jul 1st, 2020
1,031
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp29
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int health = 100, bitcoins = 0;
  10.             string[] rooms = Console.ReadLine().Split('|');
  11.             for(int i=0; i<rooms.Length; i++)
  12.             {
  13.                 string[] cmdargs = rooms[i].Split(' ');
  14.                 if(cmdargs[0] == "chest")
  15.                 {
  16.                     Console.WriteLine($"You found {cmdargs[1]} bitcoins.");
  17.                     bitcoins += int.Parse(cmdargs[1]);
  18.                 }
  19.                 else if(cmdargs[0] == "potion")
  20.                 {
  21.                     int heal = int.Parse(cmdargs[1]);
  22.                     int newHealth = health + heal;
  23.                     if (newHealth > 100) newHealth = 100;
  24.                     Console.WriteLine($"You healed for {newHealth - health} hp.");
  25.                     health = newHealth;
  26.                     Console.WriteLine($"Current health: {health} hp.");
  27.                 }
  28.                 else // monster
  29.                 {
  30.                     int damage = int.Parse(cmdargs[1]);
  31.                     health -= damage;
  32.                     if (health > 0) Console.WriteLine($"You slayed {cmdargs[0]}.");
  33.                     else
  34.                     {
  35.                         Console.WriteLine($"You died! Killed by {cmdargs[0]}.\nBest room: {i + 1}");
  36.                         break;
  37.                     }
  38.                 }
  39.             }
  40.  
  41.             if(health > 0) Console.WriteLine($"You've made it!\nBitcoins: {bitcoins}\nHealth: {health}");
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement