Repository navigation
feat(helpers): add get_era_units for an Era's unit roster - #196
Merged
Merged
Conversation
List the base ids of an Era's units from the game data eraDefinition collection: its eraUnitId roster plus its journey unit, with the units it loans to players added on request (include_loaned=True). With no era_id the Era active now is read, its window taken as half-open since consecutive Eras share their boundary millisecond. 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
Adds
get_era_units, a pure helper over the game dataeraDefinitioncollection that lists the base ids of an Era's units. With noera_idit reads the Era active now.get_game_data()response or itseraDefinitionlist, likeget_event_schedule.eraUnitIdroster plus itsjourneyUnit(normally already in the roster).loanedUnitentries (older units lent for the Era's episodes) are opt-in viainclude_loaned=True. Results are deduplicated in game data order.[startTimeMs, endTimeMs): consecutive Eras share their boundary millisecond, so exactly one Era is active at a changeover.[]; an unknownera_idraisesSwgohComlinkValueErrorlisting the available ids.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
tests/unit/test_helpers.py(TestGetEraUnits) over a trimmed copy of live game data: active-Era default, the shared boundary millisecond, named Era, loaned units and dedupe, journey unit outside the roster, no active Era, naivenow, and invalid input.tests/unit/test_helpers_mocked.pyfeeds the helper a real sync and asyncget_game_data()response.mkdocs build --strictpasses with the new "Era Helpers" section indocs/api/helpers.md.enums=Falseandenums=True): the active Era (ERA10) and each of ERA08–ERA10 match the raweraDefinitiondata.🤖 Generated with Claude Code