Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Globalization;
- using System.Text;
- namespace LegendaryFarming
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool itemObtained = false;
- Dictionary<string, int> keymaterials = new Dictionary<string, int>();
- keymaterials.Add("shards", 0);
- keymaterials.Add("fragments", 0);
- keymaterials.Add("motes", 0);
- Dictionary<string, int> junk = new Dictionary<string, int>();
- string obtainedItem = "";
- while (!itemObtained)
- {
- string[] input = Console.ReadLine().ToLower().Split().ToArray();
- List<string> materials = new List<string>();
- List<int> quantities = new List<int>();
- for (int i = 1; i <= input.Length; i++)//
- {
- if (i % 2 != 0)
- quantities.Add(int.Parse(input[i - 1]));//
- else
- materials.Add(input[i - 1]);//
- }
- for (int i = 0; i < materials.Count; i++)
- {
- if (materials[i] == "shards" || materials[i] == "fragments" || materials[i] == "motes")
- {
- if (keymaterials.ContainsKey(materials[i]))
- {
- keymaterials[materials[i]] += quantities[i];
- }
- if (keymaterials[materials[i]] >= 250)
- {
- switch (materials[i])
- {
- case "shards":
- obtainedItem = "Shadowmourne";
- break;
- case "fragments":
- obtainedItem = "Valanyr";
- break;
- case "motes":
- obtainedItem = "Dragonwrath";
- break;
- }
- Console.WriteLine($"{obtainedItem} obtained!");
- itemObtained = true;
- keymaterials[materials[i]] -= 250;
- break;
- }
- }
- else
- {
- if (junk.ContainsKey(materials[i]))
- {
- junk[materials[i]] += quantities[i];
- }
- else
- junk.Add(materials[i], quantities[i]);
- }
- }
- }
- foreach (var item in keymaterials.OrderByDescending(i => i.Value).ThenBy(i => i.Key))
- {
- Console.WriteLine($"{item.Key}: {item.Value}");
- }
- foreach (var item in junk.OrderBy(i=>i.Key))
- {
- Console.WriteLine($"{item.Key}: {item.Value}");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment