Skip to content

feat(helpers): add get_era_units for an Era's unit roster - #196

Merged
MarTrepodi merged 1 commit into
developfrom
feat/era-units
Oct 22, 2026
Merged

MarTrepodi merged 1 commit into
developfrom
feat/era-units

Conversation

@MarTrepodi

Copy link
Copy Markdown
Collaborator

Description

Adds get_era_units, a pure helper over the game data eraDefinition collection that lists the base ids of an Era's units. With no era_id it reads the Era active now.

game_data = comlink.get_game_data(items=DataItems.ERA_DEFINITION)
get_era_units(game_data)                       # active Era, e.g. ['ADELPHIRANGER', 'B1MERCDROID']
get_era_units(game_data, "ERA09_MYTHS")        # a named Era
get_era_units(game_data, include_loaned=True)  # also the units the Era loans to players
  • Accepts the whole get_game_data() response or its eraDefinition list, like get_event_schedule.
  • An Era's own units are its eraUnitId roster plus its journeyUnit (normally already in the roster). loanedUnit entries (older units lent for the Era's episodes) are opt-in via include_loaned=True. Results are deduplicated in game data order.
  • Era windows are read as half-open [startTimeMs, endTimeMs): consecutive Eras share their boundary millisecond, so exactly one Era is active at a changeover.
  • No active Era returns []; an unknown era_id raises SwgohComlinkValueError listing the available ids.
  • Makes no endpoint call, so it is public-safe.

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

  • 11 unit tests in 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, naive now, and invalid input.
  • A mocked case in tests/unit/test_helpers_mocked.py feeds the helper a real sync and async get_game_data() response.
  • Full unit suite (1550 tests) passes; mkdocs build --strict passes with the new "Era Helpers" section in docs/api/helpers.md.
  • Ran live against a Comlink instance with both clients (enums=False and enums=True): the active Era (ERA10) and each of ERA08–ERA10 match the raw eraDefinition data.

🤖 Generated with Claude Code

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>
@github-actions github-actions Bot added documentation Improvements or additions to documentation code testing labels Oct 22, 2026
@MarTrepodi
MarTrepodi merged commit a33e7c3 into develop Oct 22, 2026
16 checks passed
@MarTrepodi
MarTrepodi deleted the feat/era-units branch October 22, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code documentation Improvements or additions to documentation testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant