Skip to content

Sprint 14-B: Police Raid Mini-Game + Bail/Hospital Severity Scaling - #94

Merged
BrandDead merged 1 commit into
main-tL2525from
feat/bail-hospital-raid-trigger
Aug 5, 2026
Merged

Sprint 14-B: Police Raid Mini-Game + Bail/Hospital Severity Scaling#94
BrandDead merged 1 commit into
main-tL2525from
feat/bail-hospital-raid-trigger

Conversation

@BrandDead

Copy link
Copy Markdown
Owner

Sprint 14-B — Police Raid Mini-Game + Bail/Hospital Severity Scaling

What's in this PR

Police Raid Engine (policeRaidEngine.ts)
Replaced the tick-based engine with a time-based rAF engine. Police units spawn top+bottom per occupied column and advance 1 row per second. The player taps deployed members to start a 1.5s evacuation window before the unit reaches them. Outcome resolves as clean / partial / disaster based on the caught-vs-saved ratio.

Police Raid Component (components/raid/PoliceRaidGame.tsx)
New 8×8 grid UI driven by a single requestAnimationFrame clock. Reads selectedBlockId from blockStore (no prop drilling). Shows animated police unit tokens, member tap targets with evac progress bars, and a post-raid outcome screen with jailed/saved/seized summary.

Raid Rewards (components/raid/policeRaidRewards.ts)
applyRaidConsequences() seizes cash (capped at balance), drains cheapest drugs first, jails caught members, resets block heat to POST_RAID_HEAT, and removes caught members from block placements.

Raid Trigger (utils/raidTrigger.ts)
selectRaidTarget() fires the interactive raid when block heat ≥ 5. suppressesBackgroundRaid() prevents double-jailing the same crew. Integrated into the game loop tick.

Bail/Hospital System (utils/bailHospitalSystem.ts)
Per your spec — damage/charges determine cost, prior arrests/hospitalizations increase both cost and wait time:

  • severityTier(): 5-tier scale (0=minor → 4=critical) for both bail and hospital
  • scaledBailCost(): base × severity multiplier × repeat-offense multiplier (capped)
  • scaledHospitalCost(): same formula keyed off damage taken
  • waitTicks(): base wait + severity + repeat-offense, capped at WAIT_TICKS_CAP
  • isLifer(): member with 5+ arrests is permanently jailed — no bail possible
  • quoteRecovery(): full quote with cost, waitTicksRemaining, severityTier, lifer flag

Bail/Hospital Panel (components/contacts/BailHospitalPanel.tsx)
New panel in Contacts showing all jailed/injured members with cost quotes, wait time countdown, severity tier badge, and lifer indicator.

Tests — 430 passing ✅

  • policeRaidEngine.test.ts: 28 tests (engine functions, unit movement, catch/evac logic)
  • bailHospitalSystem.test.ts: 47 tests (severity tiers, cost scaling, wait times, lifer detection, detention tracking, abandonment penalties)
  • policeRaid.test.ts: integration tests for raid consequences
  • All 22 test files green

POLICE RAID ENGINE (policeRaidEngine.ts)
- Replaced tick-based engine with time-based rAF engine (advanceRaid, tapMember,
  evacProgress, secondsRemaining, caughtMembers, savedMembers, isTileThreatened)
- Police units spawn top+bottom per occupied column, advance 1 row/second
- Tap-to-evac mechanic: player taps deployed members to start 1.5s evacuation
- Outcome resolves clean/partial/disaster based on caught vs saved ratio
- estimateHeld() derives cash+drugs from incomePerTick for seizure calculation

POLICE RAID COMPONENT (components/raid/PoliceRaidGame.tsx)
- New 8x8 grid UI driven by rAF clock off performance.now()
- Reads selectedBlockId from blockStore (no prop drilling)
- Animated police unit tokens, member tap targets, evac progress bars
- Outcome screen with jailed/saved/seized summary

RAID REWARDS (components/raid/policeRaidRewards.ts)
- applyRaidConsequences(): seizes cash (capped at balance), drains cheapest
  drugs first, jails caught members, resets block heat to POST_RAID_HEAT,
  removes caught members from block placements

RAID TRIGGER (utils/raidTrigger.ts)
- selectRaidTarget(): fires interactive raid when block heat >= 5
- suppressesBackgroundRaid(): prevents double-jailing same crew
- Integrated into gameLoopEngine.ts tick

BAIL/HOSPITAL SYSTEM (utils/bailHospitalSystem.ts)
- severityTier(): 5-tier scale (0=minor..4=critical) for both bail and hospital
- scaledBailCost(): base * severity multiplier * repeat-offense multiplier (capped)
- scaledHospitalCost(): same formula keyed off damage taken
- waitTicks(): base wait + severity + repeat-offense, capped at WAIT_TICKS_CAP
- isLifer(): member with 5+ arrests is permanently jailed (no bail)
- quoteRecovery(): full quote with cost, waitTicksRemaining, severityTier, lifer flag
- updateHeldSince() / overdueMembers() / applyAbandonmentPenalty() preserved

BAIL/HOSPITAL PANEL (components/contacts/BailHospitalPanel.tsx)
- New panel showing all jailed/injured members with cost quotes
- Displays wait time countdown, severity tier, lifer badge
- Integrated into Contacts screen

TOPDOWN POLICERAID (components/topdown/PoliceRaidGame.tsx)
- Updated to use new time-based engine API (advanceRaid, tapMember, etc.)
- Preserves blockId+onResolved props for BlockModeView integration

TESTS (430 passing)
- policeRaidEngine.test.ts: 28 tests covering all engine functions
- bailHospitalSystem.test.ts: 47 tests covering severity tiers, cost scaling,
  wait times, lifer detection, detention tracking, abandonment penalties
- policeRaid.test.ts: integration tests for raid consequences
- vitest downgraded 4.x -> 2.1.8 for Vite 5 compatibility
@cursor

cursor Bot commented Aug 5, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@BrandDead
BrandDead merged commit 4753d46 into main-tL2525 Aug 5, 2026
3 of 5 checks passed
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
slide Building Building Preview Aug 5, 2026 3:23am

@BrandDead
BrandDead deleted the feat/bail-hospital-raid-trigger branch August 5, 2026 03:23
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