public sealed class TradeSessionA two-sided trade with a confirm-lock.
Remarks
Doc 28 is emphatic and it is right: the confirm-lock is not UI polish. It is the mechanism that makes the classic swap-at-the-last-moment scam impossible — the one where somebody replaces a legendary with a grey the instant before you click accept.
⚠ A confirmation quotes the revision it saw, and that is the part the document does not say. "Any change re-opens both confirmations" is necessary and not sufficient: it loses the race where a change and a confirmation cross in flight, because the confirmation arrives after the change has already cleared the flags and simply sets one again — against goods its sender never saw. Making the client quote a revision turns that race into a Stale, and it is the only form of the rule that holds without assuming an ordering the network does not give.
⚠ Nothing here moves anything. Settle produces one EconomyIntent and the ledger decides; a trade that half-applied is the duplication bug the whole design exists to prevent, and one intent is the only arrangement in which it cannot happen.
Fields and properties (8)
public PlayerId LeftOne party.
public PlayerId RightThe other.
public string IdWhat names it.
public TradeStatus StatusWhere it is.
public int RevisionHow many times what is on the table has changed. What a confirmation quotes.
public TradeOffer LeftOfferWhat the left is offering.
public TradeOffer RightOfferWhat the right is offering.
public bool IsLockedWhether both have confirmed the current revision.
Events (1)
public Action<TradeSession>? ChangedRaised whenever what is on the table changes, so both clients redraw.
Methods (9)
public TradeSession(PlayerId left, PlayerId right, string id)Opens a trade between two players.
public bool HasConfirmed(PlayerId player)Whether somebody has confirmed the current revision.
public TradeOffer? OfferOf(PlayerId player)What a player is offering.
public TradeRefusal Offer(PlayerId player, DefId asset, long amount)Puts something on the table, or takes it off with a zero.
public TradeRefusal Confirm(PlayerId player, int revision)Says yes to what is on the table right now.
public TradeRefusal Unconfirm(PlayerId player)Takes a confirmation back.
public TradeRefusal Cancel(PlayerId player)Calls it off.
public EconomyIntent? Compose()What the swap would be, as one intent.
public TradeRefusal Settle(IEconomyLedger ledger, out EconomyResult result)Does the swap.
Used by (1)
- TradeTestsVixen.Gameplay.Economy.Tests