-
Notifications
You must be signed in to change notification settings - Fork 485
Castle Siege Admin Panel Integration #733
Description
Summary
Add Castle Siege management capabilities to the Blazor admin panel, allowing administrators to view event status, force state transitions, manage castle ownership, and edit configuration.
Prerequisites
- Castle Siege State Machine #722 (State Machine) — for
CastleSiegeContextand state management. - Castle Siege Data Model & Configuration #721 (Data Model) — for
CastleSiegeConfigurationtype.
Background
The admin panel is a Blazor Server application in Web/AdminPanel/. It uses:
- Generic configuration editors via
AutoFields.csinWeb/Shared/Components/Form/. - Navigation via
NavMenu.razorinWeb/AdminPanel/Components/Layout/. - Server API controllers in
Web/AdminPanel/API/ServerController.cs. - The
IConfigurationChangeMediatorfor live configuration updates.
Requirements
1. Castle Siege Management Page — New file: Web/AdminPanel/Components/CastleSiegeManagement.razor
A Blazor component providing:
Status Display
- Current Castle Siege state (name, start time, remaining duration).
- Castle owner guild name (or "Unoccupied").
- Number of registered guilds.
- Tax rates and tribute money balance.
Admin Actions
- Force State Transition: Dropdown to select a target state, button to force-transition. Calls
CastleSiegePlugIn.ForceChangeState(state)or equivalent. - Change Owner: Text field for guild name, button to set as castle owner.
- Reset Siege: Button to clear all registration data and reset to
Idle1. - Edit Tax Rates: Inputs for chaos, store, and hunt tax rates with save button.
- Clear Tribute Money: Button to reset tribute money to 0.
Registered Guilds View
- Table showing all registered guilds: name, marks, registration order.
- Button to remove individual registrations.
NPC Status View
- Table showing castle NPCs: type, instance ID, upgrade levels, current HP, alive status.
2. Navigation Entry — Modify: Web/AdminPanel/Components/Layout/NavMenu.razor
Add a "Castle Siege" navigation entry under the Events section:
<NavLink class="nav-link" href="castle-siege">
<span class="oi oi-shield" aria-hidden="true"></span> Castle Siege
</NavLink>3. API Endpoints — Modify: Web/AdminPanel/API/ServerController.cs (if needed)
If the Blazor component needs server-side API calls (for force-start, etc.), add endpoints:
POST /api/castle-siege/force-state— force state transition.POST /api/castle-siege/set-owner— change castle owner.GET /api/castle-siege/status— get current status.
Alternatively, if the Blazor server component has direct access to the IGameServerContext (which it does through DI), API endpoints may not be necessary.
4. Configuration Editor
The existing AutoFields.cs system should automatically generate form fields for CastleSiegeConfiguration properties when editing the GameConfiguration. Verify:
- All simple properties (bool, int, byte) render correctly.
- Navigation properties (to
GameMapDefinition,ItemDefinition) render as dropdowns. - Collections (
StateSchedule,NpcDefinitions,UpgradeDefinitions) render as editable lists. CastleSiegeZoneDefinitionrenders with X1/Y1/X2/Y2 fields.
If custom rendering is needed, create component builders similar to LocalizedStringFieldBuilder.cs.
5. Chat Commands for Admin
Optionally add chat commands for in-game admin control:
CastleSiegeForceStateChatCommand — Optional new file
/csforcestate <state_name>
Forces the Castle Siege to transition to the specified state.
CastleSiegeInfoChatCommand — Optional new file
/csinfo
Shows current Castle Siege state, owner, and remaining time.
Files to Create
| File | Description |
|---|---|
Web/AdminPanel/Components/CastleSiegeManagement.razor |
Admin management page |
GameLogic/PlugIns/ChatCommands/CastleSiegeForceStateChatCommand.cs |
Optional admin chat command |
GameLogic/PlugIns/ChatCommands/CastleSiegeInfoChatCommand.cs |
Optional info chat command |
Files to Modify
| File | Changes |
|---|---|
Web/AdminPanel/Components/Layout/NavMenu.razor |
Add Castle Siege nav entry |
Web/AdminPanel/API/ServerController.cs |
Add CS endpoints (if needed) |
Acceptance Criteria
- Castle Siege management page is accessible from the admin panel navigation.
- Current state, owner, tax rates, and tribute money are displayed correctly.
- Admin can force state transitions via the UI.
- Admin can change castle ownership via the UI.
- Registered guilds are listed with their mark counts.
- NPC status is visible (upgrade levels, HP, alive/dead).
- Configuration editor renders
CastleSiegeConfigurationproperties correctly. - Chat commands (if implemented) work for in-game admins.