ReviewOS

stacks/wildloop

Add territory decay/expiry so inactive land becomes vulnerable

#950
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Problem

Territories never expire. A player who stops running keeps everything forever, so the map ossifies and new players can't compete.

Acceptance

  • Define a decay/vulnerability rule (e.g., no defense for N days → area shrinks or becomes easier to conquer / reverts to neutral).
  • A scheduled job applies it; history records the change.
9 days ago

Implemented in ffb12df.

The decay ladder (constants + math in resources/functions/decay.ts):

  1. territories.last_activity_at tracks the owner's last touch — claim, conquest, defense, or just running through their own land (patrols now refresh it from the battle loop).
  2. Active + owner inactive 14 days → contested ('decaying' history row + notification). It's the same contested state as an attack, so the existing #941 defend mechanic resolves it — run through your land and the clock resets.
  3. Contested + inactive 28 days → expired: off the map, current holdings decremented, territories_lost++, longest_ownership_days folded, 'expired' history row, owner notified. The land becomes claimable again (the claim overlap check skips expired land).

When it runs: opportunistically at the start of every conquest-processing pass (every recorded run ticks the world clock), on demand via POST /api/territories/decay-sweep (auth, with stale_days/expire_days overrides), and via ./buddy territory:decay for cron (preview by default, --apply).

Two adjacent bugs fixed: contested land was missing from the claim overlap check (claimable-over!), and UserTerritoriesAction hid the owner's own contested territories from their list.

Verified by scripts/verify-territory-decay.ts — 17 checks covering the contest rung, sweep idempotency, defend-resets-clock, the expiry rung with stats/notifications, reclaiming expired land, map exclusion, and patrol refresh — plus full regression of the accounting/battles/ranks suites (all green).

Sign in to comment on this issue.