Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- namespace ConsoleApp1
- {
- class Exam
- {
- static void Main(string[] args)
- {
- string[] gameArray = Console.ReadLine().Split('|').ToArray();
- int health = 100;
- int bitcoins = 0;
- for (int i = 0; i < gameArray.Length; i++)
- {
- string[] room = gameArray[i].Split().ToArray();
- if (room[0] == "potion")
- {
- int pointsHealth = int.Parse(room[1]);
- health += pointsHealth;
- if (health > 100)
- {
- int difference = health - 100;
- pointsHealth -= difference;
- health = 100;
- }
- Console.WriteLine($"You healed for {pointsHealth} hp.");
- Console.WriteLine($"Current health: {health} hp.");
- }
- else if (room[0] == "chest")
- {
- int pointsChest = int.Parse(room[1]);
- bitcoins += pointsChest;
- Console.WriteLine($"You found {pointsChest} bitcoins.");
- }
- else
- {
- string monster = room[0];
- int attackMonster = int.Parse(room[1]);
- health -= attackMonster;
- if (health > 0)
- {
- Console.WriteLine($"You slayed {monster}.");
- }
- else
- {
- Console.WriteLine($"You died! Killed by {monster}.");
- 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