Advertisement
BdW44222

04. Legendary Farming

Aug 6th, 2021
915
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.90 KB | None | 0 0
  1. def sort_materials(user_input, important_materials, useless_materials):
  2.     for i in range(0, len(user_input), 2):
  3.         quantity_material = int(data[i])
  4.         material = data[i + 1].lower()
  5.  
  6.         if material == "shards":
  7.             important_materials['shards'] += quantity_material
  8.         elif material == "fragments":
  9.             important_materials['fragments'] += quantity_material
  10.         elif material == "motes":
  11.             important_materials['motes'] += quantity_material
  12.         else:
  13.             if material not in useless_materials:
  14.                 useless_materials[material] = 0
  15.             useless_materials[material] += quantity_material
  16.  
  17.  
  18. def obtain_legendary_item(important_materials, legendary_item_slot):
  19.     if important_materials['shards'] >= 250:
  20.         legendary_item_slot = "Shadowmourne"
  21.         important_materials['shards'] = important_materials['shards'] - 250
  22.         print(f"{legendary_item_slot} obtained!")
  23.  
  24.  
  25.     elif important_materials['fragments'] >= 250:
  26.         legendary_item_slot = "Valanyr"
  27.         important_materials['fragments'] = important_materials['fragments'] - 250
  28.         print(f"{legendary_item_slot} obtained!")
  29.  
  30.  
  31.     elif important_materials['motes'] >= 250:
  32.         legendary_item_slot = "Dragonwrath"
  33.         important_materials['motes'] = important_materials['motes'] - 250
  34.         print(f"{legendary_item_slot} obtained!")
  35.  
  36.  
  37. key_materials = {'shards': 0, 'fragments': 0, 'motes': 0}
  38. junk = {}
  39.  
  40. legendary_item = " "
  41.  
  42. while legendary_item == " ":
  43.     data = input().split()
  44.  
  45.     sort_materials(data, key_materials, junk)
  46.  
  47.     obtain_legendary_item(key_materials, legendary_item)
  48.  
  49. for item, quantity in sorted(key_materials.items(), key=lambda kvp: (-kvp[1], kvp[0])):
  50.     print(f"{item}: {quantity}")
  51.  
  52. for junk_item, junk_quantity in sorted(junk.items(), key=lambda kvp: kvp[0]):
  53.     print(f"{junk_item}: {junk_quantity}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement