Skip to content

feat(helpers): accept type-prefixed enum names in guild roles and item names - #264

Merged
MarTrepodi merged 1 commit into
developfrom
feat/type-prefixed-enum-names
Nov 9, 2026
Merged

MarTrepodi merged 1 commit into
developfrom
feat/type-prefixed-enum-names

Conversation

@MarTrepodi

@MarTrepodi MarTrepodi commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Makes the guild-role and mod helpers accept a second spelling of enum names. With enums=True, the public Comlink sends bare member names (GUILD_MEMBER, SIX_STAR, STATMOD_SLOT_02), which the helpers already read. A server may instead prefix a value with its enum type and drop the inner underscores (GUILDMEMBERLEVEL_GUILDMEMBER, RARITY_SIXSTAR, STATMODSLOT_STATMODSLOT02). Before this change that spelling read as unknown: a member's role came back as None, and mod slots, tiers and rarities as 0 or ?.

Helper Change
get_guild_activity memberLevel is resolved through parse_enum(..., enum_name="GuildMemberLevel"). The redundant "1"–"4" keys are dropped from the role table, since parse_enum reads numbers directly.
get_mod_catalog, ItemNames (mystery mods, item_type_number) _as_int takes the enum's type name (StatModSlot, StatModTier, Rarity, ItemType) and resolves names through parse_enum.
_territory_battle.py Comment only: territoryBattleVersion_3 is the spelling current servers send; territoryBattleVersion3 stays accepted for older ones.

The prefix is checked, not stripped: it must match the enum's own type name, so a value from another enum (RARITY_GUILDMEMBER) is still rejected rather than misread.

Related Issues

None.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactor (code change that neither fixes a bug nor adds a feature)
  • Performance improvement
  • Documentation
  • Tests
  • CI / build / dependencies

Checklist

  • This PR targets the develop branch (only release PRs target main)
  • My commits follow the Conventional Commits / Angular convention (feat:, fix:, refactor:, etc.) — they become the changelog
  • I have not edited CHANGELOG.md by hand (it is generated from commit messages)
  • I have added/updated docstrings with type hints for any new or changed public methods
  • I have updated the docs (README.md, docs/, examples/) if user-facing behavior changed
  • I have added unit tests that cover my changes (mocked, not requiring a live comlink service)
  • Tests pass (uv run pytest tests/)
  • Ruff linter and formatter pass (uv run ruff check src/ tests/ and uv run ruff format --check src/ tests/)
  • Type check passes (uv run ty check src/swgoh_comlink/)
  • I have not bundled unrelated changes in this PR

Testing

Unit: new cases cover the prefixed spelling for guild roles, mod slots, tiers, rarities and item types, and a wrong prefix being rejected (RARITY_GUILDMEMBER → (None, None); a mod with swapped prefixes → slot and rarity 0). The territory battle fixture uses the current flag spelling, with the older one moved to a legacy test. pytest tests/: 1999 passed, 31 skipped; 100% coverage on _guild.py, _items.py and _territory_battle.py. Ruff, ty check src/swgoh_comlink/ and commitlint pass.

Live, against the public Comlink release (spec 0.40.5, game data 0.41.0): fetched a guild with recent activity and the statMod, statModSet, mysteryStatMod and territoryBattleDefinition collections, each with and without enums=True, then ran get_guild_activity, get_mod_catalog and ItemNames on both develop and this branch:

  • The public server sends only the bare spelling, which both versions already read: every member's role resolved, 0 of 288 mod definitions and 0 of 694 mystery mods unreadable.
  • The branch's output is byte-identical to develop's on all of it, with and without enums=True, so there is no regression for public users.

No example uses these helpers, so none needed a live run.

🤖 Generated with Claude Code

…m names

With enums=True, the public Comlink sends bare enum member names
(GUILD_MEMBER, SEVEN_STAR, STATMOD_SLOT_02), which the helpers already
read. A server may instead spell a value with its enum type as a prefix
and no inner underscores (GUILDMEMBERLEVEL_GUILDMEMBER, RARITY_SEVENSTAR,
STATMODSLOT_STATMODSLOT02). get_guild_activity and
ItemNames/get_mod_catalog did not recognise that spelling: a member's
role read as None and mod slots, tiers and rarities as unknown.

Both now resolve names through parse_enum, which reads either spelling
and checks the prefix against the enum's own type name, so a value from
another enum is still rejected. Results for the bare spelling and for
numbers are unchanged.

Also update the territoryBattleVersion_3 comment: it is the spelling
current servers send, and territoryBattleVersion3 is kept for older ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MarTrepodi
MarTrepodi merged commit beff74a into develop Nov 9, 2026
18 checks passed
@MarTrepodi
MarTrepodi deleted the feat/type-prefixed-enum-names branch November 9, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant