Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02._MuOnline
- {
- class MuOnline
- {
- static void Main()
- {
- int health = 100;
- int bitcoins = 0;
- int countRooms = 0;
- string[] rooms = Console.ReadLine()
- .Split('|');
- for (int i = 0; i < rooms.Length; i++)
- {
- countRooms += 1;
- string[] currentRoom = rooms[i].Split();
- string creatureOrLoot = currentRoom[0];
- int number = int.Parse(currentRoom[1]);
- if (creatureOrLoot == "potion" || creatureOrLoot == "chest")
- {
- if (creatureOrLoot == "potion")
- {
- if (health == 100)
- {
- Console.WriteLine("You healed for 0 hp.");
- Console.WriteLine($"Current health: {health} hp.");
- }
- else if (health < 100)
- {
- int oldHealth = health;
- health += number;
- if (health > 100)
- {
- health = 100;
- int healed = health - oldHealth;
- Console.WriteLine($"You healed for {healed} hp.");
- Console.WriteLine($"Current health: {health} hp.");
- }
- else
- {
- Console.WriteLine($"You healed for {number} hp.");
- Console.WriteLine($"Current health: {health} hp.");
- }
- }
- }
- else
- {
- bitcoins += number;
- Console.WriteLine($"You found {number} bitcoins.");
- }
- }
- else
- {
- health -= number;
- if (health > 0)
- {
- Console.WriteLine($"You slayed {creatureOrLoot}.");
- }
- else
- {
- Console.WriteLine($"You died! Killed by {creatureOrLoot}.");
- Console.WriteLine($"Best room: {countRooms}");
- return;
- }
- }
- }
- Console.WriteLine("You've made it!");
- Console.WriteLine($"Bitcoins: {bitcoins}");
- Console.WriteLine($"Health: {health}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment