idlechampmissingadvgenerator.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import json
  2. from pprint import pprint
  3. import re
  4. from collections import OrderedDict
  5. import math
  6. from decimal import Decimal
  7. from idlechampaccount import ICAccount
  8. import subprocess
  9. import filecmp
  10. import os
  11. COMPARE = True
  12. REDOWNLOAD = False
  13. POST = False
  14. SHOW_CHANGES = False
  15. _summary = None
  16. if POST:
  17. instance = ICAccount()
  18. instance.login()
  19. # filename = '/home/txtsd/.local/share/Steam/steamapps/common/IdleChampions/IdleDragons_Data/StreamingAssets/downloaded_files/cached_definitions.json'
  20. filename = '/tmp/cached_definitions.json'
  21. if REDOWNLOAD or not os.path.isfile(filename):
  22. result = requests.get('http://master.idlechampions.com/~idledragons/post.php?call=getdefinitions')
  23. with open(filename, 'w') as f:
  24. if result.status_code == 200:
  25. f.write(result.text)
  26. adv_filename = 'json/adventure_defines.json'
  27. area_filename = 'json/adventure_area_defines.json'
  28. camp_filename = 'json/campaign_defines.json'
  29. monster_filename = 'json/monster_defines.json'
  30. with open(filename) as f:
  31. file = f.read()
  32. with open(adv_filename) as f:
  33. adv_file = f.read()
  34. with open(area_filename) as f:
  35. area_file = f.read()
  36. with open(camp_filename) as f:
  37. camp_file = f.read()
  38. with open(monster_filename) as f:
  39. monster_file = f.read()
  40. js = json.loads(file)
  41. js_adv = json.loads(adv_file)
  42. js_area = json.loads(area_file)
  43. js_camp = json.loads(camp_file)
  44. js_mon = json.loads(monster_file)
  45. js_graphic = js['graphic_defines']
  46. js_attack = js['attack_defines']
  47. js_hero = js['hero_defines']
  48. js_hero_skin = js['hero_skin_defines']
  49. js_upgrade = js['upgrade_defines']
  50. js_premium_item = js['premium_item_defines']
  51. js_sound = js['sound_defines']
  52. js_buff = js['buff_defines']
  53. js_loot = js['loot_defines']
  54. js_achievement = js['achievement_defines']
  55. js_ability = js['ability_defines']
  56. js_effect = js['effect_defines']
  57. js_changelog = js['changelog_defines']
  58. js_text = js['text_defines']
  59. js_chest_type = js['chest_type_defines']
  60. js_effect_key = js['effect_key_defines']
  61. js_tutorial_state = js['tutorial_state_defines']
  62. js_game_rule = js['game_rule_defines']
  63. js_news = js['news_defines']
  64. js_language = js['language_defines']
  65. js_familiar = js['familiar_defines']
  66. for mon in js_mon:
  67. if mon['name'] == 'Jarlaxle':
  68. temp = mon
  69. js_mon.remove(mon)
  70. temp['name'] = 'Jarlaxle (Monster)'
  71. js_mon.append(temp)
  72. # taglist = {}
  73. # for rule in js_game_rule:
  74. # if rule['rule_name'] == 'enemy_hover_tags':
  75. # for tag in rule['rule']['tags']:
  76. # taglist.update({tag: set()})
  77. # # pprint(taglist)
  78. # for monster in js_adv:
  79. # for tag in monster['tags']:
  80. # if tag in taglist:
  81. # taglist[tag].add(monster['name'])
  82. _js_adv = sorted(js_adv, key=lambda x: x['id'])
  83. __js_adv = sorted(_js_adv, key=lambda x: x['area_set_id'])
  84. __js_adv = sorted(__js_adv, key=lambda x: x['location_id'])
  85. __js_adv = sorted(__js_adv, key=lambda x: x['campaign_id'])
  86. __js_area = sorted(js_area, key=lambda x: x['id'])
  87. __js_area = sorted(__js_area, key=lambda x: x['area_id'])
  88. __js_area = sorted(__js_area, key=lambda x: x['area_set_id'])
  89. # pprint(__js_area)
  90. __js_mon = sorted(js_mon, key=lambda x: x['id'])
  91. # pprint(__js_adv)
  92. set_advs = set()
  93. print('id' + ',' + 'campaign_id' + ',' + 'location_id' + ',' + 'area_set_id' + ',' + 'name')
  94. for adv in _js_adv:
  95. if adv['id'] not in set_advs:
  96. set_advs.add(adv['id'])
  97. name = adv['name']
  98. if name == 'Free Play':
  99. for _adv in __js_adv:
  100. if adv['variant_adventure_id'] == _adv['id']:
  101. name = _adv['name'] + ' ' + name
  102. if 'variant_adventure_id' in adv:
  103. name = ''⟶ + name
  104. print(str(adv['id']) + ',' + str(adv['campaign_id']) + ',' + str(adv['location_id']) + ',' + str(adv['area_set_id']) + ',' + name)