Skip to content

Move tile_accent / tile_style rendering helpers into a render module - #259

Merged
joryirving merged 7 commits into
mainfrom
foreman/wl-misospace-windowstead-235/issue-235
Jul 8, 2026
Merged

Move tile_accent / tile_style rendering helpers into a render module#259
joryirving merged 7 commits into
mainfrom
foreman/wl-misospace-windowstead-235/issue-235

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Extracted tile_style and tile_accent into a pure TileRender class with 19 comprehensive tests.

Fixes #235

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

Create scripts/tile_render.gd with pure (no scene reference) functions:
- TileRender.tile_style() — returns StyleBoxFlat using theme dict
- TileRender.tile_accent() — returns accent Color using context dict

Pass pending_build_kind, hover_pos, stockpile_pos, and can_place_fn via a
context dict parameter so tile rendering is testable without scene tree
instantiation. Constants (RESOURCE_COLORS, STRUCTURE_COLORS, TILE_BACKDROPS)
are passed via a theme dict from main.gd.

Add 18 regression tests in tests/test_tile_render.gd covering all tile types
(ground, tree, rock, berries, foundation, structures), build placement
highlights, stockpile accents, and integration with real constants.

Fixes #235

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

This comment was marked as outdated.

The main.gd script already delegated tile_style() and tile_accent() calls to
TileRender.tile_style() and TileRender.tile_accent(), but the TileRender class
was never preloaded, causing a runtime error. Added the missing preload
statement to wire up the rendering module.

Fixes #235

Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
its-saffron[bot]

This comment was marked as outdated.

Add explicit type annotations to variables assigned from Dictionary.get()
calls, which return Variant and trigger Godot's strict type inference
warnings-as-errors. This resolves the headless smoke test failure.

- Added explicit Vector2i casts for hover_pos and stockpile_pos
- Added explicit Dictionary type annotations for resource_colors and
  structure_colors

Fixes #235

Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
@its-saffron
its-saffron Bot dismissed their stale review July 8, 2026 08:38

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

Godot's strict type inference was treating implicit type warnings as errors
in CI, causing the headless smoke test to fail. Added explicit type
annotations to all variables assigned from Dictionary.get() calls:

- pending_build_kind: String
- hover_pos: Vector2i
- stockpile_pos: Vector2i
- resource_colors: Dictionary
- structure_colors: Dictionary

Fixes #235

Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
@its-saffron
its-saffron Bot dismissed their stale review July 8, 2026 11:11

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai added the needs-human Human input or decision is required. label Jul 8, 2026
@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

Reason: PR review: CHANGES_REQUESTED

Posted automatically by Dispatch on 2026-07-08T11:26:01.360Z

itsmiso-ai and others added 2 commits July 8, 2026 16:30
Godot requires libfontconfig.so.1 for text rendering, which is missing on
the Ubuntu CI runner. This caused the headless smoke test to fail with:
  ERROR: The dependent shared library 'libfontconfig.so.1' could not be loaded

Add an apt-get install step for libfontconfig1 before running the smoke test.

Fixes #235

Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
@joryirving joryirving added ai-review Request an AI pull request review. and removed needs-human Human input or decision is required. labels Jul 8, 2026
@its-saffron
its-saffron Bot dismissed their stale review July 8, 2026 18:03

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@its-saffron
its-saffron Bot dismissed their stale review July 8, 2026 18:04

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@its-saffron its-saffron Bot removed the ai-review Request an AI pull request review. label Jul 8, 2026
Move pure tile rendering helpers out of scripts/main.gd into a dedicated
TileRender class so tile rendering can be tested without a scene tree.

- scripts/tile_render.gd: pure TileRender class with static tile_style()
  and tile_accent() methods. Both accept plain data (tile dict, pos,
  theme dict, context dict) and read constants from scripts/constants.gd
  (RESOURCE_COLORS, STRUCTURE_COLORS, TILE_BACKDROPS) — no scene refs.
- scripts/main.gd: preload TileRender and delegate the two render
  helpers, passing pending_build_kind, hovered_tile_pos, stockpile_pos,
  and can_place_at via a context dict built from own state.
- tests/test_tile_render.gd: 19 SceneTree-based tests covering
  tile_style (border color, stockpile override, unknown-kind fallback,
  corner radius, shadow, return type) and tile_accent (build placement
  valid/invalid, stockpile, resource/structure colors, foundation,
  hover mismatch, empty context, real-constant integration).

Fixes #235

Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>

@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 extracts tile_style and tile_accent rendering helpers into a dedicated TileRender module (scripts/tile_render.gd) with 19 comprehensive tests, following established repository patterns for testability.

Change Summary

New Module: scripts/tile_render.gd

  • class_name TileRender with pure static functions
  • tile_style(): Creates StyleBoxFlat with border colors, backdrop colors, corner radius, shadow
  • tile_accent(): Returns Color for overlay accents based on tile kind, build state, hover state, stockpile state, and resource/structure colors
  • No scene references — fully testable without scene tree

Test Suite: tests/test_tile_render.gd

  • 19 regression tests covering:
    • tile_style: StyleBoxFlat type, border color, background from TILE_BACKDROPS, stockpile override, unknown kind default, corner radius, shadow
    • tile_accent: build placement valid/invalid, stockpile gold, resource color, structure color, foundation, hover mismatch, empty context
    • Integration: uses real RESOURCE_COLORS and STRUCTURE_COLORS from constants.gd

Integration: scripts/main.gd

  • Delegates tile_style() and tile_accent() to TileRender.tile_style() and TileRender.tile_accent()
  • Passes render_theme dict containing TILE_BACKDROPS, RESOURCE_COLORS, STRUCTURE_COLORS

CI: .github/workflows/test.yml

  • Added libfontconfig1 dependency installation, fixing the fontconfig error shown in smoke.log

Standards Compliance

Verified:

  • ✅ Follows repository extraction pattern: tile_render.gd mirrors worker_renderer.gd (issue PR 232), goal_progression.gd, worker_cap_logic.gd
  • ✅ Pure functions with no scene references
  • ✅ Class-based module with class_name declaration
  • ✅ Comprehensive test coverage with regression tests
  • ✅ Uses existing constants (RESOURCE_COLORS, STRUCTURE_COLORS, TILE_BACKDROPS)
  • ✅ Smoke test CI updated to fix dependency issue

Linked Issue Fit

Issue PR 235 calls for extracting tile rendering helpers into a testable module. This PR delivers:

  • TileRender class with pure rendering functions
  • 19 comprehensive tests validating tile_style and tile_accent behavior
  • Integration with main.gd via delegation pattern

No acceptance criteria document was provided in context, but the PR body commits to "19 comprehensive tests" — verified as delivered.

Evidence Provider Findings

No evidence providers configured.

Tool Harness Findings

  • ✅ Test file tests/test_tile_render.gd read successfully: 19 tests defined covering both functions
  • ✅ Workflow file .github/workflows/test.yml read successfully: libfontconfig1 dependency added
  • ✅ RESOURCE_COLORS usage verified across constants.gd, main.gd, tile_render.gd, and tests

CI Results

Check Status
macOS validation ✅ success
Script test suite ✅ success
Headless smoke test ✅ success

Unknowns / Needs Verification

None — all relevant evidence was available and verified.

Conclusion

This PR is a clean extraction refactor that:

  1. Improves testability by moving rendering logic out of main.gd
  2. Adds comprehensive regression tests (19 tests)
  3. Fixes a CI dependency issue (libfontconfig1)
  4. Follows established repository patterns
  5. Passes all CI checks including macOS validation

No blockers identified. The implementation is ready to merge.

@joryirving
joryirving merged commit 3a457ad into main Jul 8, 2026
4 checks passed
@joryirving
joryirving deleted the foreman/wl-misospace-windowstead-235/issue-235 branch July 8, 2026 21:15
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.

Move tile_accent / tile_style rendering helpers into a render module

2 participants