petyaminkova91

Untitled

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