Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace ConsoleApp49
- {
- class Program
- {
- static void Main(string[] args)
- {
- int a = 0;
- int health = 100;
- int coins = 0;
- // var input = "cat 100|potion 30|orc 10|chest 10|snake 25|chest 110";
- var input = Console.ReadLine();
- int count = input.Split(' ').Length;
- for (int i = 0; i < count - 1; i++)
- {
- a += 1;
- var output = Regex.Replace(input.Split("|")[i], @"[^0-9a-zA-Z\ ]+", "");
- var item = Regex.Replace(output.Split()[0], @"[^0-9a-zA-Z\ ]+", "");
- if (item == "potion")
- {
- var value = Regex.Replace(output.Split()[1], @"[^0-9a-zA-Z\ ]+", "");
- if (health <= 100)
- {
- int h = health;
- health += int.Parse(value);
- if (health >= 100)
- {
- if(h <= 100)
- {
- Console.WriteLine("You healed for {0} hp.", 100 - h);
- }
- else
- {
- Console.WriteLine("You healed for {0} hp.", 0);
- }
- health = 100;
- Console.WriteLine("Current health: {0} hp.", health);
- }
- else
- {
- Console.WriteLine("You healed for {0} hp.", value);
- Console.WriteLine("Current health: {0} hp.", health);
- }
- }
- }
- else if (item == "chest")
- {
- var value = Regex.Replace(output.Split()[1], @"[^0-9a-zA-Z\ ]+", "");
- coins += int.Parse(value);
- Console.WriteLine("You found {0} bitcoins.", value);
- }
- else
- {
- var value = Regex.Replace(output.Split()[1], @"[^0-9a-zA-Z\ ]+", "");
- health -= int.Parse(value);
- if (health > 0)
- {
- Console.WriteLine("You slayed {0}.", item);
- }
- else if (health <= 0)
- {
- if(a == 0)
- {
- a += 1;
- }
- Console.WriteLine("You died! Killed by boss.");
- Console.WriteLine("Best room: {0}", a);
- break;
- }
- }
- }
- if(a == count - 1)
- {
- Console.WriteLine("You've made it!");
- Console.WriteLine("Bitcoins: {0}", coins);
- Console.WriteLine("Health: {0}", health);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement