Advertisement
Guest User

Untitled

a guest
Jul 26th, 2020
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using System.Text;
  5. using System.Linq;
  6.  
  7. namespace _01._Furniture
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. //100 hp
  14. //200 mp
  15.  
  16. int times = int.Parse(Console.ReadLine());
  17.  
  18. var nameHp = new Dictionary<string, int>();
  19. var nameMp = new Dictionary<string, int>();
  20.  
  21. for (int i = 0; i < times; i++)
  22. {
  23. var name = Console.ReadLine().Split().ToArray();
  24.  
  25. nameHp[name[0]] = int.Parse(name[1]);
  26. nameMp[name[0]] = int.Parse(name[2]);
  27.  
  28. }
  29.  
  30. var command = Console.ReadLine().Split(" - ").ToArray();
  31.  
  32. while (command[0] != "End")
  33. {
  34. if (command[0] == "CastSpell")
  35. {
  36. //CastSpell – {hero name} – {MP needed} – {spell name}
  37. int mpNeeded = int.Parse(command[2]);
  38.  
  39. if (nameMp[command[1]] < mpNeeded )
  40. {
  41. Console.WriteLine($"{command[1]} does not have enough MP to cast {command[3]}!");
  42. }
  43. else
  44. {
  45. nameMp[command[1]] -= mpNeeded;
  46. int points = nameMp[command[1]];
  47. Console.WriteLine($"{command[1]} has successfully cast {command[3]} and now has {points} MP!");
  48. }
  49. }
  50. if (command[0] == "TakeDamage")
  51. {
  52. //TakeDamage – {hero name} – {damage} – {attacker}
  53. int damage = int.Parse(command[2]);
  54.  
  55. nameHp[command[1]] -= damage;
  56.  
  57. if (nameHp[command[1]] <= 0)
  58. {
  59. Console.WriteLine($"{command[1]} has been killed by {command[3]}!");
  60. nameHp.Remove(command[1]);
  61. }
  62. else
  63. {
  64. int current = nameHp[command[1]];
  65. Console.WriteLine($"{command[1]} was hit for {damage} HP by {command[3]} and now has {current} HP left!");
  66. }
  67.  
  68. }
  69. if (command[0] == "Recharge")
  70. {
  71. //Recharge – {hero name} – {amount}
  72. int amount = int.Parse(command[2]);
  73. int old = nameMp[command[1]];
  74. nameMp[command[1]] += amount;
  75. if (nameMp[command[1]] > 200)
  76. {
  77. nameMp[command[1]] = 200;
  78. amount = 200 - old;
  79. }
  80.  
  81. Console.WriteLine($"{command[1]} recharged for {amount} MP!");
  82. }
  83. if (command[0] == "Heal")
  84. {
  85. //Heal – {hero name} – {amount}
  86. int amount = int.Parse(command[2]);
  87. int old = nameHp[command[1]];
  88. nameHp[command[1]] += amount;
  89. if (nameHp[command[1]] > 100)
  90. {
  91. nameHp[command[1]] = 100;
  92. amount = 100 - old;
  93. }
  94.  
  95. Console.WriteLine($"{command[1]} healed for {amount} HP!");
  96. }
  97.  
  98. command = Console.ReadLine().Split(" - ").ToArray();
  99. }
  100.  
  101.  
  102. }
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement