aboutsummaryrefslogtreecommitdiff
path: root/src/game_tab/Game.hpp
blob: 93980560207f7bbc4b81a81a535d37ec2af9081b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once

#include "ChessArbiter.hpp"
#include "HalfMove.hpp"
#include "ochess.hpp"
#include <unordered_map>

#define UNPACK_ABSOLUTE_MOVE(MOVE,SRC,DST) {(SRC)=(MOVE).substr(0,2);(DST)=(MOVE).substr(2,2);}

class Game {
  std::string board;
  std::string initial_fen;
  std::string result;
  std::unordered_map<std::string, std::string> tags;
  HalfMove *moves;
  HalfMove *current;
  chessarbiter::ChessArbiter arbiter;

public:
  Game(const Game* g);
  Game();
  Game(std::string fen);
  Game(HalfMove *m, std::string initial_fen);
  ~Game();
  std::string GetBoard();
  std::string GetTag(std::string tagname);
  void SetTag(std::string tagname, std::string value);
  void DeleteTag(std::string tagname);
  HalfMove *GetCurrentMove();
  HalfMove *GetMoves();
  std::string GetFen();
  std::string GetResult();
  bool Play(std::string move);
  bool IsBlackToPlay();
  void Previous();
  void Next();
  void DeleteMove(HalfMove *m);
  void PromoteMove(HalfMove *m);
  void SetMoveAsMainline(HalfMove *m);
  void SetCurrent(HalfMove *m);
  std::vector<std::string> ListTags();
  void SetResult(std::string result);
  /**
   * @brief Build current game
   * Verify and play all the moves in the game
   * while building the fen for each move
   */
  void BuildAndVerify();
};