Advertisement
Guest User

LegendaryFarming

a guest
Oct 15th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.82 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5.  
  6. class LegendaryFarming
  7. {
  8.     static void Main()
  9.     {
  10.         SortedDictionary<string, long> keyMaterials = new SortedDictionary<string, long>();
  11.         keyMaterials["shards"] = 0;
  12.         keyMaterials["motes"] = 0;
  13.         keyMaterials["fragments"] = 0;
  14.  
  15.         SortedDictionary<string, long> junkMaterials = new SortedDictionary<string, long>();
  16.         bool isInput = true;
  17.  
  18.         while (isInput)
  19.         {
  20.             string[] materials = Console.ReadLine().ToLower().Split(' ').ToArray();
  21.  
  22.             for (int i = 0; i < materials.Length; i += 2)
  23.             {
  24.                 long curentQuantiti = long.Parse(materials[i]);
  25.                 string curentMaterial = materials[i + 1];
  26.                 if (curentMaterial == "shards" || curentMaterial == "motes" || curentMaterial == "fragments")
  27.                 {
  28.                     keyMaterials[curentMaterial] += curentQuantiti;
  29.                 }
  30.                 else
  31.                 {
  32.                     if (!junkMaterials.ContainsKey(curentMaterial))
  33.                     {
  34.                         junkMaterials.Add(curentMaterial, 0);
  35.                     }
  36.                     junkMaterials[curentMaterial] += curentQuantiti;
  37.                 }
  38.  
  39.                 if (keyMaterials["shards"] >= 250 || keyMaterials["motes"] >= 250 || keyMaterials["fragments"] >= 250)
  40.                 {
  41.                     foreach (var item in keyMaterials.OrderByDescending(x => x.Value))
  42.                     {
  43.                         switch (item.Key)
  44.                         {
  45.                             case "motes":
  46.                                 Console.WriteLine("Dragonwrath obtained!");
  47.                                 keyMaterials[item.Key] -= 250;
  48.                                 break;
  49.                             case "shards":
  50.                                 Console.WriteLine("Shadowmourne obtained!");
  51.                                 keyMaterials[item.Key] -= 250;
  52.                                 break;
  53.                             case "fragments":
  54.                                 Console.WriteLine("Valanyr obtained!");
  55.                                 keyMaterials[item.Key] -= 250;
  56.                                 break;
  57.                         }
  58.                         break;
  59.                     }
  60.  
  61.                     foreach (var item in keyMaterials.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  62.                     {
  63.                         Console.WriteLine("{0}: {1}", item.Key, item.Value);
  64.                     }
  65.                     foreach (var item in junkMaterials)
  66.                     {
  67.                         Console.WriteLine("{0}: {1}", item.Key, item.Value);
  68.                     }
  69.  
  70.                     return;
  71.                 }
  72.             }
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement