Advertisement
MartinZarev

Untitled

Apr 6th, 2020
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace MuOnline
  6. {
  7.     class Program
  8.     {
  9.         static void Main()
  10.         {
  11.             int health = 100;
  12.             int bitcoins = 0;
  13.             int bestRoom = 0;
  14.  
  15.             List<string> rooms = Console.ReadLine().Split("|").ToList();
  16.                                  
  17.             for (int i = 0; i < rooms.Count(); i++)
  18.             {
  19.                 string[] tokens = rooms[i].Split();
  20.                 string action = tokens[0];
  21.                 int number = int.Parse(tokens[1]);
  22.                 bestRoom++;
  23.  
  24.                 if (action=="potion")
  25.                 {
  26.                     int currHealth = health;
  27.                     health += number;
  28.                     if (health>100)
  29.                     {
  30.                         health = 100;
  31.                         int diff = 100 - currHealth;
  32.                         Console.WriteLine($"You healed for {diff} hp.");
  33.                     }
  34.                     else
  35.                     {
  36.                         Console.WriteLine($"You healed for {number} hp.");
  37.                     }
  38.                     Console.WriteLine($"Current health: {health} hp.");
  39.                 }
  40.                 else if (action=="chest")
  41.                 {
  42.                     Console.WriteLine($"You found {number} bitcoins.");
  43.                     bitcoins += number;
  44.                 }
  45.                 else
  46.                 {
  47.                       health -= number;
  48.                     if (health<=0)
  49.                     {                      
  50.                         Console.WriteLine($"You died! Killed by {action}.");
  51.                         Console.WriteLine($"Best room: {bestRoom}");
  52.                         return;
  53.                     }
  54.                     else
  55.                     {
  56.                         Console.WriteLine($"You slayed {action}.");
  57.                         continue;
  58.                     }
  59.                 }
  60.             }
  61.  
  62.             Console.WriteLine($"You've made it!");
  63.             Console.WriteLine($"Bitcoins: {bitcoins}");
  64.             Console.WriteLine($"Health: {health}");
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement