Class StatWallet

Namespace
SurvivorsMaker.Core
Assembly
SurvivorsMaker.Core.dll

Per-combat net ledger. Income statistics and pending net settlement are intentionally separate.

public sealed class StatWallet : IStatDebitSource, IStatSource
Inheritance
StatWallet
Implements
Inherited Members

Constructors

StatWallet(int, int)

public StatWallet(int baseBalance, int minimumBalance = 0)

Parameters

baseBalance int
minimumBalance int

Properties

Balance

public int Balance { get; }

Property Value

int

BaseBalance

public int BaseBalance { get; }

Property Value

int

Income

public long Income { get; }

Property Value

long

IsSettled

public bool IsSettled { get; }

Property Value

bool

MinimumBalance

public int MinimumBalance { get; }

Property Value

int

NetChange

public int NetChange { get; }

Property Value

int

Revision

Revision stamp for reported source values; change it whenever those values change.

public long Revision { get; }

Property Value

long

Methods

TryCredit(int)

Credits nonnegative integer currency within wallet bounds; failure leaves balance unchanged.

public bool TryCredit(int amount)

Parameters

amount int

Returns

bool

TryDebit(string, float)

Atomically debits available currency for the currency source key; failure leaves balance unchanged.

public bool TryDebit(string key, float amount)

Parameters

key string
amount float

Returns

bool

TryGet(string, out float)

Reads the currency balance for the currency source key; unknown keys return false.

public bool TryGet(string key, out float value)

Parameters

key string
value float

Returns

bool

TrySettle(out int)

Caller applies netDelta once, replacing the old gross-income settlement path.

public bool TrySettle(out int netDelta)

Parameters

netDelta int

Returns

bool