Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
EC2 Default User committed Nov 5, 2023
2 parents a9e0622 + 4b692e6 commit 1243ea8
Show file tree
Hide file tree
Showing 9 changed files with 6,647 additions and 32 deletions.
2 changes: 2 additions & 0 deletions ObjectStatistics/full_tech_tree_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def create_localised_name_lookup(category_key: str) -> dict[EntityId, str]:

localised_unit_building_name_lookup = create_localised_name_lookup("units_buildings")

print(localised_unit_building_name_lookup)

# Hardcode a fix for Huskarl because it appears again at "759",
# but "759" does not exist in the other json
localised_unit_building_name_lookup["Huskarl"] = "41"
Expand Down
19 changes: 18 additions & 1 deletion TechTreeProcessing/techtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
name = directory["techs"][str(x)]["localised_name"]
tech_dict[name] = x

castle_age_unique_techs = []
imperial_age_unique_techs = []

for c in civs:
x = techtree["techtrees"][c]["unique"]["castleAgeUniqueUnit"]
name = directory["units_buildings"][str(x)]["localised_name"]
Expand All @@ -59,9 +62,11 @@
x = techtree["techtrees"][c]["unique"]["castleAgeUniqueTech"]
name = directory["techs"][str(x)]["localised_name"]
master_dict[name] = [c]
castle_age_unique_techs.append(name)
x = techtree["techtrees"][c]["unique"]["imperialAgeUniqueTech"]
name = directory["techs"][str(x)]["localised_name"]
master_dict[name] = [c]
imperial_age_unique_techs.append(name)

for item in unit_dict.keys():
master_dict[item] = []
Expand All @@ -88,6 +93,18 @@
if pay in techtree["techtrees"][c]["techs"]:
master_dict[key].append(c)

# Make a json for Castle and Imperial Age unique techs
castle_age_unique_techs.sort()
imperial_age_unique_techs.sort()


<<<<<<< Updated upstream
print(master_dict)
=======
unique_techs = {}
unique_techs["castle_age_unique_techs"] = castle_age_unique_techs
unique_techs["imperial_age_unique_techs"] = imperial_age_unique_techs

with open('unique_techs.json', 'w') as json_file:
json.dump(unique_techs, json_file)
# print(master_dict)
>>>>>>> Stashed changes
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)
24 changes: 12 additions & 12 deletions cog_modules/random/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

load_dotenv()
CATS = os.getenv("x-api-key")
botDMs = int(os.getenv("DMChannel"))
botID = int(os.getenv("BOTID"))
# botDMs = int(os.getenv("DMChannel"))
# botID = int(os.getenv("BOTID"))


class Random(commands.Cog):
Expand Down Expand Up @@ -105,16 +105,16 @@ async def gizmo_or_tao(self, ctx: commands.Context):
# Checks to see if someone DMs the bot
# If so, it forwards the message to a specific channel and replies to the
# person who sent the message
@commands.Cog.listener()
async def on_message(self, message):
if isinstance(message.channel, discord.DMChannel): # if the message is a DM
channel = self.bot.get_channel(botDMs) # get channel to forward message to
if message.author.id != botID: # make sure we're not forwarding/sending messages when the bot messages
newMessage = discord.Embed(
title=f"New bot DM from `{message.author}`", description=f"{message.content}", timestamp=message.created_at
)
await channel.send(embed=newMessage) # forwards message to channel
await self.bot.process_commands(message)
# @commands.Cog.listener()
# async def on_message(self, message):
# if isinstance(message.channel, discord.DMChannel): # if the message is a DM
# channel = self.bot.get_channel(botDMs) # get channel to forward message to
# if message.author.id != botID: # make sure we're not forwarding/sending messages when the bot messages
# newMessage = discord.Embed(
# title=f"New bot DM from `{message.author}`", description=f"{message.content}", timestamp=message.created_at
# )
# await channel.send(embed=newMessage) # forwards message to channel
# await self.bot.process_commands(message)


async def setup(bot: commands.Bot):
Expand Down
42 changes: 36 additions & 6 deletions cog_modules/stats/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
with open("descriptions_cleaned.json") as fp:
descriptions = json.load(fp)

<<<<<<< Updated upstream
=======
# Load the unique_techs.json file as unique_techs
with open("unique_techs.json") as fp:
unique_techs = json.load(fp)
>>>>>>> Stashed changes

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

Expand Down Expand Up @@ -82,9 +89,21 @@ async def statInfo(self, ctx: commands.Context, arg1, arg2=None, arg3=None, arg4
embed = discord.Embed(title=f"{input} Stats", description=f"Information about {input}s.", color=0xD5D341)
else:
embed = discord.Embed(title=f"{input} Stats", description=f"Information about {input}.", color=0xD5D341)
embed.set_thumbnail(
url=f"https://raw.githubusercontent.com/SiegeEngineers/aoe2techtree/master/img/{entityDirectory}/{unitBuildNum}.png"
)

# Check to see if entity is a Castle Age Unique Tech
if input in unique_techs["castle_age_unique_techs"]:
embed.set_thumbnail(
url=f"https://raw.githubusercontent.com/SiegeEngineers/aoe2techtree/master/img/{entityDirectory}/unique_tech_1.png"
)
# Check to see if entity is a Castle Age Unique Tech
elif input in unique_techs["imperial_age_unique_techs"]:
embed.set_thumbnail(
url=f"https://raw.githubusercontent.com/SiegeEngineers/aoe2techtree/master/img/{entityDirectory}/unique_tech_2.png"
)
else:
embed.set_thumbnail(
url=f"https://raw.githubusercontent.com/SiegeEngineers/aoe2techtree/master/img/{entityDirectory}/{unitBuildNum}.png"
)
embed.add_field(name="Cost", value=costString2, inline=True)

if entity == "techs":
Expand Down Expand Up @@ -170,9 +189,20 @@ async def advstatInfo(self, ctx: commands.Context, arg1, arg2=None, arg3=None, a
else:
embed = discord.Embed(title=f"{input} Stats", description=f"Information about {input}.", color=0xD5D341)

embed.set_thumbnail(
url=f"https://raw.githubusercontent.com/SiegeEngineers/aoe2techtree/master/img/{entityDirectory}/{unitBuildNum}.png"
)
# Check to see if entity is a Castle Age Unique Tech
if input in unique_techs["castle_age_unique_techs"]:
embed.set_thumbnail(
url=f"https://raw.githubusercontent.com/SiegeEngineers/aoe2techtree/master/img/{entityDirectory}/unique_tech_1.png"
)
# Check to see if entity is a Castle Age Unique Tech
elif input in unique_techs["imperial_age_unique_techs"]:
embed.set_thumbnail(
url=f"https://raw.githubusercontent.com/SiegeEngineers/aoe2techtree/master/img/{entityDirectory}/unique_tech_2.png"
)
else:
embed.set_thumbnail(
url=f"https://raw.githubusercontent.com/SiegeEngineers/aoe2techtree/master/img/{entityDirectory}/{unitBuildNum}.png"
)
embed.add_field(name="Cost", value=costString2, inline=True)

if entity == "techs":
Expand Down
3 changes: 3 additions & 0 deletions full_tech_tree_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def create_localised_name_lookup(category_key):
localised_name_lookup = {}

for key, value in directory[category_key].items():
# print(key, value["localised_name"])
if value["localised_name"] in localised_name_lookup:
localised_name_lookup[value["localised_name"]] = str(
min(int(key), int(localised_name_lookup[value["localised_name"]]))
Expand Down Expand Up @@ -49,6 +50,8 @@ def create_localised_name_lookup(category_key):
localised_unit_building_name_lookup["Monastery"] = "104"
localised_unit_building_name_lookup["Condottiero"] = "882"
localised_unit_building_name_lookup["Villager"] = "83"
localised_unit_building_name_lookup["Gate"] = "487"
localised_unit_building_name_lookup["Palisade Gate"] = "792"


# This list comes from this java script file.
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.",

}
1 change: 1 addition & 0 deletions unique_techs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"castle_age_unique_techs": ["Anarchy", "Andean Sling", "Atlatl", "Ballistas", "Bearded Axe", "Bimaristan", "Burgundian Vineyards", "Carrack", "Chatras", "Chieftains", "Cilician Fleet", "Corvinian Army", "Detinets", "Eupseong", "First Crusade", "Grand Trunk Road", "Great Wall", "Greek Fire", "Hill Forts", "Hul'che Javelineers", "Inquisition", "Ironclad", "Kamandaran", "Kasbah", "Kshatriyas", "Manipur Cavalry", "Marauders", "Medical Corps", "Nomads", "Paiks", "Pavise", "Royal Heirs", "Silk Armor", "Sipahi", "Steppe Husbandry", "Stirrups", "Stronghold", "Svan Towers", "Szlachta Privileges", "Thalassocracy", "Tigui", "Tusk Swords", "Wagenburg Tactics", "Yasama", "Yeomen"], "imperial_age_unique_techs": ["Arquebus", "Artillery", "Atheism", "Aznauri Cavalry", "Bagains", "Bogsveigar", "Chivalry", "Citadels", "Comitatenses", "Counterweights", "Crenellations", "Cuman Mercenaries", "Double Crossbow", "Drill", "Druzhina", "El Dorado", "Fabric Shields", "Farimba", "Fereters", "Flemish Revolution", "Forced Levy", "Frontier Guards", "Furor Celtica", "Garland Wars", "Hauberk", "Howdah", "Hussite Reforms", "Kataparuto", "Lechitic Legacy", "Logistica", "Maghrebi Camels", "Mahayana", "Paper Money", "Perfusion", "Recurve Bow", "Rocketry", "Shatagni", "Shinkichon", "Silk Road", "Supremacy", "Timurid Siegecraft", "Torsion Engines", "Tower Shields", "Warwolf", "Wootz Steel"]}

0 comments on commit 1243ea8

Please sign in to comment.