Skip to content

feat/fix: transport load order bug + engineer-neutral building capture + tests - #62

Merged
linkbag merged 1 commit into
mainfrom
feat/ic-verify-transport-neutral
Mar 9, 2026
Merged

linkbag merged 1 commit into
mainfrom
feat/ic-verify-transport-neutral

Conversation

@linkbag

@linkbag linkbag commented Mar 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Bug fix (Unit.ts): case 'load' order handler never called processNextOrder() when the unit was already in range of the transport, leaving the unit permanently stalled with a dangling currentOrder. Also fixed proximity threshold inconsistency (TILE_SIZE×2 → TILE_SIZE×1.5) to stay inside the transport's actual load range.
  • Bug fix (Combat.ts): Engineer attacking a damaged neutral hospital or repair depot triggered the repair path instead of the capture path. Fixed: only bridges are repaired by engineers; all other neutral buildings (tech buildings) are always capturable regardless of HP.
  • Tests: 34 new unit tests covering transport load/unload gating, drop-tile spiral algorithm, engineer-vs-neutral-building branching, and post-capture neutral building healing effects.

Verification findings

  • amphibious_transport (naval, cap 8, infantry+vehicles) and nighthawk (aircraft, cap 5, infantry) — both fully defined ✓
  • Load/unload event wiring in EntityManager is complete ✓ (was just the order-queue clearing that was broken)
  • AI transport hooks (handleTransportHooks) fire on a 4000ms interval and correctly issue load/unload orders ✓
  • Neutral buildings spawn on the map correctly ✓
  • Hospital/repair depot post-capture effects are implemented in updateNeutralEffects ✓
  • Bridge damage/repair system (GameMap + engineer path) is wired end-to-end ✓

Test plan

  • npx tsc --noEmit — clean
  • npx vitest run — 96/96 pass (34 new)
  • Manual: send infantry near amphibious transport → verify units board and transport moves/unloads
  • Manual: send engineer at damaged hospital → verify capture (not repair)
  • Manual: send engineer at damaged bridge → verify bridge restored

🤖 Generated with Claude Code

…e fix + tests

Fix 1 (Unit.ts): In the 'load' order handler, when the unit is already
within range of the transport, `processNextOrder()` was never called after
emitting `request_load_unit`. The order would remain as `currentOrder`
forever, leaving the unit stalled. Fix: add `processNextOrder()` after the
close-range load attempt. Also tighten the proximity threshold from
TILE_SIZE*2 (64px) to TILE_SIZE*1.5 (48px) so it stays inside the
transport's actual loadRangeTiles=1.85 load range (59.2px), preventing
silent rejections in `loadUnitIntoTransport`.

Fix 2 (Combat.ts): The engineer-vs-neutral-building logic incorrectly
repaired ANY damaged neutral structure, including hospitals and repair
depots. Only bridges should be repaired (they are infrastructure); tech
buildings (hospital, repair depot) should be capturable regardless of HP.
Restructured the if/else so only `isBridgeStructure` triggers the
repair/no-capture path.

Tests: Add 34 unit tests in tests/transport-and-neutral.test.ts covering:
- Transport load gating (player, category, capacity, distance, state)
- Transport unload (drop tile placement, dying passengers, edge cases)
- findNearestOpenDropTile spiral algorithm
- Engineer vs neutral building branching (bridge repair, hospital capture,
  damaged-hospital capture regression)
- Neutral building effects post-capture (hospital/repair depot heal range,
  faction checks, heal cap)

tsc: clean | vitest: 96/96 pass (34 new)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@linkbag
linkbag merged commit 25b660c into main Mar 9, 2026
1 check passed
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