Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _02DungeonestDark
- {
- class Program
- {
- static void Main(string[] args)
- {
- int health = 100;
- int coins = 0;
- string[] dungeonsRoom = Console.ReadLine().Split('|').ToArray();
- for (int i = 0; i < dungeonsRoom.Length; i++)
- {
- string[] currentRoom = dungeonsRoom[i].Split().ToArray();
- string content = currentRoom[0]; //съдържанието в стаята
- int number = int.Parse(currentRoom[1]); //стойността в стаята
- if (content == "potion") //ако намерим potion
- {
- int currentHealth = health;
- health += number;
- if (health > 100)
- {
- Console.WriteLine($"You healed for {100 - currentHealth} hp.");
- Console.WriteLine($"Current health: 100 hp.");
- health = 100;
- }
- else //ако кръвта е под 100
- {
- Console.WriteLine($"You healed for {number} hp."); //хилваме се само с Number
- Console.WriteLine($"Current health: {health} hp.");
- }
- }
- else if (content == "chest") //намерили сме сандък с пари
- {
- coins += number; //добавяме парите от сандъка към нашите
- Console.WriteLine($"You found {number} coins.");//принтираме колко пари сме намерили
- }
- else //намерили сме чудовище в стаята
- {
- string monsterName = content;
- health -= number;
- if (health > 0) //живи сме и сме убили чудовището
- {
- Console.WriteLine($"You slayed {monsterName}.");
- }
- else //ако умрем принтираме съобщение на конзолата и прекъсваме цикъла
- {
- Console.WriteLine($"You died! Killed by {monsterName}.\nBest room: {i + 1}");
- break;
- }
- }
- }
- if (health > 0) //ако сме живи принтираме последното съобщение
- {
- Console.WriteLine($"You've made it!\nCoins: {coins}\nHealth: {health}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement