Skip to content

Add Gameplay status projection query#156

Merged
bartul merged 1 commit into
masterfrom
feat/gameplay-status-projection-query
Jun 7, 2026
Merged

Add Gameplay status projection query#156
bartul merged 1 commit into
masterfrom
feat/gameplay-status-projection-query

Conversation

@bartul

@bartul bartul commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a Gameplay status projection with GameId, InPlay, and NumberOfPlayers.
  • Add a thin Gameplay.getGameplayStatus query facade over projection loading.
  • Move Gameplay into InPlay when Rondel setup completes.
  • Add separated Gameplay query specifications and update Gameplay documentation.

Impact

Callers can query a compact Gameplay status read model without coupling to write-side state. The query dependency can be backed by current state now and by a dedicated projection store later.

Validation

  • dotnet fantomas .
  • dotnet build Imperium.slnx
  • dotnet test
  • dotnet run --no-build --project tests/Imperium.UnitTests/Imperium.UnitTests.fsproj -- --render-spec-markdown

Summary by CodeRabbit

Release Notes

  • New Features

    • Added gameplay status query capability to retrieve current game state, including whether a game is in play and the number of active players.
  • Tests

    • Expanded test coverage for gameplay status queries and initialization tracking.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a7d5968d-adc8-466f-bbb1-0d41ef449375

📥 Commits

Reviewing files that changed from the base of the PR and between 3fd698f and 599e5c2.

📒 Files selected for processing (17)
  • AGENTS.md
  • docs/gameplay.md
  • src/Imperium/Gameplay/Gameplay.fs
  • src/Imperium/Gameplay/Gameplay.fsi
  • src/Imperium/Gameplay/GameplayDependencies.fs
  • src/Imperium/Gameplay/GameplayDependencies.fsi
  • src/Imperium/Gameplay/Projections.fs
  • src/Imperium/Gameplay/Projections.fsi
  • src/Imperium/Gameplay/Queries.fs
  • src/Imperium/Gameplay/Queries.fsi
  • src/Imperium/Imperium.fsproj
  • tests/Imperium.UnitTests/Imperium.UnitTests.fsproj
  • tests/Imperium.UnitTests/Imperium/Gameplay/Assertions.fs
  • tests/Imperium.UnitTests/Imperium/Gameplay/Context.fs
  • tests/Imperium.UnitTests/Imperium/Gameplay/QuerySpecification.fs
  • tests/Imperium.UnitTests/Imperium/Gameplay/Specification.fs
  • tests/Imperium.UnitTests/Main.fs

📝 Walkthrough

Walkthrough

This PR adds a read-side gameplay status query capability to the Gameplay bounded context. It introduces query contracts, projections, read-side dependencies, a public query facade, handler state updates, comprehensive test infrastructure, and documentation clarifications across the query path from contract through projection to result.

Changes

Gameplay Status Query Implementation

Layer / File(s) Summary
Query contracts and read-side dependency wiring
src/Imperium/Gameplay/Queries.fs, src/Imperium/Gameplay/Queries.fsi, src/Imperium/Gameplay/GameplayDependencies.fs, src/Imperium/Gameplay/GameplayDependencies.fsi
GetGameplayStatusQuery record and LoadGameplayStatusProjection/GameplayQueryDependencies read-side abstractions establish the async projection loader interface for query handlers.
Gameplay status projection and read model
src/Imperium/Gameplay/Projections.fs, src/Imperium/Gameplay/Projections.fsi
GameplayStatusView record and GameplayStatusProjection.fromState map GameplayState into queryable snapshots: GameId, InPlay (derived from status), and player count (from roster).
Public facade and handler updates
src/Imperium/Gameplay/Gameplay.fs, src/Imperium/Gameplay/Gameplay.fsi
New Gameplay.getGameplayStatus entry point delegates to internal queries. Handlers.rondelPositionedAtStart transitions to InPlay and extends CompletedInitializations with GameInitialization.Rondel.
Test context and assertion helpers
tests/Imperium.UnitTests/Imperium/Gameplay/Context.fs, tests/Imperium.UnitTests/Imperium/Gameplay/Assertions.fs
Context record gains GetGameplayStatus field. Setup helpers wire GameplayQueryDependencies with status projection and call the query synchronously. Assertion helpers validate status presence, GameId, InPlay, and player count.
Query test specifications and runner integration
tests/Imperium.UnitTests/Imperium/Gameplay/QuerySpecification.fs, tests/Imperium.UnitTests/Imperium/Gameplay/Specification.fs, tests/Imperium.UnitTests/Main.fs
QuerySpecification module defines three behavior specs: unknown game returns None, post-start returns setup status, post-Rondel returns in-play status. Runner visibility changed to internal; markdown and test execution updated to include query specs.
Build configuration and documentation
src/Imperium/Imperium.fsproj, tests/Imperium.UnitTests/Imperium.UnitTests.fsproj, docs/gameplay.md, AGENTS.md
Project files register new Projections and Queries source files. Event Model diagram adds GetGameplayStatus query path; Flow clarifies state transitions and initialization tracking; Queries section documents behavior; Design Notes expanded on contract semantics and facade methods.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • bartul/imperium#149: Modifies the same Handlers.rondelPositionedAtStart flow and CompletedInitializations tracking that the new query projections report.
  • bartul/imperium#144: Introduces PlayerRoster as a Set<PlayerId>, which the new GameplayStatusProjection.fromState depends on for computing NumberOfPlayers.
  • bartul/imperium#145: Updates RondelPositionedAtStartInboundEvent transformation that feeds the handler state changes tracked by the new query projection.

🐰 A query for status takes the stage,
With projections that map our game's page,
Unknown games return none so clear,
While started games bring data dear,
Players counted, in-play state shown,
The query path is now full-grown!

🚥 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 title accurately and concisely describes the main change: adding a Gameplay status projection query capability, which is the primary objective across multiple files (Projections, Queries, and facade).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 feat/gameplay-status-projection-query

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.

@bartul bartul merged commit 904a680 into master Jun 7, 2026
5 checks passed
@bartul bartul deleted the feat/gameplay-status-projection-query branch June 7, 2026 19:28
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