Summary
Implement the Castle Siege economy system: tax rates set by the castle owner, tribute money collection, tax exemptions for the owner's alliance, and the Land of Trials hunt zone toggle.
Prerequisites
Requirements
1. Tax Types
| Type |
Name |
Range |
Applied To |
| 1 |
Chaos Tax |
0–3 (%) |
Chaos Machine crafting Zen cost |
| 2 |
Store Tax |
0–3 (%) |
NPC store purchase prices |
| 3 |
Hunt Tax |
0–300,000 |
Flat entry fee to Land of Trials |
2. Tax Exemptions
Players who are members of the castle owner's guild or the castle owner's alliance pay 0 tax.
Check: player's guild AllianceGuild (or guild itself) matches CastleSiegeData.OwnerGuildId.
3. Tax Provider — New file: GameLogic/CastleSiege/CastleSiegeTaxProvider.cs
A service queried by existing game logic to apply taxes.
public class CastleSiegeTaxProvider
{
public int GetChaosTax(Player player); // Returns additional Zen % for crafting
public int GetStoreTax(Player player); // Returns additional Zen % for shop
public int GetHuntEntryFee(Player player); // Returns flat Zen fee for LoT entry
public bool IsExempt(Player player); // True if player is in owner guild/alliance
}
Each method:
- Get
CastleSiegeContext from the game context.
- If no siege data or castle unoccupied → return 0.
- If
IsExempt(player) → return 0.
- Return the configured tax rate.
4. Integration with Existing Actions
Chaos Tax — Modify: GameLogic/PlayerActions/Items/BaseItemCraftingHandler.cs
In the crafting cost calculation, after computing the base Zen cost:
- Get
CastleSiegeTaxProvider.GetChaosTax(player).
- Add
baseCost * taxRate / 100 to the total cost.
- Add the tax amount to
CastleSiegeData.TributeMoney (via the context).
Store Tax — Modify: GameLogic/PlayerActions/Items/BuyNpcItemAction.cs
In the buy price calculation:
- Get
CastleSiegeTaxProvider.GetStoreTax(player).
- Add
basePrice * taxRate / 100 to the total price.
- Add the tax amount to tribute money.
Hunt Tax — Modify: GameLogic/PlayerActions/WarpGateAction.cs or the Land of Trials entry handler
When a player tries to enter Land of Trials (gate ID 95):
- Get
CastleSiegeTaxProvider.GetHuntEntryFee(player).
- Charge the fee (deduct from player's Zen).
- Add to tribute money.
- If player can't afford it → deny entry.
- If hunt zone is disabled and player is not exempt → deny entry.
5. Tax Rate Change Action — New file: GameLogic/CastleSiege/Actions/CastleSiegeTaxRateChangeAction.cs
Validation:
- Player is the castle owner guild master.
- Not during
Start state.
- Tax values within valid ranges (Chaos/Store: 0–3, Hunt: 0–300000).
Effect:
- Update
CastleSiegeData.TaxChaos, TaxStore, or TaxHunt.
- Persist to database.
- Broadcast updated rates.
6. Tribute Money Withdraw Action — New file: GameLogic/CastleSiege/Actions/CastleSiegeTributeWithdrawAction.cs
Validation:
- Player is the castle owner guild master.
- Requested amount ≤
CastleSiegeData.TributeMoney.
- Player's Zen after addition ≤
GameConfiguration.MaximumInventoryMoney.
- No concurrent withdrawal (use a flag/lock).
Effect:
- Subtract from
CastleSiegeData.TributeMoney.
- Add to player's Zen.
- Persist to database.
7. Hunt Zone Toggle Action — New file: GameLogic/CastleSiege/Actions/CastleSiegeHuntZoneToggleAction.cs
Validation:
- Player is the castle owner guild master.
- Not during
Start state.
Effect:
- Toggle
CastleSiegeData.IsHuntZoneEnabled.
- Persist.
Entry logic:
- If hunt zone disabled: only castle owner and alliance members can enter.
- If hunt zone enabled: anyone can enter (after paying the hunt tax).
8. Tax Reset on Ownership Change
In CastleSiegePlugIn.OnEnterStateAsync(End), when ownership changes:
- Set
TaxChaos = 0, TaxStore = 0, TaxHunt = 0.
- Set
TributeMoney = 0.
- Set
IsHuntZoneEnabled = false.
- Persist.
9. Tax Info Request Handler
CastleSiegeTaxInfoHandlerPlugIn — handles C1-B2-08. Returns current tax rates and tribute money balance.
- Only the castle owner guild master should see the full tribute balance.
10. Message Handlers
| Handler |
Packet |
Description |
CastleSiegeTaxInfoHandlerPlugIn |
C1-B2-08 |
Tax info request |
CastleSiegeTaxChangeHandlerPlugIn |
C1-B2-09 |
Tax rate change |
CastleSiegeTributeWithdrawHandlerPlugIn |
C1-B2-10 |
Tribute withdrawal |
CastleSiegeHuntZoneToggleHandlerPlugIn |
C1-B2-1F |
Hunt zone toggle |
CastleSiegeHuntZoneEnterHandlerPlugIn |
C1-B9-05 |
Hunt zone entry |
11. View Interfaces & Remote Views
ICastleSiegeTaxInfoPlugIn — sends tax rates and tribute money.
ICastleSiegeTaxChangeResultPlugIn — sends tax change result.
ICastleSiegeTributeWithdrawResultPlugIn — sends withdrawal result.
Files to Create
| File |
Description |
GameLogic/CastleSiege/CastleSiegeTaxProvider.cs |
Tax calculation service |
GameLogic/CastleSiege/Actions/CastleSiegeTaxRateChangeAction.cs |
Tax rate change |
GameLogic/CastleSiege/Actions/CastleSiegeTributeWithdrawAction.cs |
Tribute withdrawal |
GameLogic/CastleSiege/Actions/CastleSiegeHuntZoneToggleAction.cs |
Hunt zone toggle |
GameServer/MessageHandler/CastleSiege/CastleSiegeTaxInfoHandlerPlugIn.cs |
Packet handler |
GameServer/MessageHandler/CastleSiege/CastleSiegeTaxChangeHandlerPlugIn.cs |
Packet handler |
GameServer/MessageHandler/CastleSiege/CastleSiegeTributeWithdrawHandlerPlugIn.cs |
Packet handler |
GameServer/MessageHandler/CastleSiege/CastleSiegeHuntZoneToggleHandlerPlugIn.cs |
Packet handler |
GameServer/MessageHandler/CastleSiege/CastleSiegeHuntZoneEnterHandlerPlugIn.cs |
Packet handler |
GameLogic/Views/CastleSiege/ICastleSiegeTaxInfoPlugIn.cs |
View interface |
GameServer/RemoteView/CastleSiege/CastleSiegeTaxInfoPlugIn.cs |
Remote view |
Files to Modify
| File |
Changes |
GameLogic/PlayerActions/Items/BaseItemCraftingHandler.cs |
Add chaos tax integration |
GameLogic/PlayerActions/Items/BuyNpcItemAction.cs |
Add store tax integration |
GameLogic/PlayerActions/WarpGateAction.cs |
Add hunt tax and zone toggle check |
Acceptance Criteria
Summary
Implement the Castle Siege economy system: tax rates set by the castle owner, tribute money collection, tax exemptions for the owner's alliance, and the Land of Trials hunt zone toggle.
Prerequisites
CastleSiegeData(tax rates, tribute money fields).CastleSiegeContextand state awareness.Requirements
1. Tax Types
2. Tax Exemptions
Players who are members of the castle owner's guild or the castle owner's alliance pay 0 tax.
Check: player's guild
AllianceGuild(or guild itself) matchesCastleSiegeData.OwnerGuildId.3. Tax Provider — New file:
GameLogic/CastleSiege/CastleSiegeTaxProvider.csA service queried by existing game logic to apply taxes.
Each method:
CastleSiegeContextfrom the game context.IsExempt(player)→ return 0.4. Integration with Existing Actions
Chaos Tax — Modify:
GameLogic/PlayerActions/Items/BaseItemCraftingHandler.csIn the crafting cost calculation, after computing the base Zen cost:
CastleSiegeTaxProvider.GetChaosTax(player).baseCost * taxRate / 100to the total cost.CastleSiegeData.TributeMoney(via the context).Store Tax — Modify:
GameLogic/PlayerActions/Items/BuyNpcItemAction.csIn the buy price calculation:
CastleSiegeTaxProvider.GetStoreTax(player).basePrice * taxRate / 100to the total price.Hunt Tax — Modify:
GameLogic/PlayerActions/WarpGateAction.csor the Land of Trials entry handlerWhen a player tries to enter Land of Trials (gate ID 95):
CastleSiegeTaxProvider.GetHuntEntryFee(player).5. Tax Rate Change Action — New file:
GameLogic/CastleSiege/Actions/CastleSiegeTaxRateChangeAction.csValidation:
Startstate.Effect:
CastleSiegeData.TaxChaos,TaxStore, orTaxHunt.6. Tribute Money Withdraw Action — New file:
GameLogic/CastleSiege/Actions/CastleSiegeTributeWithdrawAction.csValidation:
CastleSiegeData.TributeMoney.GameConfiguration.MaximumInventoryMoney.Effect:
CastleSiegeData.TributeMoney.7. Hunt Zone Toggle Action — New file:
GameLogic/CastleSiege/Actions/CastleSiegeHuntZoneToggleAction.csValidation:
Startstate.Effect:
CastleSiegeData.IsHuntZoneEnabled.Entry logic:
8. Tax Reset on Ownership Change
In
CastleSiegePlugIn.OnEnterStateAsync(End), when ownership changes:TaxChaos = 0,TaxStore = 0,TaxHunt = 0.TributeMoney = 0.IsHuntZoneEnabled = false.9. Tax Info Request Handler
CastleSiegeTaxInfoHandlerPlugIn— handlesC1-B2-08. Returns current tax rates and tribute money balance.10. Message Handlers
CastleSiegeTaxInfoHandlerPlugInC1-B2-08CastleSiegeTaxChangeHandlerPlugInC1-B2-09CastleSiegeTributeWithdrawHandlerPlugInC1-B2-10CastleSiegeHuntZoneToggleHandlerPlugInC1-B2-1FCastleSiegeHuntZoneEnterHandlerPlugInC1-B9-0511. View Interfaces & Remote Views
ICastleSiegeTaxInfoPlugIn— sends tax rates and tribute money.ICastleSiegeTaxChangeResultPlugIn— sends tax change result.ICastleSiegeTributeWithdrawResultPlugIn— sends withdrawal result.Files to Create
GameLogic/CastleSiege/CastleSiegeTaxProvider.csGameLogic/CastleSiege/Actions/CastleSiegeTaxRateChangeAction.csGameLogic/CastleSiege/Actions/CastleSiegeTributeWithdrawAction.csGameLogic/CastleSiege/Actions/CastleSiegeHuntZoneToggleAction.csGameServer/MessageHandler/CastleSiege/CastleSiegeTaxInfoHandlerPlugIn.csGameServer/MessageHandler/CastleSiege/CastleSiegeTaxChangeHandlerPlugIn.csGameServer/MessageHandler/CastleSiege/CastleSiegeTributeWithdrawHandlerPlugIn.csGameServer/MessageHandler/CastleSiege/CastleSiegeHuntZoneToggleHandlerPlugIn.csGameServer/MessageHandler/CastleSiege/CastleSiegeHuntZoneEnterHandlerPlugIn.csGameLogic/Views/CastleSiege/ICastleSiegeTaxInfoPlugIn.csGameServer/RemoteView/CastleSiege/CastleSiegeTaxInfoPlugIn.csFiles to Modify
GameLogic/PlayerActions/Items/BaseItemCraftingHandler.csGameLogic/PlayerActions/Items/BuyNpcItemAction.csGameLogic/PlayerActions/WarpGateAction.csAcceptance Criteria