Skip to content

Castle Siege Tax, Tribute & Economy #729

@sven-n

Description

@sven-n

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:

  1. Get CastleSiegeContext from the game context.
  2. If no siege data or castle unoccupied → return 0.
  3. If IsExempt(player) → return 0.
  4. 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

  • 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions