Skip to content

Commit

Permalink
apply black & isort
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 4, 2023
1 parent 6192742 commit 622a22e
Show file tree
Hide file tree
Showing 5 changed files with 6,576 additions and 14 deletions.
1 change: 0 additions & 1 deletion TechTreeProcessing/techtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,4 @@
master_dict[key].append(c)



print(master_dict)
27 changes: 16 additions & 11 deletions clean_description_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,47 @@

import json


def remove_keys(text, re_subs):
import re

pattern = re.compile("|".join(re_subs))
return pattern.sub(lambda m: '', text)
return pattern.sub(lambda m: "", text)


with open('descriptions.json','r') as f:
with open("descriptions.json", "r") as f:
data = json.load(f)

# Hardcode fix to Elite Berserk
# add <br>\n right before (‹cost›) in key "26576"
data["26576"] = data["26576"].replace("(‹cost›)", "<br>\n(‹cost›)")


filtered = {k: [a.strip() for a in remove_keys(v, {'<[^>]+>', '[(]?‹[^›]+›[)]?'}).split('\n') if len(a.strip())] for k,v in data.items()}
filtered = {
k: [a.strip() for a in remove_keys(v, {"<[^>]+>", "[(]?‹[^›]+›[)]?"}).split("\n") if len(a.strip())]
for k, v in data.items()
}

with open('directory.json','r') as f:
with open("directory.json", "r") as f:
directory = json.load(f)

final_description_directory = {}

for k in filtered:
# print(type(k), k)
for unit_building in directory['units_buildings']:
description_look_up_key = directory['units_buildings'][unit_building]["help_converter"]
unit_building_name = directory['units_buildings'][unit_building]["localised_name"]
for unit_building in directory["units_buildings"]:
description_look_up_key = directory["units_buildings"][unit_building]["help_converter"]
unit_building_name = directory["units_buildings"][unit_building]["localised_name"]
if description_look_up_key == int(k):
final_description_directory[unit_building_name] = filtered[k][1]

for k in filtered:
for tech in directory['techs']:
description_look_up_key = directory['techs'][tech]["help_converter"]
tech_name = directory['techs'][tech]["localised_name"]
for tech in directory["techs"]:
description_look_up_key = directory["techs"][tech]["help_converter"]
tech_name = directory["techs"][tech]["localised_name"]
if description_look_up_key == int(k):
final_description_directory[tech_name] = filtered[k][1]


with open('descriptions_cleaned.json', 'w') as json_file:
with open("descriptions_cleaned.json", "w") as json_file:
json.dump(final_description_directory, json_file)
1 change: 1 addition & 0 deletions cog_modules/stats/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
with open("descriptions_cleaned.json") as fp:
descriptions = json.load(fp)


class StatCommands(commands.Cog):
"""Commands for stat commands."""

Expand Down
6,560 changes: 6,559 additions & 1 deletion techTreeInfo.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion techtree_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,5 +370,4 @@
"Elite Ratha": " Bengali unique chariot that can switch between melee and ranged attacks. Strong vs. infantry. Weak vs. Skirmishers and Camel Riders.Upgrades: attack, armor (Blacksmith); speed, hit points (Stable); creation speed (Castle); more resistant to Monks (Monastery). ‹attack› ‹armor› ‹piercearmor› ‹range›",
"Gambesons": " Militia-line receive +1 pierce armor.",
"Bogsveigar": " Archer-line and Longboats receive +1 attack.",

}

0 comments on commit 622a22e

Please sign in to comment.