Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Mu_Online_MidExam
- {
- class Program
- {
- static void Main(string[] args)
- {
- double health = 100;
- double bitcoins = 0;
- int room = 0;
- double totalBitcoins = 0;
- var dungeousRooms = Console.ReadLine()
- .Split("|");
- bool isVictory = false;
- for (int i = 0; i < dungeousRooms.Length; i++)
- {
- var commandSec = dungeousRooms[i].Split(" ");
- string commandMain = commandSec[0];
- room++;
- if (commandMain == "potion")
- {
- int helpHealth = int.Parse(commandSec[1]);
- if (health < 100)
- {
- if ((helpHealth + health) == 100)
- {
- Console.WriteLine($"You healed for {health} hp.");
- }
- else
- {
- double neededHealth = 100 - health;
- double noNeedHealth = Math.Abs(neededHealth - helpHealth);
- health += neededHealth;
- Console.WriteLine($"You healed for {neededHealth} hp.");
- }
- }
- //else
- //{
- // double diff = health - 100;
- // double diffTwo = diff - helpHealth;
- // Console.WriteLine($"You healed for {Math.Abs(diffTwo)} hp.");
- //}
- Console.WriteLine($"Current health: {health} hp.");
- isVictory = true;
- }
- else if (commandMain == "chest")
- {
- double amountBitcoins = int.Parse(commandSec[1]);
- Console.WriteLine($"You found {amountBitcoins} bitcoins.");
- totalBitcoins += amountBitcoins;
- isVictory = true;
- }
- else
- {
- double fightAttack = double.Parse(commandSec[1]);
- health -= fightAttack;
- if (health > 0 )
- {
- Console.WriteLine($"You slayed {commandMain}.");
- //continue;
- }
- else
- {
- Console.WriteLine($"You died! Killed by {commandMain}.");
- Console.WriteLine($"Best room: {room}");
- isVictory = false;
- break;
- }
- }
- }
- if (isVictory)
- {
- Console.WriteLine("You've made it!");
- Console.WriteLine($"Bitcoins: {totalBitcoins}");
- Console.WriteLine($"Health: {health}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment