1#ifndef NANOMMO_SERVER_DUELS_H_
2#define NANOMMO_SERVER_DUELS_H_
22 static constexpr float kReach = 10.0f;
25 static constexpr std::chrono::seconds
kAskTime{30};
52 void Ask(uint32_t
id, uint32_t other);
59 const Duel*
Of(uint32_t
id)
const;
62 uint32_t
Opponent(uint32_t
id)
const;
66 uint32_t
End(uint32_t
id);
70 std::vector<Duel>
Step(std::chrono::nanoseconds time);
73 const std::map<uint32_t, Duel>&
all()
const {
return duels_; }
80 std::map<uint32_t, Duel> duels_;
82 std::map<uint32_t, uint32_t> challengers_;
83 std::set<uint32_t> news_;
static constexpr float kFlagReach
uint32_t Accept(uint32_t id, Place flag)
const Duel * Of(uint32_t id) const
The player's duel, from the ask to the end, or nullptr.
uint32_t End(uint32_t id)
void Ask(uint32_t id, uint32_t other)
The player asks the other to duel. Neither may be in a duel already.
const std::map< uint32_t, Duel > & all() const
Each duel, by its challenger's id.
static constexpr float kReach
A player asks another within this many metres of them.
uint32_t Opponent(uint32_t id) const
Who the player's duelling, by their id, once the countdown's over, or 0.
std::vector< Duel > Step(std::chrono::nanoseconds time)
static constexpr std::chrono::seconds kAskTime
An ask waits this long for a yes.
std::set< uint32_t > TakeNews()
static constexpr std::chrono::seconds kCountdown
From the yes to the duel, so that both sides are ready for it.
std::chrono::nanoseconds left
How long the ask has left, and then the countdown.
uint32_t challenger
Who asked, and who they asked, by their ids.
uint32_t Against(uint32_t id) const
The other side from the player's, by their id.
In metres from the middle of a land.