Table of Contents

Class ImproveRelationsCommand

Namespace
Core.Diplomacy
Assembly
Core.dll

ENGINE LAYER - Command to improve relations between two countries

Architecture:

  • ENGINE: Generic mechanism using ushort resourceId (resource-agnostic)
  • GAME: Policy layer sets which resource (gold) via factory: (ushort)ResourceType.Gold

Validation:

  • Both countries exist
  • Not at war
  • Source country has enough of the specified resource (if cost > 0)

Execution:

  • Deduct resource cost (if specified)
  • Add "Improved Relations" opinion modifier
  • Emit DiplomacyOpinionChangedEvent
public class ImproveRelationsCommand : BaseCommand, ICommand
Inheritance
object
ImproveRelationsCommand
Implements
Inherited Members

Properties

ImproveRelationsDecayTicks

public int ImproveRelationsDecayTicks { get; set; }

Property Value

int

ImproveRelationsModifierType

public ushort ImproveRelationsModifierType { get; set; }

Property Value

ushort

ImproveRelationsModifierValue

public FixedPoint64 ImproveRelationsModifierValue { get; set; }

Property Value

FixedPoint64

Priority

Get command priority for execution ordering Higher priority commands execute first

public override int Priority { get; }

Property Value

int

ResourceCost

public FixedPoint64 ResourceCost { get; set; }

Property Value

FixedPoint64

ResourceId

public ushort ResourceId { get; set; }

Property Value

ushort

SourceCountry

public ushort SourceCountry { get; set; }

Property Value

ushort

TargetCountry

public ushort TargetCountry { get; set; }

Property Value

ushort

Methods

Deserialize(BinaryReader)

Deserialize command data from binary reader Used for save/load and command replay Must reconstruct identical command state

public override void Deserialize(BinaryReader reader)

Parameters

reader BinaryReader

Binary reader to deserialize from

Execute(GameState)

Execute the command and modify game state Should emit appropriate events for other systems to react Must be deterministic for multiplayer compatibility

public override void Execute(GameState gameState)

Parameters

gameState GameState

Game state to modify

GetSuccessMessage(GameState)

public string GetSuccessMessage(GameState gameState)

Parameters

gameState GameState

Returns

string

GetValidationError(GameState)

public string GetValidationError(GameState gameState)

Parameters

gameState GameState

Returns

string

Serialize(BinaryWriter)

Serialize command data to binary writer Used for save/load and command logging Must be deterministic - same command = same bytes

public override void Serialize(BinaryWriter writer)

Parameters

writer BinaryWriter

Binary writer to serialize to

Undo(GameState)

Undo the command - restore previous state Required for replay systems and error recovery

public override void Undo(GameState gameState)

Parameters

gameState GameState

Game state to restore

Validate(GameState)

Validate that this command can be executed in the current game state. Should be fast and have no side effects.

public override bool Validate(GameState gameState)

Parameters

gameState GameState

Current game state for validation

Returns

bool

True if command can be executed