deleriumbg

Legendary Farming

Mar 20th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.33 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.             Dictionary<string, int> keyMaterials = new Dictionary<string, int>();
  12.             Dictionary<string, int> junk = new Dictionary<string, int>();
  13.             keyMaterials.Add("shards", 0);
  14.             keyMaterials.Add("fragments", 0);
  15.             keyMaterials.Add("motes", 0);
  16.             bool shadowmourneObtained = false;
  17.             bool valanyrObtained = false;
  18.             bool dragonwrathObtained = false;
  19.             string legendary = "";
  20.  
  21.             while (shadowmourneObtained == false && valanyrObtained == false && dragonwrathObtained == false)
  22.             {
  23.                 List<string> input = Console.ReadLine().ToLower().Split(' ').ToList();
  24.                 string material = "";
  25.                 int quantity = 0;
  26.                 for (int i = 0; i < input.Count; i += 2)
  27.                 {
  28.                     quantity = int.Parse(input[i]);
  29.                     material = input[i + 1];
  30.  
  31.                     switch (material)
  32.                     {
  33.                         case "shards":
  34.                             keyMaterials["shards"] += quantity;
  35.                             break;
  36.                         case "fragments":
  37.                             keyMaterials["fragments"] += quantity;
  38.                             break;
  39.                         case "motes":
  40.                             keyMaterials["motes"] += quantity;
  41.                             break;
  42.                         default:
  43.                             if (junk.ContainsKey(material) == false)
  44.                             {
  45.                                 junk.Add(material, quantity);
  46.                             }
  47.                             else
  48.                             {
  49.                                 junk[material] += quantity;
  50.                             }
  51.                             break;
  52.                     }
  53.  
  54.                     if (keyMaterials["shards"] >= 250)
  55.                     {
  56.                         shadowmourneObtained = true;
  57.                         legendary = "Shadowmourne";
  58.                         keyMaterials["shards"] -= 250;
  59.                         break;
  60.                     }
  61.                     else if (keyMaterials["fragments"] >= 250)
  62.                     {
  63.                         valanyrObtained = true;
  64.                         legendary = "Valanyr";
  65.                         keyMaterials["fragments"] -= 250;
  66.                         break;
  67.                     }
  68.                     else if (keyMaterials["motes"] >= 250)
  69.                     {
  70.                         dragonwrathObtained = true;
  71.                         legendary = "Dragonwrath";
  72.                         keyMaterials["motes"] -= 250;
  73.                         break;
  74.                     }
  75.                 }
  76.             }
  77.  
  78.             Console.WriteLine($"{legendary} obtained!");
  79.             foreach (var item in keyMaterials.OrderBy(x => x.Key).OrderByDescending(x => x.Value))
  80.             {
  81.                 Console.WriteLine($"{item.Key}: {item.Value}");
  82.             }
  83.             foreach (var item in junk.OrderBy(x => x.Key))
  84.             {
  85.                 Console.WriteLine($"{item.Key}: {item.Value}");
  86.             }
  87.         }
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment