1#ifndef NANOMMO_SERVER_TRADES_H_
2#define NANOMMO_SERVER_TRADES_H_
8#include "absl/status/status.h"
9#include "absl/status/statusor.h"
11#include "protocol/nanommo.pb.h"
31 bool Ask(uint32_t
id, uint32_t other);
34 uint32_t
With(uint32_t
id)
const;
37 const protocol::TradeSide&
SideOf(uint32_t
id)
const;
45 bool Holds(uint32_t
id,
const protocol::Place& place)
const;
53 const protocol::TradeOffer& offer);
58 absl::StatusOr<bool>
Ready(uint32_t
id,
bool ready, uint32_t revision);
71 uint32_t
End(uint32_t
id);
82 protocol::TradeSide offer;
83 uint32_t revision = 0;
87 std::map<uint32_t, uint32_t> asked_;
89 std::map<uint32_t, Side> sides_;
90 std::set<uint32_t> news_;
uint32_t End(uint32_t id)
absl::Status Complete(uint32_t id, Inventory &bag, Inventory &other_bag, const ItemTable &items)
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.
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)
std::set< uint32_t > TakeNews()
uint32_t RevisionOf(uint32_t id) const
absl::StatusOr< bool > Ready(uint32_t id, bool ready, uint32_t revision)
The items in the items file, by id.