Advertisement
VickSuna

Untitled

Aug 14th, 2021
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace FFE
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string input = Console.ReadLine();
  13.  
  14. Dictionary<string, List<int>> fighters = new Dictionary<string, List<int>>();
  15.  
  16. // health = 0;
  17. // energy = 1;
  18.  
  19. while (input != "Results")
  20. {
  21. string[] command = input.Split(":");
  22.  
  23. if (command.Contains("Add"))
  24. {
  25. string fighterName = command[1];
  26.  
  27. int fighterHealth = int.Parse(command[2]);
  28.  
  29. int fighterEnergy = int.Parse(command[3]);
  30.  
  31. if (!fighters.ContainsKey(fighterName))
  32. {
  33. fighters.Add(fighterName, new List<int> { fighterHealth, fighterEnergy });
  34. }
  35. else
  36. {
  37. fighters[fighterName][0] += fighterHealth;
  38. }
  39.  
  40.  
  41. }
  42. else if (command.Contains("Attack"))
  43. {
  44. string attackerName = command[1];
  45.  
  46. string defenderName = command[2];
  47.  
  48. int damage = int.Parse(command[3]);
  49.  
  50. if (fighters.ContainsKey(attackerName) && fighters.ContainsKey(defenderName))
  51. {
  52. fighters[defenderName][0] -= damage;
  53.  
  54. if (fighters[defenderName][0] <= 0)
  55. {
  56. fighters.Remove(defenderName);
  57.  
  58. Console.WriteLine($"{defenderName} was disqualified!");
  59. }
  60.  
  61. fighters[attackerName][1] -= 1;
  62.  
  63. if (fighters[attackerName][1] == 0)
  64. {
  65. fighters.Remove(attackerName);
  66.  
  67. Console.WriteLine($"{attackerName} was disqualified!");
  68. }
  69. }
  70. }
  71.  
  72. else if (command.Contains("Delete"))
  73. {
  74. string fighterName = command[1];
  75.  
  76. if (fighters.ContainsKey(fighterName))
  77. {
  78. fighters.Remove(fighterName);
  79. }
  80. if (command.Contains("All"))
  81. {
  82. fighters.Clear();
  83. }
  84.  
  85. }
  86.  
  87.  
  88.  
  89. input = Console.ReadLine();
  90. }
  91.  
  92. Console.WriteLine($"People count: {fighters.Count}");
  93.  
  94. foreach (var user in fighters.OrderByDescending(x => x.Value[0]).ThenBy(x => x.Key))
  95. {
  96. Console.WriteLine($"{user.Key} - {user.Value[0]} - {user.Value[1]}");
  97. }
  98. }
  99. }
  100. }
  101.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement