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
Background
The admin panel is a Blazor Server application in Web/AdminPanel/. It uses:
- Generic configuration editors via
AutoFields.cs in Web/Shared/Components/Form/.
- Navigation via
NavMenu.razor in Web/AdminPanel/Components/Layout/.
- Server API controllers in
Web/AdminPanel/API/ServerController.cs.
- The
IConfigurationChangeMediator for 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.
CastleSiegeZoneDefinition renders 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
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
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
CastleSiegeContextand state management.CastleSiegeConfigurationtype.Background
The admin panel is a Blazor Server application in
Web/AdminPanel/. It uses:AutoFields.csinWeb/Shared/Components/Form/.NavMenu.razorinWeb/AdminPanel/Components/Layout/.Web/AdminPanel/API/ServerController.cs.IConfigurationChangeMediatorfor live configuration updates.Requirements
1. Castle Siege Management Page — New file:
Web/AdminPanel/Components/CastleSiegeManagement.razorA Blazor component providing:
Status Display
Admin Actions
CastleSiegePlugIn.ForceChangeState(state)or equivalent.Idle1.Registered Guilds View
NPC Status View
2. Navigation Entry — Modify:
Web/AdminPanel/Components/Layout/NavMenu.razorAdd a "Castle Siege" navigation entry under the Events section:
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.cssystem should automatically generate form fields forCastleSiegeConfigurationproperties when editing theGameConfiguration. Verify:GameMapDefinition,ItemDefinition) render as dropdowns.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 fileForces the Castle Siege to transition to the specified state.
CastleSiegeInfoChatCommand— Optional new fileShows current Castle Siege state, owner, and remaining time.
Files to Create
Web/AdminPanel/Components/CastleSiegeManagement.razorGameLogic/PlugIns/ChatCommands/CastleSiegeForceStateChatCommand.csGameLogic/PlugIns/ChatCommands/CastleSiegeInfoChatCommand.csFiles to Modify
Web/AdminPanel/Components/Layout/NavMenu.razorWeb/AdminPanel/API/ServerController.csAcceptance Criteria
CastleSiegeConfigurationproperties correctly.