Libsaki
Core library of Pancake Mahjong
app
table_msg.h
1
#ifndef SAKI_APP_TABLE_MSG_H
2
#define SAKI_APP_TABLE_MSG_H
3
4
#include "replay.h"
5
#include "../form/hand.h"
6
#include "../3rd/json.hpp"
7
8
9
10
11
namespace
saki
12
{
13
14
15
16
namespace
field
17
{
18
19
20
constexpr
const
char
*ARGS =
"Args"
;
21
constexpr
const
char
*EVENT =
"Event"
;
22
23
constexpr
const
char
*FORMS =
"forms"
;
24
constexpr
const
char
*HANDS =
"hands"
;
25
constexpr
const
char
*OPENERS =
"openers"
;
26
constexpr
const
char
*PICK =
"pick"
;
27
constexpr
const
char
*RESULT =
"result"
;
28
29
30
31
}
// namespace field
32
33
34
35
class
TableMsgContent
36
{
37
public
:
38
struct
JustPause
39
{
40
int
ms;
41
};
42
43
explicit
TableMsgContent
(
const
char
*event,
const
nlohmann::json
&args);
44
45
template
<
typename
T>
46
TableMsgContent
(
const
T &args)
47
: mJson(args)
48
{
49
}
50
51
std::string event()
const
;
52
const
nlohmann::json
&args()
const
;
53
std::string marshal()
const
;
54
55
private
:
56
nlohmann::json
mJson;
57
};
58
59
void
to_json(
nlohmann::json
&
json
,
const
TableMsgContent::JustPause
&pause);
60
61
62
63
struct
TableMsg
64
{
65
Who
to;
66
TableMsgContent
content;
67
};
68
69
70
71
unsigned
createSwapMask(
const
TileCount
&closed,
72
const
util::Stactor<T37, 13>
&choices);
73
std::string stringOf(
const
T37
&t,
bool
lay =
false
);
74
void
to_json(
nlohmann::json
&json,
const
util::Range<T37>
&ts);
75
void
to_json(
nlohmann::json
&json,
const
util::Range<T34>
&ts);
76
void
to_json(
nlohmann::json
&json,
const
M37
&bark);
77
void
to_json(
nlohmann::json
&json,
const
util::Stactor<M37, 4>
&barks);
78
void
to_json(
nlohmann::json
&json,
const
IrsCheckItem
&item);
79
void
to_json(
nlohmann::json
&json,
const
Rule
&rule);
80
void
to_json(
nlohmann::json
&json,
const
Replay
&replay);
81
void
to_json(
nlohmann::json
&json,
const
Replay::Round
&round);
82
void
to_json(
nlohmann::json
&json,
const
Replay::Track
&track);
83
84
template
<
typename
T>
85
std::string marshal(
const
T &obj)
86
{
87
return
nlohmann::json
(obj).
dump
();
88
}
89
90
Action
makeAction(
const
std::string &actStr,
int
actArg,
91
const
std::string &actTile);
92
93
}
// namespace saki
94
95
96
97
#endif // SAKI_APP_TABLE_MSG_H
nlohmann::basic_json<>
saki::Rule
Definition:
rule.h:13
saki::IrsCheckItem
Definition:
choices.h:13
nlohmann::basic_json::dump
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false) const
serialization
Definition:
json.hpp:11111
saki::TileCount
Definition:
tile_count.h:17
saki::TableMsgContent::JustPause
Definition:
table_msg.h:38
saki::Action
Definition:
action.h:27
saki
Definition:
ai.cpp:18
saki::TableMsgContent
Definition:
table_msg.h:35
saki::Replay::Track
Definition:
replay.h:91
saki::Replay
Definition:
replay.h:54
saki::util::Range
Definition:
stactor.h:34
saki::T37
Definition:
tile.h:353
saki::TableMsg
Definition:
table_msg.h:63
nlohmann::json
basic_json<> json
default JSON class
Definition:
json.hpp:109
saki::M37
Definition:
meld.h:17
saki::util::Stactor
Stactor = statically allocated vector.
Definition:
stactor.h:247
saki::Replay::Round
Definition:
replay.h:98
saki::Who
Definition:
who.h:14
Generated by
1.8.13