Skip to content

CC-73: Add Great War Support#7

Merged
ianpaschal merged 8 commits into
mainfrom
ian/cc-73-add-great-war-support
Jun 5, 2026
Merged

CC-73: Add Great War Support#7
ianpaschal merged 8 commits into
mainfrom
ian/cc-73-add-great-war-support

Conversation

@ianpaschal

@ianpaschal ianpaschal commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Resolves CC-73

Summary by CodeRabbit

  • New Features

    • Added support for Great War (4th Edition) game system with faction, alignment, force diagram, and unit selections.
    • Introduced validated list/roster building with comprehensive error messaging and legality constraints.
    • Added mission pack selection and outcome validation for Great War V4.
  • Documentation

    • Updated game system display names for clarity and consistency.
    • Marked registration details as deprecated in favor of new list data schema.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: db50c893-17d0-49bd-b348-087fbcc0c249

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR introduces the Great War (4th Edition) game system and refactors list-building schema validation. The refactor replaces game-system-specific registrationDetails with a shared, generic createListDataSchema factory that works across all systems. New foundational utilities include a listDataId schema validator and a getIssueMessages test fixture helper. The schema factory includes comprehensive cross-field validators for metadata (force diagrams, factions, alignments, eras) and entity constraints (formations, units, command cards). Flames of War V4 and Team Yankee V2 are wired to use the new schema alongside enhanced force-diagram helpers. Great War V4 is introduced with complete static data (alignments, factions, force diagrams, units, missions, points versions), schemas, and test coverage. System registration in common helpers is extended to support the new game system.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly describes the primary change: adding support for the Great War game system to the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ian/cc-73-add-great-war-support

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 11

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/battlefront/_shared/_internal/createGetForceDiagramData.ts`:
- Around line 42-43: The deprecated function createGetForceDiagramData uses
unsafe non-null assertions on data.series (references: series and
seriesDisplayName) which can crash if series is undefined; update the function
to check for existence of data.series and series[data.series] before indexing,
and either return a safe fallback object (e.g., with series: undefined and
seriesDisplayName: ''/null) or throw a clear runtime error indicating callers
must migrate to getForceDiagramSeries/getForceDiagramAlignment; ensure you
reference the symbols data.series, series, and series[data.series] when adding
the null checks so the function no longer dereferences undefined.

In `@src/battlefront/_shared/schema/listData.validators.ts`:
- Around line 242-277: The validator uses generic paths like ['formations']
which hide which array item failed; update validateFormation (and the analogous
unit validator) to accept an item index (e.g., formationIndex: number) from the
caller and include it in ctx.addIssue paths (e.g., ['formations',
formationIndex]) so errors point to the exact item; locate calls where
formations/units are iterated (the listData.ts iteration mentioned) and pass the
current index through to validateFormation/validateUnit to ensure all
ctx.addIssue calls include the index.
- Around line 242-277: In validateFormation, the error message for missing
sourceSeriesKey is misleading because sourceSeriesKey can be undefined either
when the sourceForceDiagram key is absent from context.forceDiagrams or when the
force diagram exists but has no series; update the logic to first check whether
context.forceDiagrams hasOwnProperty(sourceData.sourceForceDiagram) (or use the
in operator) and emit the "unrecognized force diagram" zod issue only when the
key is absent, then only attempt to read sourceSeriesKey and perform the era
comparison (and emit the era-mismatch issue) if a series value exists; if the
diagram key exists but series is undefined, skip validation instead of emitting
the unrecognized error.
- Around line 316-362: In validateUnit, change the logic around sourceSeriesKey
so you first detect whether sourceData.sourceForceDiagram is a known key in
context.forceDiagrams (e.g., using the `in` operator or hasOwnProperty) and only
emit "Unit source has an unrecognized force diagram." when that key is missing;
if the key exists but context.forceDiagrams[sourceForceDiagram]?.series is
undefined, skip the era compatibility check (do not emit the unrecognized error)
and only perform the era comparison when a series value is present (i.e., when
sourceSeriesKey is truthy) so that recognized force diagrams lacking series
metadata don't produce the misleading error.

In `@src/battlefront/greatWarV4/schema/gameSystemConfig.test.ts`:
- Line 9: Fix the import formatting by adding a space after the comma between
the two imported symbols; update the import line that currently reads "import {
GameSystemConfig,gameSystemConfig } from './gameSystemConfig';" to "import {
GameSystemConfig, gameSystemConfig } from './gameSystemConfig';" so both
GameSystemConfig and gameSystemConfig are properly separated.

In `@src/battlefront/greatWarV4/schema/gameSystemConfig.ts`:
- Around line 14-26: The schema declares pointsVersion as optional but
superRefine calls isPointsVersionValid which treats a missing value as invalid;
make pointsVersion required by removing z.optional around
createEnumSchema(PointsVersion) so the schema and validator agree (adjusting the
createEnumSchema usage for pointsVersion), ensuring the superRefine check on
isPointsVersionValid and the error path ['dynamicPointsVersion'] behave
consistently with the tests.
- Line 13: The points schema currently uses z.coerce.number() with no
constraints, allowing zero, negative or absurdly large values; update the schema
for the points field in gameSystemConfig (the "points" property) to enforce
valid values by adding validators such as .int().min(1) or .positive() and
(optionally) a sensible .max(...) threshold (e.g. 1_000_000) to prevent
unreasonable inputs; ensure you keep z.coerce.number() as the base so strings
are coerced but append the chosen chain (.int().min(1) or .positive().max(...))
to the points definition.

In `@src/battlefront/greatWarV4/schema/gameSystemConfig.validators.ts`:
- Around line 3-10: The function isPointsVersionValid currently uses an if/else
to return true/false; simplify it to a single return of the boolean expression
by returning !!values.pointsVersion (or Boolean(values.pointsVersion)) directly
in isPointsVersionValid, referencing the GameSystemConfig parameter to preserve
types and behavior.

In `@src/battlefront/greatWarV4/schema/listData.test.ts`:
- Around line 16-26: The test fixture validData declares ForceDiagram.American
and Faction.UnitedStates but uses the British unit constant Unit.GWB101; change
the unit references in the formation (id 'form00') and unit (id 'unit00') to an
American unit constant (e.g., Unit.GWU101 / GWU107 / GWU118) so the formation
and unit entries match the meta (ForceDiagram.American / Faction.UnitedStates)
and keep validData semantically consistent.

In `@src/common/schemas/listDataId.ts`:
- Around line 5-6: The local errorMap option in listDataId.ts is typed as
errorMap?: () => { message: string } which prevents callers from using Zod's
(issue, ctx) parameters; update the type of errorMap to match Zod's signature
(accepting issue and ctx) and import the appropriate Zod types (e.g., ZodIssue
and the error-map/context type from zod) so errorMap?: (issue: ZodIssue, ctx: /*
Zod error map ctx type */) => { message: string } and callers can access
issue/ctx in a type-safe way.

In `@src/common/static/gameSystems.ts`:
- Around line 7-17: Update the inline comment above the GreatWarV4 enum entry to
correct the spelling mistake: change "pervious" to "previous" in the explanatory
block comment that starts before GreatWarV4 = 'great_war_v4' so the comment
reads "previous versions" instead of "pervious versions".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 911ebda0-b3bc-45f8-a356-41118162e5a1

📥 Commits

Reviewing files that changed from the base of the PR and between 9efa6a1 and 840cc05.

📒 Files selected for processing (51)
  • src/battlefront/_shared/_fixtures/getIssueMessages.test.ts
  • src/battlefront/_shared/_fixtures/getIssueMessages.ts
  • src/battlefront/_shared/_internal/createGetForceDiagramData.ts
  • src/battlefront/_shared/schema/commandCard.ts
  • src/battlefront/_shared/schema/formation.ts
  • src/battlefront/_shared/schema/listData.test.ts
  • src/battlefront/_shared/schema/listData.ts
  • src/battlefront/_shared/schema/listData.validators.ts
  • src/battlefront/_shared/schema/matchResultDetails.test.ts
  • src/battlefront/_shared/schema/registrationDetails.ts
  • src/battlefront/_shared/schema/unit.ts
  • src/battlefront/_shared/static/rankingFactors.ts
  • src/battlefront/_shared/types.ts
  • src/battlefront/flamesOfWarV4/index.ts
  • src/battlefront/flamesOfWarV4/schema/gameSystemConfig.ts
  • src/battlefront/flamesOfWarV4/schema/listData.test.ts
  • src/battlefront/flamesOfWarV4/schema/listData.ts
  • src/battlefront/flamesOfWarV4/schema/registrationDetails.ts
  • src/battlefront/flamesOfWarV4/static/forceDiagrams.ts
  • src/battlefront/greatWarV4/index.ts
  • src/battlefront/greatWarV4/schema/gameSystemConfig.test.ts
  • src/battlefront/greatWarV4/schema/gameSystemConfig.ts
  • src/battlefront/greatWarV4/schema/gameSystemConfig.validators.ts
  • src/battlefront/greatWarV4/schema/listData.test.ts
  • src/battlefront/greatWarV4/schema/listData.ts
  • src/battlefront/greatWarV4/schema/matchResultDetails.ts
  • src/battlefront/greatWarV4/static/alignments.ts
  • src/battlefront/greatWarV4/static/factions.ts
  • src/battlefront/greatWarV4/static/forceDiagrams.ts
  • src/battlefront/greatWarV4/static/missionNames.ts
  • src/battlefront/greatWarV4/static/missionPackUtils.ts
  • src/battlefront/greatWarV4/static/missionPackVersions.ts
  • src/battlefront/greatWarV4/static/pointsVersions.ts
  • src/battlefront/greatWarV4/static/units.ts
  • src/battlefront/greatWarV4/types.ts
  • src/battlefront/teamYankeeV2/index.ts
  • src/battlefront/teamYankeeV2/schema/listData.test.ts
  • src/battlefront/teamYankeeV2/schema/listData.ts
  • src/battlefront/teamYankeeV2/schema/registrationDetails.ts
  • src/battlefront/teamYankeeV2/static/forceDiagrams.ts
  • src/battlefront/teamYankeeV2/static/units.ts
  • src/common/_fixtures/gameSystemFixtures.ts
  • src/common/_internal/createEnumSchema.test.ts
  • src/common/_internal/createEnumSchema.ts
  • src/common/helpers/getGameSystem.ts
  • src/common/helpers/validateGameSystemConfig.ts
  • src/common/helpers/validateMatchResultDetails.ts
  • src/common/schemas/listDataId.ts
  • src/common/static/gameSystems.ts
  • src/common/static/tournamentPairingMethods.ts
  • src/common/types.ts

Comment thread src/battlefront/_shared/_internal/createGetForceDiagramData.ts
Comment thread src/battlefront/_shared/schema/listData.validators.ts
Comment thread src/battlefront/_shared/schema/listData.validators.ts
Comment thread src/battlefront/greatWarV4/schema/gameSystemConfig.test.ts Outdated
Comment thread src/battlefront/greatWarV4/schema/gameSystemConfig.ts
Comment thread src/battlefront/greatWarV4/schema/gameSystemConfig.ts
Comment thread src/battlefront/greatWarV4/schema/gameSystemConfig.validators.ts
Comment thread src/battlefront/greatWarV4/schema/listData.test.ts
Comment thread src/common/schemas/listDataId.ts Outdated
Comment thread src/common/static/gameSystems.ts
@ianpaschal
ianpaschal merged commit cb91845 into main Jun 5, 2026
5 checks passed
@ianpaschal
ianpaschal deleted the ian/cc-73-add-great-war-support branch June 5, 2026 07:26
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.

1 participant