Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int health = 100;
- int bitcoins = 0;
- List<string> rooms = Console.ReadLine()
- .Split('|')
- .ToList();
- for (int i = 0; i<rooms.Count; i++)
- {
- string[] ROOM = rooms[i].Split().ToArray();
- int number = int.Parse(ROOM[1]);
- string command = ROOM[0];
- int amount = 0;
- if (command == "potion")
- {
- int previousHealth = health;
- health += number;
- if (health > 100)
- {
- amount = Math.Abs(100-previousHealth);
- Console.WriteLine($"You healed for {amount} hp.");
- health = 100;
- Console.WriteLine($"Current health: {health} hp.");
- }
- else if (health <= 100)
- {
- Console.WriteLine($"You healed for {number} hp.");
- Console.WriteLine($"Current health: {health} hp.");
- }
- }
- else if (command == "chest")
- {
- bitcoins+=number;
- Console.WriteLine($"You found {number} bitcoins.");
- }
- else
- {
- health-=number;
- if (health >0)
- {
- Console.WriteLine($"You slayed {command}.");
- }
- else if (health <=0)
- {
- Console.WriteLine($"You died! Killed by {command}.");
- Console.WriteLine($"Best room: {i+1}");
- return;
- }
- }
- }
- Console.WriteLine("You've made it!");
- Console.WriteLine($"Bitcoins: {bitcoins}");
- Console.WriteLine($"Health: {health}");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement