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