list.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/env python3
  2. # ---------------------------------------------------------------------
  3. # ------------------------- Plight Rising -----------------------------
  4. # -----------------------------txtsd-----------------------------------
  5. # ---------------------------------------------------------------------
  6. """Lists things"""
  7. # Imports -------------------------------------------------------------
  8. import os
  9. import json
  10. # End Imports ---------------------------------------------------------
  11. userID = ''
  12. derp = []
  13. things = []
  14. venue = ''
  15. # training_fields, woodland_border, scorched_forest, sandswept_delta, forgotten_cave,
  16. # bamboo_waterfall, waterway, arena, boreal_wood, harpys_roost, mire, kelp_beds
  17. time = 0
  18. enemies = {}
  19. total = 0
  20. noloot = 0
  21. dec = json.JSONDecoder()
  22. with open(userID + '.txt', 'r') as f:
  23. try:
  24. herp = f.read()
  25. except:
  26. print("--Done Reading--")
  27. for x in herp.split('\n'):
  28. try:
  29. derp.append(dec.decode(x))
  30. except:
  31. print("--Done Parsing--")
  32. print(str(len(derp)) + ' entries')
  33. for x in derp:
  34. if (x['venue'] == venue) and (x['time'] > time):
  35. total += 1
  36. if x['loot']:
  37. for y in x['loot']:
  38. if y not in things:
  39. things.append(y)
  40. else:
  41. noloot += 1
  42. temp = ''
  43. for y in x['enemies']:
  44. temp += (y['name'] + ' | ')
  45. if temp not in enemies:
  46. enemies[temp] = 0
  47. enemies[temp] += 1
  48. print("Battles: " + str(total), "Noloot: " + str(noloot))
  49. things.sort(key=lambda herp: (herp['subtype'], herp['name']))
  50. print('')
  51. for x in enemies:
  52. print(x, str(enemies[x]/total*100)[:7] + '%')
  53. print('')
  54. for i, w in enumerate(things):
  55. instances = 0
  56. count = 0
  57. prob = {'1': 0, '2': 0, '3': 0, '4': 0}
  58. for x in derp:
  59. if (x['venue'] == venue) and (x['time'] > time):
  60. if x['loot']:
  61. num = 0
  62. for y in x['loot']:
  63. if y['name'] == w['name']:
  64. num += 1
  65. count += 1
  66. if not num == 0:
  67. prob[str(num)] += 1
  68. print(w['subtype'], str(count / total * 100.0)[:7] + '%', w['name'].replace('\u2019', "'") + ": " + str(count))
  69. os.system("pause")