Repository navigation
feat(helpers): accept type-prefixed enum names in guild roles and item names - #264
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 asNone, and mod slots, tiers and rarities as0or?.get_guild_activitymemberLevelis resolved throughparse_enum(..., enum_name="GuildMemberLevel"). The redundant"1"–"4"keys are dropped from the role table, sinceparse_enumreads numbers directly.get_mod_catalog,ItemNames(mystery mods,item_type_number)_as_inttakes the enum's type name (StatModSlot,StatModTier,Rarity,ItemType) and resolves names throughparse_enum._territory_battle.pyterritoryBattleVersion_3is the spelling current servers send;territoryBattleVersion3stays 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
Checklist
developbranch (only release PRs targetmain)feat:,fix:,refactor:, etc.) — they become the changelogCHANGELOG.mdby hand (it is generated from commit messages)README.md,docs/,examples/) if user-facing behavior changeduv run pytest tests/)uv run ruff check src/ tests/anduv run ruff format --check src/ tests/)uv run ty check src/swgoh_comlink/)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 rarity0). 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.pyand_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,mysteryStatModandterritoryBattleDefinitioncollections, each with and withoutenums=True, then ranget_guild_activity,get_mod_catalogandItemNameson bothdevelopand this branch:develop's on all of it, with and withoutenums=True, so there is no regression for public users.No example uses these helpers, so none needed a live run.
🤖 Generated with Claude Code