-
Notifications
You must be signed in to change notification settings - Fork 486
Castle Siege Tax, Tribute & Economy #729
Copy link
Copy link
Open
Labels
Description
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
- Castle Siege Data Model & Configuration #721 (Data Model) — for
CastleSiegeData(tax rates, tribute money fields). - Castle Siege State Machine #722 (State Machine) — for
CastleSiegeContextand state awareness. - Guild Alliance System #720 (Guild Alliance) — for alliance membership checks (tax exemptions).
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
CastleSiegeContextfrom 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 / 100to 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 / 100to 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
Startstate. - Tax values within valid ranges (Chaos/Store: 0–3, Hunt: 0–300000).
Effect:
- Update
CastleSiegeData.TaxChaos,TaxStore, orTaxHunt. - 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
Startstate.
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— handlesC1-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
- Castle owner guild master can set tax rates within valid ranges.
- Chaos tax is applied to Chaos Machine crafting costs.
- Store tax is applied to NPC shop purchases.
- Hunt tax is charged when entering Land of Trials.
- Castle owner and alliance members are exempt from all taxes.
- Tax revenue accumulates in tribute money.
- Castle owner guild master can withdraw tribute money.
- Hunt zone can be toggled on/off by the castle owner.
- Tax rates reset to 0 on ownership change.
- Tax info is available via packet request.
Reactions are currently unavailable