DemandDef gains optional ConsumptionPerTurn and SustainTurns. When ConsumptionPerTurn > 0 the demand maintains a buffer filled by deliveries and drained each turn. Shortage fires the first turn the buffer can't cover consumption; it clears when the buffer refills. SustainedTurns counts consecutive non-shortage turns, and IsSatisfied flips to true once it meets SustainTurns — so the victory condition becomes "no shortage for N consecutive turns" as soon as a mission opts in. Classic demands (ConsumptionPerTurn = 0) behave exactly as before. TurnExecutor runs the consumption sub-phase after transfers. Two new events (DemandShortageStarted / DemandShortageCleared) let the presentation surface the state later. BoardSnapshot + CampaignLoader carry the new fields; no existing mission opts in yet, so campaign_01.json is unaffected.
22 lines
744 B
C#
22 lines
744 B
C#
namespace Chessistics.Engine.Model;
|
|
|
|
/// <summary>
|
|
/// A demand building.
|
|
///
|
|
/// Classic mode (default): counts deliveries up to <see cref="Amount"/>,
|
|
/// then <see cref="DemandState.IsSatisfied"/> stays true forever.
|
|
///
|
|
/// Recurring mode: set <see cref="ConsumptionPerTurn"/> > 0. The demand
|
|
/// holds a buffer of delivered cargo; each turn it consumes that many
|
|
/// units. If the buffer runs dry it enters shortage. The demand is
|
|
/// considered satisfied once it has spent <see cref="SustainTurns"/>
|
|
/// consecutive turns without shortage.
|
|
/// </summary>
|
|
public record DemandDef(
|
|
Coords Position,
|
|
string Name,
|
|
CargoType Cargo,
|
|
int Amount,
|
|
int Deadline = 0,
|
|
int ConsumptionPerTurn = 0,
|
|
int SustainTurns = 0);
|