Package forgottentowns.mod.api
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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordAn authored market, with its own finite purse and seasonal production.static final recordDetached completed-production query used by trade policies and colony extensions.static final recordOne completed packing record, retaining the original route shape for mod compatibility.static final recordImmutable settlement context. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanDecides whether a town buys a resource from its recurring export identities.default booleanDetermines whether players can choose recurring exports rather than using authored goods.estimate(SettlementTrading.World world, SettlementTrading.Production production) Determines export units from completed packing output in a rolling season-length window, including today.booleanChooses which other saved towns belong to this network.default List<SettlementTrading.Market> markets(SettlementTrading.World world) Supplies authored markets, for example completed campaign settlements.default intLimits the current town's distinct recurring export products.default intPrices a good using the resource registry's ordinary value.default TradeProductionRulesRetains legacy production-policy data for compatibility with existing mod cores.recordedExports(SettlementTrading.Production production, int maximum) Converts selected completed packing records into a bounded recurring export allowance.intseasonalGold(int roll) Determines a saved or authored town's seasonal income using a stable host random draw.booleansupports(SettlementTrading.World world) Selects the worlds in which this network is available.inttravelDays(String biome) Determines shipment duration from the other settlement's biome.
-
Method Details
-
supports
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
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
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
Map<String,Integer> estimate(SettlementTrading.World world, SettlementTrading.Production production) 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 previewsproduction- 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
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 snapshotmaximum- 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
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
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
Prices a good using the resource registry's ordinary value.- Parameters:
resourceId- resource being tradedbaseValue- authored resource valuebuying- whether the current player is buying- Returns:
- unit price, clamped by the host to 0..100000; a resulting zero prohibits the trade
-
accepts
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 resourceproductionExports- 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
-