szdytom a3d235b10b
add GameBoard
Signed-off-by: szdytom <szdytom@qq.com>
2024-02-04 21:01:06 +08:00

49 lines
937 B
C++

#ifndef OGLG_GAMEBOARD_H_
#define OGLG_GAMEBOARD_H_
#include <vector>
#include <cstdint>
#include <deque>
#include <set>
#include "PlayerMove.h"
#include "pc/pctypes.h"
#include "pc/commcode.h"
#include "pc/astuple.h"
struct PlayerState {
Player id;
Team team;
bool is_defeated;
std::deque<PlayerMove> tasks;
PlayerState();
};
class GameBoard {
public:
GameBoard(std::uint8_t n, std::uint8_t t, pos_t w, pos_t h, const std::vector<Team> &player_team);
const Tile& at(pos_t x, pos_t y) const;
Tile& at(pos_t x, pos_t y);
bool attack(const PlayerMove &o);
void turnUpdate();
void roundUpdate();
bool isTeammate(Player x, Player y) const;
private:
void capitalCaptured(Player target, Player source);
void updatedPosition(pos_t x, pos_t y);
std::uint8_t n, t;
std::vector<PlayerState> players;
pos_t w, h;
std::vector<Tile> board;
std::set<Point> updated_tiles;
std::vector<Player> defeated_players;
};
#endif