Skip to content

Fix duration-0 one-time rewards expiring before consumption - #321

Merged
joryirving merged 3 commits into
mainfrom
foreman/wl-misospace-windowstead-311/issue-311
Aug 8, 2026
Merged

Fix duration-0 one-time rewards expiring before consumption#321
joryirving merged 3 commits into
mainfrom
foreman/wl-misospace-windowstead-311/issue-311

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Tests fail due to missing godot runtime in environment; cannot verify goal reward or progression logic.

Fixes #311

Opened by foreman on review GO (workload wl-misospace-windowstead-311).

tick_rewards() now skips the expiration check for rewards with
duration == 0 (one-time), allowing REWARD_RECRUIT_DISCOUNT and
REWARD_AMBIENT_IMPROVE to persist until consumed by their
consume_* helpers. Previously these expired on the very next tick
after being awarded, making them unusable in normal gameplay.

Adds 5 regression tests covering:
- One-time rewards surviving 70 ticks (past EVENT_INTERVAL_TICKS)
- consume_recruit_discount and consume_ambient_improve removing rewards
- Timed rewards (duration > 0) still expiring on schedule

Fixes #311

Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
@itsmiso-ai
itsmiso-ai requested a review from joryirving as a code owner August 8, 2026 16:53
its-saffron[bot]

This comment was marked as outdated.

@its-saffron its-saffron 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.

AI Automated Review (incremental)

Incremental review: reviewed the changes since the last managed review; unresolved findings from that review are carried forward.

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic) — escalated (fast_low_confidence)

Recommendation: Approve

This PR fixes the reported bug where duration-0 one-time rewards (build_workshop → recruit discount, build_garden → ambient improve) expired on the first tick_rewards call before they could be consumed. The incremental review delta contains test-only refinements; the core fix in scripts/goal_reward.gd was introduced in the preceding commit on the branch.

Change-by-Change Findings

tests/test_goal_reward.gd — test refinements

  1. test_one_time_ambient_improve_survives_ticks — Added optional assertion messages ("build_garden grants an ambient improve", "Ambient improve is a one-time reward") to two assert_eq calls. No behavioral change; improves failure readability.

  2. test_consume_recruit_discount_removes_one_time_reward and test_consume_ambient_improve_removes_one_time_reward — Added "Reward is active before consumption" message to the pre-consumption size assertion. Minor clarity improvement; no logic change.

  3. test_timed_reward_still_expires_on_scheduleKey test correction. The loop boundary changed from range(DURATION_RESOURCE_TRICKLE) to range(DURATION_RESOURCE_TRICKLE + 1), with an explanatory comment:

    "tick_rewards checks remaining <= 0 BEFORE decrementing, so a reward created with remaining == duration survives duration ticks and expires on the next one."

    This correctly validates that the duration-0 guard does not break the existing timed-reward expiry path. The test now properly observes expiry after DURATION_RESOURCE_TRICKLE + 1 ticks.

Standards Compliance

No AGENTS.md conventions are relevant to this change. The repository standards are satisfied:

  • GDScript warnings treated as errors: no new warnings introduced (CI macOS validation passed).
  • Tests use the existing assert_eq pattern with optional message arguments — consistent with the rest of the test suite.
  • No save/version migration or file format changes.

Linked Issue Fit

Issue PR 311 is referenced in the PR title, body, commit message, and test docstrings. The issue describes duration-0 one-time rewards expiring before consumption — precisely what the test suite now validates:

  • test_one_time_reward_survives_ticks — REWARD_RECRUIT_DISCOUNT survives 70 ticks
  • test_one_time_ambient_improve_survives_ticks — REWARD_AMBIENT_IMPROVE survives 70 ticks
  • test_consume_recruit_discount_removes_one_time_reward — explicit consumption removes the reward
  • test_consume_ambient_improve_removes_one_time_reward — explicit consumption removes the reward
  • test_timed_reward_still_expires_on_schedule — timed rewards still expire correctly (no regression)

The linked issue acceptance criteria are met.

Tool Harness Findings

Not applicable — no tool harness output in this review corpus.

Unknowns / Needs Verification

None. All evidence is complete:

  • The incremental delta is test-only and self-documenting.
  • All 6 CI checks passed at the PR head commit.
  • The previous review already validated the goal_reward.gd implementation fix via file read.

@joryirving
joryirving merged commit 3729f58 into main Aug 8, 2026
7 checks passed
@joryirving
joryirving deleted the foreman/wl-misospace-windowstead-311/issue-311 branch August 8, 2026 17:48
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.

[P2] Duration-0 one-time goal rewards expire before they can be consumed — recruit discount and ambient improve never fire

2 participants