Interface SettlementTrading


public interface SettlementTrading
Pure rules for an opt-in settlement trade network. The engine owns inventory conservation, durable receipts, the shared calendar and UI; the mod owns export selection, prices, grants and travel rules. Export allowances cannot exceed the host's recorded completed packing output. Callbacks receive detached values and must not retain mutable external state.
  • Method Details

    • supports

      boolean supports(SettlementTrading.World world)
      Selects the worlds in which this network is available.
      Parameters:
      world - immutable town and campaign context
      Returns:
      true to activate this network; the last applicable registration wins
    • includesSavedTowns

      boolean includesSavedTowns(SettlementTrading.World world)
      Chooses which other saved towns belong to this network.
      Parameters:
      world - current world; completion-stage details are omitted for this visibility query
      Returns:
      true to include sandbox saved towns; false for authored markets only
    • maximumExports

      default int maximumExports()
      Limits the current town's distinct recurring export products.
      Returns:
      inclusive product cap, clamped by the host to 1..64
    • productionRules

      default TradeProductionRules productionRules()
      Retains legacy production-policy data for compatibility with existing mod cores. Recorded crate production does not use capacity or renewable-input assumptions.
      Returns:
      legacy immutable rules, or null
    • estimate

      Determines export units from completed packing output in a rolling season-length window, including today. Called both for the actual selection and for previews with one additional selected product. The host validates the returned table, converts loose goods to enabled market packing units, and caps each resulting allowance at recorded packing output for that selected good.
      Parameters:
      world - current settlement and campaign context; completion stages are omitted for previews
      production - completed packing records, selected goods, and stored tradable quantities
      Returns:
      nonnull map of at most 4096 registered resource IDs to nonnull quantities in 0..100000; invalid quantities are rejected rather than clamped
    • recordedExports

      static Map<String,Integer> recordedExports(SettlementTrading.Production production, int maximum)
      Converts selected completed packing records into a bounded recurring export allowance. Farm growth, worker counts and theoretical workstation capacity are not saleable output.
      Parameters:
      production - completed crate-production snapshot
      maximum - maximum crates of one product per season, clamped to 0..100000
      Returns:
      immutable selected crate quantities after flooring and clamping counts, retaining zero-production identities; map iteration order is unspecified
      Throws:
      NullPointerException - if production is null
    • configurableExports

      default boolean configurableExports(SettlementTrading.World world)
      Determines whether players can choose recurring exports rather than using authored goods.
      Parameters:
      world - current settlement context with completion-stage details omitted
      Returns:
      true for configurable exports
    • markets

      Supplies authored markets, for example completed campaign settlements.
      Parameters:
      world - current profile, stage and completion context
      Returns:
      nonnull list of nonnull markets to make available; absent authored markets are hidden
    • travelDays

      int travelDays(String biome)
      Determines shipment duration from the other settlement's biome.
      Parameters:
      biome - uppercase engine biome identifier
      Returns:
      travel time in whole days, clamped by the host to 1..48
    • seasonalGold

      int seasonalGold(int roll)
      Determines a saved or authored town's seasonal income using a stable host random draw.
      Parameters:
      roll - deterministic uniform integer within 0..1,000,000 inclusive
      Returns:
      gold grant, clamped by the host to 0..100000 and remaining integer purse capacity
    • price

      default int price(String resourceId, int baseValue, boolean buying)
      Prices a good using the resource registry's ordinary value.
      Parameters:
      resourceId - resource being traded
      baseValue - authored resource value
      buying - whether the current player is buying
      Returns:
      unit price, clamped by the host to 0..100000; a resulting zero prohibits the trade
    • accepts

      default boolean accepts(String resourceId, Set<String> productionExports)
      Decides whether a town buys a resource from its recurring export identities. The default rejects products that the receiving town itself exports; reserved inventory does not change that decision.
      Parameters:
      resourceId - offered resource
      productionExports - the receiving town's recurring export resource IDs
      Returns:
      true when the town will buy this resource
      Throws:
      NullPointerException - if productionExports is null, or if it rejects a null resourceId