Skip to content

feat: add rotating goal data model#154

Merged
joryirving merged 3 commits into
mainfrom
saffron/issue-142-rotating-goal-model
May 23, 2026
Merged

feat: add rotating goal data model#154
joryirving merged 3 commits into
mainfrom
saffron/issue-142-rotating-goal-model

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Fixes #142

Add a minimal pure data model for rotating colony goals. No UI yet.

Goal state structure

  • goal id/type — unique identifier and type enum (resource/build/build_complete)
  • target resource/build/task — target specification per goal type
  • target amount — threshold for completion
  • current progress — computed or updated value
  • completion state — boolean flag set by complete_goal()

Goal catalog (7 fixed entries)

ID Type Target
gather_wood resource 10 wood
gather_stone resource 5 stone
gather_food resource 8 food
build_hut build hut
build_workshop build workshop
build_garden build garden
any_build build_complete any build

Acceptance criteria

  • Goal catalog exists in a testable place (scripts/rotating_goal.gd)
  • Active goal can be selected deterministically for tests (select_next_active_goal)
  • Progress can be updated or computed from existing game state
  • Completion detection is covered by tests
  • No UI changes yet
  • Link back to design: add compact rotating colony goals #131

Refs: #131

- Add scripts/rotating_goal.gd with pure data model for colony goals
- Goal catalog with 7 fixed entries (wood, stone, food, hut, workshop, garden, any_build)
- Deterministic goal selection from completed-id set
- Progress computation for resource, build, and build-complete goals
- Completion detection by goal type
- No-op reward on completion (placeholder only)
- Add tests/test_rotating_goal.gd covering all acceptance criteria

Refs #142
@itsmiso-ai
itsmiso-ai requested a review from joryirving as a code owner May 23, 2026 05:03
@its-miso

its-miso Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Automated recommendation: APPROVE

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

PR Review: feat: add rotating goal data model

Summary

This PR adds a pure data model for rotating colony goals in scripts/rotating_goal.gd with corresponding tests in tests/test_rotating_goal.gd. The implementation is focused, well-documented, and includes comprehensive test coverage.

Change-by-Change Findings

scripts/rotating_goal.gd (120 lines, ADDED)

  • Goal types: Three constants define GOAL_TYPE_RESOURCE, GOAL_TYPE_BUILD, and GOAL_TYPE_BUILD_COMPLETE
  • Goal catalog: Seven fixed entries covering all specified concepts (wood, stone, food, hut, workshop, garden, any_build)
  • apply_goal_template: Correctly uses duplicate(true) for deep copying targets, preventing catalog mutation
  • select_next_active_goal: Returns first non-completed goal deterministically, or empty dict when all complete
  • Progress helpers: Separate functions for updating (update_resource_progress) and computing (compute_*_progress) progress from game state
  • Completion detection: Type-dispatching is_goal_complete() with individual is_*_complete() checks
  • Reward behavior: complete_goal() sets completed=true with no reward field (matches issue requirement)

tests/test_rotating_goal.gd (234 lines, ADDED)

  • Catalog tests: Verifies 7 entries, all goal types, all goal IDs
  • Template tests: Validates deep copy behavior (template_deep_copies_target)
  • Selection tests: Covers first goal, skipping completed, last remaining, all-complete edge case
  • Progress tests: Validates clamping at target amount, game state computation, missing resource handling
  • Completion tests: Tests all three goal types with progress=0 and progress>=threshold cases
  • No-op reward test: Explicitly verifies no reward field is added on completion

Standards Compliance

Repository conventions followed:

  • GDScript class with class_name RotatingGoal (matches layout_math.gd pattern)
  • Constants use SCREAMING_SNAKE_CASE
  • Static utility functions for pure data operations
  • Inline comments with ## style documentation
  • Deep-copy defensive programming for catalog data

Issue #142 requirements fully met:

  • Goal state structure includes id/type, target, target amount, current progress, completion state
  • Goal catalog uses existing game concepts only (wood, stone, food, hut, workshop, garden)
  • No UI changes, no rewards beyond no-op completion
  • References design: add compact rotating colony goals #131 as requested

Linked Issue Fit

Issue #142 acceptance criteria status:

  • Goal catalog exists in a testable place → scripts/rotating_goal.gd
  • Active goal can be selected deterministically → select_next_active_goal(completed_ids)
  • Progress can be updated or computed from game state → update_resource_progress, compute_*_progress
  • Completion detection covered by tests → test_is_goal_complete with 7 assertions
  • No UI changes yet → Pure data model only
  • Link back to design: add compact rotating colony goals #131 → Commented at line 3

Evidence Provider Findings

No evidence providers configured.

Tool Harness Findings

No tool requests executed (planned: 0, executed: 0).

Unknowns / Needs Verification

None. Implementation is complete and self-contained.

joryirving and others added 2 commits May 23, 2026 12:52
…n apply_goal_template

- Replace 'extends Node' with 'class_name RotatingGoal' since the script
  only uses static functions (addresses review feedback)
- Use .duplicate(true) for deep copy of target dictionaries in
  apply_goal_template to protect against future nested structures
@joryirving
joryirving enabled auto-merge May 23, 2026 19:02
@joryirving
joryirving merged commit 96dfa56 into main May 23, 2026
4 checks passed
@joryirving
joryirving deleted the saffron/issue-142-rotating-goal-model branch May 23, 2026 19:03
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.

feat: add rotating goal data model

2 participants