Implement Castle Siege Crown and switch mechanics - #903
Conversation
Validate Crown and switch occupants, preserve interrupted capture progress, and swap participant sides after successful captures. Persist the final owner and reset the Castle Siege economy when ownership changes. Add Crown, switch, capture-progress, and ownership remote views, together with regression tests for mechanics and packet serialization.
Express the attacking and defending side updates as explicit guarded cases so the control flow satisfies static analysis without changing the side-swap behavior.
ReviewI went through the diff against A few things I'd like to see addressed before merge. 1. The switch packet carries the object id where the client expects the switch index
2. Crown progress is counted in fixed 1-second steps instead of elapsed time
3. Switch and Crown state are re-broadcast to every player every second
4.
|
Use elapsed wall time for Crown progress, persist intermediate ownership for restart recovery, and keep End-state cleanup resilient to stale guild data. Broadcast switch and Crown state only on changes, synchronize players entering mid-battle, clear switch runtime state after capture, and add regression coverage for the reviewed edge cases.
Second pass — reviewed
|
Clamp Crown progress after delayed periodic ticks and track switch broadcast snapshots by network object identifier. Document the legacy switch-index packet fields and add regression coverage for delayed updates, duplicate switch spawns, and economy handling after recapture.
Third pass — reviewed
|
Use locked NPC runtime snapshots during Crown and switch processing to prevent concurrent collection access. Keep player-entry synchronization read-only, document the Crown progress clamp, and add regression coverage ensuring synchronization does not mutate shared battle state.
Summary
Implements the Castle Siege Crown capture and switch mechanics described in #726.
Changes
Testing
Scope note
Life Stone destruction during side reassignment depends on the runtime Life Stone implementation from #727. The current change performs the side reassignment and respawn flow without introducing temporary or unused Life Stone code.