nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
trade_window.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_TRADE_WINDOW_H_
2#define NANOMMO_CLIENT_TRADE_WINDOW_H_
3
4#include <cstdint>
5#include <optional>
6#include <utility>
7
8#include "content/items.h"
9#include "protocol/nanommo.pb.h"
10
11namespace nanommo {
12
13/// What a side of a trade offers, as an offer that asks for it again: its
14/// places in the bag, in order, and its gold.
15protocol::TradeOffer OfferOf(const protocol::TradeSide& side);
16
17/// A trade with another player, in a window of its own, which is open while
18/// the trade is. What you offer is on the left: drag items onto it from the
19/// bag, click one to take it back, and type the gold. What they offer is on
20/// the right. A side's slots light green once it's ready, Ready says you are,
21/// and a change to either offer makes neither side ready. Closing the window
22/// calls the trade off.
24 public:
25 explicit TradeWindow(ItemTable items) : items_(std::move(items)) {}
26
27 /// Draws it while there's a trade. Returns what the player does, which the
28 /// server does, or says in the chat why not.
29 std::optional<protocol::TradeAction> Build(const protocol::Trade& trade);
30
31 private:
32 ItemTable items_;
33 /// The gold being typed, which is the offer's while nobody's typing.
34 uint32_t gold_ = 0;
35 bool typing_ = false;
36};
37
38} // namespace nanommo
39
40#endif // NANOMMO_CLIENT_TRADE_WINDOW_H_
std::optional< protocol::TradeAction > Build(const protocol::Trade &trade)
TradeWindow(ItemTable items)
Definition chat.cc:9
protocol::TradeOffer OfferOf(const protocol::TradeSide &side)
The items in the items file, by id.
Definition items.h:18