Advertisement
silvana1303

MuOnline

Jun 13th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5.  
  6. namespace ConsoleApp1
  7. {
  8.     class Exam
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string[] gameArray = Console.ReadLine().Split('|').ToArray();
  13.  
  14.             int health = 100;
  15.             int bitcoins = 0;
  16.  
  17.             for (int i = 0; i < gameArray.Length; i++)
  18.             {
  19.                 string[] room = gameArray[i].Split().ToArray();
  20.  
  21.                 if (room[0] == "potion")
  22.                 {
  23.                     int pointsHealth = int.Parse(room[1]);
  24.  
  25.                     health += pointsHealth;
  26.  
  27.                     if (health > 100)
  28.                     {
  29.                         int difference = health - 100;
  30.                         pointsHealth -= difference;
  31.                         health = 100;
  32.                     }
  33.  
  34.                     Console.WriteLine($"You healed for {pointsHealth} hp.");
  35.                     Console.WriteLine($"Current health: {health} hp.");
  36.                 }
  37.                 else if (room[0] == "chest")
  38.                 {
  39.                     int pointsChest = int.Parse(room[1]);
  40.  
  41.                     bitcoins += pointsChest;
  42.  
  43.                     Console.WriteLine($"You found {pointsChest} bitcoins.");
  44.  
  45.                 }
  46.                 else
  47.                 {
  48.                     string monster = room[0];
  49.                     int attackMonster = int.Parse(room[1]);
  50.  
  51.                     health -= attackMonster;
  52.  
  53.                     if (health > 0)
  54.                     {
  55.                         Console.WriteLine($"You slayed {monster}.");
  56.                     }
  57.                     else
  58.                     {
  59.                         Console.WriteLine($"You died! Killed by {monster}.");
  60.                         Console.WriteLine($"Best room: {i + 1}");
  61.                         return;
  62.                     }
  63.                 }
  64.  
  65.             }
  66.             Console.WriteLine($"You've made it!");
  67.             Console.WriteLine($"Bitcoins: {bitcoins}");
  68.             Console.WriteLine($"Health: {health}");
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement