|
| bool | Ask (uint32_t id, uint32_t other) |
| uint32_t | With (uint32_t id) const |
| | Who the player's trading with, by their id, or 0 for nobody.
|
| const protocol::TradeSide & | SideOf (uint32_t id) const |
| | What the player offers, and whether they're ready, while they trade.
|
| uint32_t | RevisionOf (uint32_t id) const |
| bool | Holds (uint32_t id, const protocol::Place &place) const |
| absl::Status | Offer (uint32_t id, const Inventory &bag, const ItemTable &items, const protocol::TradeOffer &offer) |
| absl::StatusOr< bool > | Ready (uint32_t id, bool ready, uint32_t revision) |
| absl::Status | Complete (uint32_t id, Inventory &bag, Inventory &other_bag, const ItemTable &items) |
| uint32_t | End (uint32_t id) |
| std::set< uint32_t > | TakeNews () |
The trades between the players in one copy of a land, which its World keeps, so that both players are always in it. A player asks another to trade, and the trade opens once the other asks them back. Each side offers stacks from their bag, by their places, and gold, and once both sides are ready, each gets what the other offered.
Nothing a client says is trusted. What's offered is held where it is until the trade's over, each change to an offer takes the trade to its next revision, which a ready has to name, and the trade gives nothing unless each place still has what was offered.
Definition at line 26 of file trades.h.
Once both sides are ready: each bag gives up what it offered and gets what the other offered, all of it or none, and the trade's over. Each place offered has to have at least as many as it did, of the same item with the same rolls. If one hasn't, a bag hasn't room, or a side hasn't the gold it offered, neither side is ready any more, and the error says why, in words for both players.
Definition at line 122 of file trades.cc.
| absl::Status nanommo::Trades::Offer |
( |
uint32_t | id, |
|
|
const Inventory & | bag, |
|
|
const ItemTable & | items, |
|
|
const protocol::TradeOffer & | offer ) |
What the player offers from their bag, in place of what they offered before: copies of the stacks at the offer's places, whole, and gold they have. Neither side is ready any more, as there's something new to look at, and the trade's at its next revision. Or the error says why not, in words for the player.
Definition at line 70 of file trades.cc.