Advertisement
LardaX

Legendary-Farming-Remake

Oct 8th, 2016
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Legendary_Farming
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Dictionary<string, int> materials = new Dictionary<string, int>();
  14.             string legendarySword = "";
  15.             materials.Add("fragments", 0);
  16.             materials.Add("shards", 0);
  17.             materials.Add("motes", 0);
  18.  
  19.             while (true)
  20.             {
  21.                 string[] materialsObtained = Console.ReadLine().ToLower().Split().ToArray();
  22.  
  23.                 for (int i = 1; i < materialsObtained.Length; i += 2)
  24.                 {
  25.                     if (!materials.ContainsKey(materialsObtained[i]))
  26.                     {
  27.                         materials.Add(materialsObtained[i], 0);
  28.                     }
  29.  
  30.                     materials[materialsObtained[i]] += int.Parse(materialsObtained[i - 1]);
  31.  
  32.                     legendarySword = GetLegendaryItem(materials, legendarySword);
  33.                    
  34.                     if (!legendarySword.Equals(""))
  35.                     {
  36.                         break;
  37.                     }
  38.                 }
  39.  
  40.                 if (!legendarySword.Equals(""))
  41.                 {
  42.                     break;
  43.                 }
  44.             }
  45.  
  46.             PrintWeapon(materials, legendarySword);
  47.  
  48.         }
  49.  
  50.         private static string GetLegendaryItem(Dictionary<string, int> materials, string legendarySword)
  51.         {
  52.             if (materials["fragments"] >= 250)
  53.             {
  54.                 legendarySword = "Valanyr";
  55.                 materials["fragments"] -= 250;
  56.             }
  57.             else if (materials["shards"] >= 250)
  58.             {
  59.                 legendarySword = "Shadowmourne";
  60.                 materials["shards"] -= 250;
  61.             }
  62.             else if (materials["motes"] >= 250)
  63.             {
  64.                 legendarySword = "Dragonwrath";
  65.                 materials["motes"] -= 250;
  66.             }
  67.  
  68.             return legendarySword;
  69.         }
  70.  
  71.         private static void PrintWeapon(Dictionary<string, int> materials, string legendarySword)
  72.         {
  73.             Console.WriteLine($"{legendarySword} obtained!");
  74.             Dictionary<string, int> legendaryMaterials = new Dictionary<string, int>();
  75.             SortedDictionary<string, int> otherMaterials = new SortedDictionary<string, int>();
  76.  
  77.             FillDictionaries(materials, legendaryMaterials, otherMaterials);
  78.  
  79.             PrintLegendaryMaterials(legendaryMaterials);
  80.             PrintOtherMaterials(otherMaterials);
  81.  
  82.         }
  83.  
  84.         private static void PrintOtherMaterials(SortedDictionary<string, int> otherMaterials)
  85.         {
  86.             foreach (KeyValuePair<string, int> material in otherMaterials)
  87.             {
  88.                 Console.WriteLine($"{material.Key}: {material.Value}");
  89.             }
  90.         }
  91.  
  92.         private static void PrintLegendaryMaterials(Dictionary<string, int> legendaryMaterials)
  93.         {
  94.             foreach (KeyValuePair<string, int> material in legendaryMaterials.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  95.             {
  96.                 Console.WriteLine($"{material.Key}: {material.Value}");
  97.             }
  98.         }
  99.  
  100.         private static void FillDictionaries(Dictionary<string, int> materials, Dictionary<string, int> legendaryMaterials, SortedDictionary<string, int> otherMaterials)
  101.         {
  102.             foreach (KeyValuePair<string, int> material in materials)
  103.             {
  104.                 if (material.Key.Equals("shards") || material.Key.Equals("fragments") || material.Key.Equals("motes"))
  105.                 {
  106.                     legendaryMaterials.Add(material.Key, material.Value);
  107.                 }
  108.                 else
  109.                 {
  110.                     otherMaterials.Add(material.Key, material.Value);
  111.                 }
  112.             }
  113.         }
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement