Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp29
- {
- class Program
- {
- static void Main(string[] args)
- {
- int health = 100, bitcoins = 0;
- string[] rooms = Console.ReadLine().Split('|');
- for(int i=0; i<rooms.Length; i++)
- {
- string[] cmdargs = rooms[i].Split(' ');
- if(cmdargs[0] == "chest")
- {
- Console.WriteLine($"You found {cmdargs[1]} bitcoins.");
- bitcoins += int.Parse(cmdargs[1]);
- }
- else if(cmdargs[0] == "potion")
- {
- int heal = int.Parse(cmdargs[1]);
- int newHealth = health + heal;
- if (newHealth > 100) newHealth = 100;
- Console.WriteLine($"You healed for {newHealth - health} hp.");
- health = newHealth;
- Console.WriteLine($"Current health: {health} hp.");
- }
- else // monster
- {
- int damage = int.Parse(cmdargs[1]);
- health -= damage;
- if (health > 0) Console.WriteLine($"You slayed {cmdargs[0]}.");
- else
- {
- Console.WriteLine($"You died! Killed by {cmdargs[0]}.\nBest room: {i + 1}");
- break;
- }
- }
- }
- if(health > 0) Console.WriteLine($"You've made it!\nBitcoins: {bitcoins}\nHealth: {health}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement