test(engine): Halving Season opponent token halving runtime#3497
Conversation
Verify CreateToken replacement with Half + Opponent scope reduces count 5→2. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Code Review
This pull request adds a new unit test, halving_season_halves_opponent_token_creation, to crates/engine/src/game/replacement.rs. The test verifies that a replacement effect configured to halve token creation for an opponent correctly reduces a proposed batch of five tokens to two (rounding down), in accordance with CR 614.1a and CR 111.1. No review comments were provided, and the changes are idiomatic and compliant with the repository's style guide, so there is no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
matthewevans
left a comment
There was a problem hiding this comment.
Maintainer review — ENQUEUE-READY (test PR)
Verdict: looks good. This is a runtime test that drives the real replacement pipeline and discriminates.
Test discrimination — PASS
halving_season_halves_opponent_token_creation constructs a ReplacementDefinition::new(ReplacementEvent::CreateToken).quantity_modification(Half).token_owner_scope(Opponent), then calls the actual replace_event(...) with a ProposedEvent::CreateToken { count: 5, owner: PlayerId(1) } and asserts the surviving count == 2. If the Half halving (replacement.rs:1922 / 2058, count / 2) or the token_owner_scope applicability gate (replacement.rs:3655) were reverted, the count would stay 5 and the assertion would fail. This is a genuine pipeline test, not an AST-shape assertion.
Notes
- The engine logic under test (
QuantityModification::Halfhalving +token_owner_scope(Opponent)enforcement) already exists onmain— the test constructs theReplacementDefinitiondirectly, so it is independent of the parser PR #3495 at the engine layer. The body's "Depends on #3495" is a parser-side dependency (parsing the Oracle text into this definition), not a compile/run dependency for this test. Confirmed it compiles against currentmain. 5 / 2 = 2round-down is correct per integer division; the comment ("rounded down") matches.- CR annotation
CR 614.1a + CR 111.1is appropriate (replacement effect modifying a token-creation event).
Clean, discriminating, no production behavior change. Approving.
Summary
halving_season_halves_opponent_token_creationreplacement testTest plan
cargo test -p engine --lib halving_season_halves_opponentCloses #3496. Depends on parser PR #3495.
Made with Cursor