Advertisement
Guest User

04. Legendary Farming

a guest
Feb 14th, 2022
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.21 KB | None | 0 0
  1. elements = input().lower()
  2. elements = elements.split(" ")
  3.  
  4. shards = 0
  5. fragments = 0
  6. motes = 0
  7.  
  8. resource_for_obtaining = ''
  9.  
  10. junk_item_dictionary = {}
  11. legendary_item_dictionary = {'shards': 0, 'fragments': 0, 'motes': 0}
  12.  
  13. key_materials_reached = False
  14.  
  15. while not key_materials_reached:
  16.  
  17.     for el in range(0, len(elements), 2):
  18.         current_item = elements[el + 1]
  19.         quantity = int(elements[el])
  20.  
  21.         if current_item == "motes":
  22.             motes += quantity
  23.         elif current_item == "shards":
  24.             shards += quantity
  25.         elif current_item == "fragments":
  26.             fragments += quantity
  27.  
  28.         if motes >= 250:
  29.             motes -= 250
  30.             legendary_item_dictionary[current_item] = motes
  31.             resource_for_obtaining = 'motes'
  32.             key_materials_reached = True
  33.             break
  34.         elif fragments >= 250:
  35.             fragments -= 250
  36.             legendary_item_dictionary[current_item] = fragments
  37.             resource_for_obtaining = 'fragments'
  38.             key_materials_reached = True
  39.             break
  40.         elif shards >= 250:
  41.             shards -= 250
  42.             legendary_item_dictionary[current_item] = shards
  43.             resource_for_obtaining = 'shards'
  44.             key_materials_reached = True
  45.             break
  46.  
  47.         if current_item == "motes" or current_item == "shards" or current_item == "fragments":
  48.             legendary_item_dictionary[current_item] += quantity
  49.         else:
  50.             junk_item_dictionary[current_item] = quantity
  51.  
  52.     if not key_materials_reached:
  53.         elements = input().lower()
  54.         elements = elements.split(" ")
  55.  
  56. if resource_for_obtaining == "shards":
  57.     print(f"Shadowmourne obtained!")
  58. elif resource_for_obtaining == "fragments":
  59.     print(f"Valanyr obtained!")
  60. elif resource_for_obtaining == "motes":
  61.     print(f"Dragonwrath obtained!")
  62.  
  63.  
  64. for (key_material_name, key_material_qty) in sorted(legendary_item_dictionary.items(), key=lambda kvp: (-kvp[1], kvp[0])):
  65.     print(f'{key_material_name}: {key_material_qty}')
  66.  
  67. for (junk_material_name, junk_material_qty) in sorted(junk_item_dictionary.items(), key=lambda kvp: kvp[0]):
  68.     print(f"{junk_material_name}: {junk_material_qty}")
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement