Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace hex with hash string #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions cdragontoolbox/tftdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def parse_character_names(self, map22):
def parse_sets(self, map22, character_names):
"""Parse character sets to a list of `(name, number, characters)`"""
character_lists = {x.path: x for x in map22.entries if x.type == "MapCharacterList"}
set_collection = [x for x in map22.entries if x.type == 0x438850FF]
set_collection = [x for x in map22.entries if x.type == "TFTSetData"]

if not set_collection:
# backward compatibility
Expand All @@ -148,7 +148,7 @@ def parse_sets(self, map22, character_names):
set_number = item.getv("number")
set_mutator = item.getv("Mutator")
char_list = item.getv("characterLists")[0]
set_info = item[0xD2538E5A].value
set_info = item["ScriptData"].value
set_name = set_info["SetName"].getv("mValue")

if set_number is None or set_name is None:
Expand Down Expand Up @@ -177,10 +177,10 @@ def parse_items(self, map22):

items.append({
"id": item.getv("mId"),
"name": item.getv(0xC3143D66),
"desc": item.getv(0x765F18DA),
"name": item.getv("mDisplayNameTra"),
"desc": item.getv("mDescriptionNameTra"),
"icon": item.getv("mIconPath"),
"from": [x.h for x in item.getv(0x8B83BA8A, [])],
"from": [x.h for x in item.getv("mComposition", [])],
"effects": effects,
})
item_ids[item.path.h] = item.getv("mId")
Expand Down Expand Up @@ -216,7 +216,7 @@ def parse_champs(self, map22, traits, character_folder):
champ_traits = [] # trait paths, as hashes
for trait in record.getv("mLinkedTraits", []):
if isinstance(trait, BinEmbedded):
champ_traits.extend(field.value for field in trait.fields if field.name.h == 0x053A1F33)
champ_traits.extend(field.value for field in trait.fields if field.name.h == "TraitData")
else:
champ_traits.append(trait.h)

Expand All @@ -228,7 +228,7 @@ def parse_champs(self, map22, traits, character_folder):

champs[name] = ({
"apiName": record.getv("mCharacterName"),
"name": champ.getv(0xC3143D66),
"name": champ.getv("mDisplayNameTra"),
"cost": rarity + int(rarity / 6),
"icon": champ.getv("mIconPath"),
"traits": [traits[h]["name"] for h in champ_traits if h in traits],
Expand All @@ -245,8 +245,8 @@ def parse_champs(self, map22, traits, character_folder):
"range": record.getv("attackRange", 0) // 180,
},
"ability": {
"name": champ.getv(0x87A69A5E),
"desc": champ.getv(0xBC4F18B3),
"name": champ.getv("mAbilityNameTra"),
"desc": champ.getv("mDescriptionTra"),
"icon": champ.getv("mPortraitIconPath"),
"variables": ability_variables,
},
Expand Down Expand Up @@ -279,8 +279,8 @@ def parse_traits(self, map22):

traits[trait.path] = {
"apiName": trait.getv("mName"),
"name": trait.getv(0xC3143D66),
"desc": trait.getv(0x765F18DA),
"name": trait.getv("mDisplayNameTra"),
"desc": trait.getv("mDescriptionNameTra"),
"icon": trait.getv("mIconPath"),
"effects": effects,
}
Expand Down