补全类型
This commit is contained in:
parent
675692d4be
commit
d233589af0
@ -225,7 +225,7 @@
|
|||||||
|
|
||||||
### 结构化数据编码
|
### 结构化数据编码
|
||||||
|
|
||||||
在把一些数据编码为二进制数据时,逐个将其成员按照顺序紧密得放在一起。在编码整数或浮点数时,直接使用小端序的二进制表示。在编码字符串或不定长数组时,首先给出一个 4 字节的无符号整数表示长度,然后逐个给出其成员元素。
|
在把一些数据编码为二进制数据时,逐个将其成员按照顺序紧密地放在一起。在编码整数或浮点数时,直接使用小端序的二进制表示。在编码字符串或不定长数组时,首先给出一个 4 字节的无符号整数表示长度,然后逐个给出其成员元素。
|
||||||
|
|
||||||
### 过程调用中的类型
|
### 过程调用中的类型
|
||||||
|
|
||||||
@ -334,7 +334,7 @@
|
|||||||
| 成员标识符 | 类型 | 含义 |
|
| 成员标识符 | 类型 | 含义 |
|
||||||
| :--- | :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
| `team` | `Team` | 队伍 |
|
| `team` | `Team` | 队伍 |
|
||||||
| `diffs` | `TeamViewDiff` | 有变化的格子 |
|
| `diffs` | `TileDiff[]` | 有变化的格子 |
|
||||||
|
|
||||||
**类型** `GameState`:用于表示一半回合结束时的状态,该类型用于 `tick` 的返回值。
|
**类型** `GameState`:用于表示一半回合结束时的状态,该类型用于 `tick` 的返回值。
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef OGPC_PCTYPES_H_
|
#ifndef OGPC_PCTYPES_H_
|
||||||
#define OGPC_PCTYPES_H_
|
#define OGPC_PCTYPES_H_
|
||||||
|
|
||||||
#include <cctypes>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "astuple.h"
|
#include "astuple.h"
|
||||||
@ -46,5 +46,100 @@ struct PlayerRanking {
|
|||||||
OGPC_DECLARE_ASTUPLE(player, is_defeated, land, unit)
|
OGPC_DECLARE_ASTUPLE(player, is_defeated, land, unit)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TeamRanking {
|
||||||
|
Team team;
|
||||||
|
std::vector<PlayerRanking> players;
|
||||||
|
|
||||||
|
OGPC_DECLARE_ASTUPLE(team, players)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Tile {
|
||||||
|
Player owner;
|
||||||
|
std::uint8_t type;
|
||||||
|
std::int32_t unit;
|
||||||
|
|
||||||
|
OGPC_DECLARE_ASTUPLE(owner, type, unit)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TileDiff {
|
||||||
|
std::uint8_t x;
|
||||||
|
std::uint8_t y;
|
||||||
|
Tile value;
|
||||||
|
|
||||||
|
OGPC_DECLARE_ASTUPLE(x, y, value)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TeamViewDiff {
|
||||||
|
Team team;
|
||||||
|
std::vector<TileDiff> diffs;
|
||||||
|
|
||||||
|
OGPC_DECLARE_ASTUPLE(team, diffs)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GameState {
|
||||||
|
std::uint32_t halfturn_id;
|
||||||
|
std::vector<Player> defeated_players;
|
||||||
|
std::vector<Player> alive_players;
|
||||||
|
std::vector<TeamRanking> leaderboard;
|
||||||
|
std::vector<TeamViewDiff> diffs;
|
||||||
|
std::vector<std::string> msg;
|
||||||
|
|
||||||
|
OGPC_DECLARE_ASTUPLE(halfturn_id, defeated_players, alive_players, leaderboard, diffs, msg)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Modifier {
|
||||||
|
std::uint32_t key;
|
||||||
|
std::int32_t value;
|
||||||
|
|
||||||
|
OGPC_DECLARE_ASTUPLE(key, value)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ReplayStep {
|
||||||
|
std::uint32_t halfturn_id;
|
||||||
|
std::vector<PlayerMove> player_moves;
|
||||||
|
std::vector<Player> offline_events;
|
||||||
|
|
||||||
|
OGPC_DECLARE_ASTUPLE(halfturn_id, player_moves, offline_events)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PlayerInfo {
|
||||||
|
uuid uid;
|
||||||
|
std::uint8_t id;
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
OGPC_DECLARE_ASTUPLE(uid, id, name)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct InitInfo {
|
||||||
|
std::uint8_t n;
|
||||||
|
std::int32_t player_team;
|
||||||
|
std::vector<Modifier> modifiers;
|
||||||
|
|
||||||
|
OGPC_DECLARE_ASTUPLE(n, player_team, modifiers)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Replay {
|
||||||
|
uuid rid;
|
||||||
|
std::uint64_t timestamp;
|
||||||
|
std::int8_t speed;
|
||||||
|
InitInfo init_info;
|
||||||
|
std::uint32_t length;
|
||||||
|
std::uint8_t player_num;
|
||||||
|
std::vector<PlayerInfo> players;
|
||||||
|
Team winner;
|
||||||
|
std::vector<Tile> terrain;
|
||||||
|
std::vector<ReplayStep> steps;
|
||||||
|
|
||||||
|
OGPC_DECLARE_ASTUPLE(rid, timestamp, speed, init_info, length, player_num, players, winner, terrain, steps)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GameInfo {
|
||||||
|
uuid rid;
|
||||||
|
std::int8_t speed;
|
||||||
|
std::vector<PlayerInfo> players;
|
||||||
|
|
||||||
|
OGPC_DECLARE_ASTUPLE(rid, speed, players)
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user