Advertisement
ElviraPetkova

Legendary_Farming

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