Skip to content

import affix data from d4data#755

Open
chrizzocb wants to merge 5 commits into
d4lfteam:mainfrom
chrizzocb:affix-data-from-d4data
Open

import affix data from d4data#755
chrizzocb wants to merge 5 commits into
d4lfteam:mainfrom
chrizzocb:affix-data-from-d4data

Conversation

@chrizzocb
Copy link
Copy Markdown
Contributor

validated with uv run python -m src.tools.gen_data d4data

gen_data.py still depended on D4Companion/Data/Affixes.*.json; AffixManager.cs only consumes that data, while the real string-building logic is in D4DataParser/Parsers/AffixParser.cs.

Code change: Ported the relevant Companion affix parsing/localisation logic into src/tools/gen_data.py, starting from json/base/meta/Affix/*.json, while keeping the generated assets/lang/enUS/affixes.json format unchanged. Added a few existing fallback keys to custom_affixes_enUS.json.

Impact: Existing affix keys/values are preserved. The generated enUS affix output matches the current file exactly.

validated with uv run python -m src.tools.gen_data d4data

gen_data.py still depended on D4Companion/Data/Affixes.*.json; AffixManager.cs only consumes that data, while the real string-building logic is in D4DataParser/Parsers/AffixParser.cs.

Code change: Ported the relevant Companion affix parsing/localisation logic into src/tools/gen_data.py, starting from json/base/meta/Affix/*.json, while keeping the generated assets/lang/enUS/affixes.json format unchanged. Added a few existing fallback keys to custom_affixes_enUS.json.

Impact: Existing affix keys/values are preserved. The generated enUS affix output matches the current file exactly.
Copy link
Copy Markdown
Contributor

@cjshrader cjshrader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Removed, this was addressed)

Comment thread src/tools/gen_data.py Outdated
return json.load(file)


def unsigned_int(value: int) -> int:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a method is only one line long let's remove it please, we can just repeat this code where necessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update2

unsigned_int() was a one-line wrapper around value % (2**32) and only used inside src/tools/gen_data.py

Comment thread src/tools/gen_data.py Outdated
"c_mythic": "Mythic",
}

CROWD_CONTROL_TYPES = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I knew a lot of these maps would be necessary and expected them, but do you think we could move them to a different file at least? Maybe a gen_data_helpers.py?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see update3

@josdemmers
Copy link
Copy Markdown

Noticed this PR when looking through the repo.
The Holy Damage affixes was fixed in the data parser earlier this month. Previously I localized it as non-physical.
The mapping I used to find the correct localization strings for damage types was no longer correct since season 13.

Here is an example for Holy Damage ingame:
image

@cjshrader
Copy link
Copy Markdown
Contributor

Thank you @josdemmers! So it is a real affix, it's just a temper. One struggle I've had is I can't find an authoritative list of every affix in the game to compare against our list.

I don't know if you know this but we used to just get our affixes from your data. Which has worked fine of course, but I didn't like having a reliance on two different repos (yours and d4data) for ours to function. I asked @chrizzocb here to unleash his AI to break that dependency, but in a way I also wanted to keep it how it was because it meant you had to handle missing affixes instead of me. Oh well.

@josdemmers
Copy link
Copy Markdown

In the past there was this list: https://www.d4craft.com/affixes
Too bad the last update was from season 5. I'm not aware of a similar website that is up-to-date.

But feel free to use my parsed data when needed. That's why it's open source.

Like you, I also wanted to look into the affixes/aspects to check if they are actually being used in game. But haven't found a good solution for that yet.
Season 13 (Expansion) especially took some time because both pre- and current season aspects remain in the game data. So you now have aspects with the exact same name but with different descriptions.

cjshrader and others added 3 commits May 26, 2026 13:54
unsigned_int() was a one-line wrapper around value % (2**32) and only used inside src/tools/gen_data.py
move MAPS to a different file.

gen_data_helpers.py

verified with
uv run python -m src.tools.gen_data d4data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants