Advertisement
Guest User

Legendary Farming

a guest
Feb 19th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _09.Legendary_Farming
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. bool shadowmourneObtained = false;
  12. bool valanyrObtained = false;
  13. bool dragonwrathObtained = false;
  14.  
  15. string resource;
  16. int quantity = 0;
  17. string prize = string.Empty;
  18.  
  19. var resourcesPrimary = new Dictionary<string, int>();
  20. var junk = new Dictionary<string, int>();
  21.  
  22. resourcesPrimary.Add("shards", 0);
  23. resourcesPrimary.Add("fragments", 0);
  24. resourcesPrimary.Add("motes", 0);
  25.  
  26. while (shadowmourneObtained == false && valanyrObtained == false && dragonwrathObtained == false)
  27. {
  28. string[] input = Console.ReadLine().Split(' ').ToArray();
  29.  
  30. for (int i = 0; i < input.Length; i += 2)
  31. {
  32. resource = input[i + 1].ToLower();
  33. quantity = int.Parse(input[i]);
  34.  
  35. if (resourcesPrimary.ContainsKey(resource))
  36. resourcesPrimary[resource] += quantity;
  37. else if (!junk.ContainsKey(resource))
  38. junk.Add(resource, quantity);
  39. else
  40. junk[resource] += quantity;
  41.  
  42. if(resourcesPrimary["shards"] >= 250)
  43. {
  44. shadowmourneObtained = true;
  45. prize = "Shadowmourne";
  46. resourcesPrimary["shards"] -= 250;
  47. break;
  48. }
  49. else if(resourcesPrimary["fragments"] >= 250)
  50. {
  51. valanyrObtained = true;
  52. prize = "Valanyr";
  53. resourcesPrimary["fragments"] -= 250;
  54. break;
  55. }
  56. else if(resourcesPrimary["motes"] >= 250)
  57. {
  58. dragonwrathObtained = true;
  59. prize = "Dragonwrath";
  60. resourcesPrimary["motes"] -= 250;
  61. break;
  62. }
  63.  
  64. }
  65. }
  66.  
  67. Console.WriteLine($"{prize} obtained!");
  68. foreach (var metal in resourcesPrimary.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  69. {
  70. Console.WriteLine($"{metal.Key}: {metal.Value}");
  71. }
  72. foreach (var metal in junk.OrderBy(x => x.Key))
  73. {
  74. Console.WriteLine($"{metal.Key}: {metal.Value}");
  75. }
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement