Fixed initialization order in animation manager.
[NALCG.git] / src / middleman.h
blob719a591dc4f5561c2807f45de200b2c875a0670e
1 #ifndef _NALCG_MIDDLEMAN_H_
2 #define _NALCG_MIDDLEMAN_H_
4 // class includes
5 #include "ai.h"
6 #include "aiinfo.h"
7 #include "enduser.h"
8 #include "logic/colour.h"
9 #include "logic/board.h"
10 #include "logic/chesspieces-meta.h"
12 // system includes
13 #include <cassert>
14 #include <vector>
16 class Middleman
18 public:
19 // Constants
20 static const unsigned int HALF_TURN = 1;
21 static const unsigned int FULL_TURN = 2;
23 Middleman(const std::vector<AI*>& aiList, const std::vector<AIInfo>& aiInfos);
24 virtual ~Middleman();
26 // Methods
27 void startGame();
29 Colour endGame();
31 std::vector<std::size_t> getValidMovesAt(std::size_t x, std::size_t y) const;
33 unsigned int move( std::size_t fromX, std::size_t fromY,
34 std::size_t toX, std::size_t toY,
35 unsigned int promoteTo = 0);
37 void undo(unsigned int steps = FULL_TURN);
39 // Getters
40 std::size_t getAICount() const { return aiList.size(); }
42 const AIInfo& getAIInfoAt(std::size_t index) const { return aiInfos.at(index); }
44 const std::vector<std::string>& getGameLog() const { return gameLog; }
46 const Board* getGameStateAt(std::size_t index) const { return gameStates.at(index); }
48 // Should be called *after* playRound(), since that updates currentPlayer.
49 unsigned int getGameConditionMask() const;
51 // Setters
52 void addView(EndUser* view) { views.push_back(view); }
54 private:
55 // Members
56 Board* board;
57 Colour currentTurn;
58 unsigned int rounds;
59 std::vector<EndUser*> views;
60 std::vector<AI*> aiList;
61 std::vector<AIInfo> aiInfos;
62 std::vector<Board*> gameStates;
63 std::vector<std::string> gameLog;
65 // Methods
66 void playRound();
68 void moveUpdate(std::size_t fromX, std::size_t fromY,
69 std::size_t toX, std::size_t toY, bool continuous = false);
71 void promoteUpdate( std::size_t fromX, std::size_t fromY,
72 std::size_t toX, std::size_t toY,
73 unsigned int promoteTo);
75 void boardUpdate();
77 const std::string newLogEntry( std::size_t fromX, std::size_t fromY,
78 std::size_t toX, std::size_t toY) const;
80 template <typename T>
81 void deleteAndClear(std::vector<T>& vector);
84 #endif // _NALCG_MIDDLEMAN_H_