nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
duel_window.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_DUEL_WINDOW_H_
2#define NANOMMO_CLIENT_DUEL_WINDOW_H_
3
4#include <cstdint>
5#include <optional>
6
7#include "protocol/nanommo.pb.h"
8
9namespace nanommo {
10
11/// The countdown's whole seconds, rounded up, so that it says 1 until the
12/// duel starts.
13uint32_t CountdownSeconds(uint32_t milliseconds);
14
15/// A duel on the screen: a question when someone asks you, with Duel and Not
16/// now, the countdown's seconds in the middle of the screen, and Fight! as it
17/// starts. Who won goes in the chat, from the server.
19 public:
20 /// How long Fight! stays up, in seconds, as it fades.
21 static constexpr double kFight = 1.0;
22
23 /// How long an answer hides the question, in seconds, while the server
24 /// hears it. If it's still asking after that, as when it turned a yes down,
25 /// the question's back.
26 static constexpr double kAnswering = 1.0;
27
28 /// Draws what the duel needs now. Returns the player's answer, once.
29 std::optional<protocol::DuelAction> Build(const protocol::Duel& duel);
30
31 private:
32 protocol::DuelState state_ = protocol::DUEL_NONE;
33 /// When the duel started, by ImGui's clock.
34 double started_ = -kFight;
35 /// When we answered the ask that's up, by ImGui's clock.
36 double answered_ = -kAnswering;
37};
38
39} // namespace nanommo
40
41#endif // NANOMMO_CLIENT_DUEL_WINDOW_H_
std::optional< protocol::DuelAction > Build(const protocol::Duel &duel)
Draws what the duel needs now. Returns the player's answer, once.
static constexpr double kAnswering
Definition duel_window.h:26
static constexpr double kFight
How long Fight! stays up, in seconds, as it fades.
Definition duel_window.h:21
Definition chat.cc:9
uint32_t CountdownSeconds(uint32_t milliseconds)