Class UpgradeShopRules

Namespace
TDMaker.Core
Assembly
TDMaker.Core.dll

Storage-independent immutable star-shop transitions. Forced battle ranks never affect spending.

public static class UpgradeShopRules
Inheritance
UpgradeShopRules
Inherited Members

Methods

Available(UpgradeSnapshot, long)

Earned total minus spending. A negative balance remains visible for invalid imported profiles.

public static long Available(UpgradeSnapshot state, long earnedTotal)

Parameters

state UpgradeSnapshot
earnedTotal long

Returns

long

CanPurchase(UpgradeSnapshot, long, string, int)

Accepts only the immediate next rank with sufficient stars.

public static bool CanPurchase(UpgradeSnapshot state, long earnedTotal, string trackId, int rank)

Parameters

state UpgradeSnapshot
earnedTotal long
trackId string
rank int

Returns

bool

CanRevert(UpgradeSnapshot, UpgradeSnapshot)

Tests purchased-state equality against the opening baseline.

public static bool CanRevert(UpgradeSnapshot state, UpgradeSnapshot openingBaseline)

Parameters

state UpgradeSnapshot
openingBaseline UpgradeSnapshot

Returns

bool

Open(UpgradeSnapshot)

Captures the complete purchase state on opening the shop. Immutable snapshots need no mutable copy.

public static UpgradeSnapshot Open(UpgradeSnapshot state)

Parameters

state UpgradeSnapshot

Returns

UpgradeSnapshot

ResetAll(UpgradeSnapshot, out UpgradeSnapshot)

Clears every purchase and replaces the revert baseline with that same empty state.

public static UpgradeSnapshot ResetAll(UpgradeSnapshot state, out UpgradeSnapshot openingBaseline)

Parameters

state UpgradeSnapshot
openingBaseline UpgradeSnapshot

Returns

UpgradeSnapshot

Revert(UpgradeSnapshot)

Restores the opening baseline, rather than undoing one purchase.

public static UpgradeSnapshot Revert(UpgradeSnapshot openingBaseline)

Parameters

openingBaseline UpgradeSnapshot

Returns

UpgradeSnapshot

Spent(UpgradeSnapshot)

Sum of every purchased stage's incremental cost; checked for overflow.

public static long Spent(UpgradeSnapshot state)

Parameters

state UpgradeSnapshot

Returns

long

TryPurchase(UpgradeSnapshot, long, string, int, out UpgradeSnapshot)

Returns a purchased copy, or the unchanged state on refusal.

public static bool TryPurchase(UpgradeSnapshot state, long earnedTotal, string trackId, int rank, out UpgradeSnapshot result)

Parameters

state UpgradeSnapshot
earnedTotal long
trackId string
rank int
result UpgradeSnapshot

Returns

bool