1 #ifndef _NALCG_MIDDLEMAN_H_
2 #define _NALCG_MIDDLEMAN_H_
6 #include "ais/aiinfo.h"
8 #include "logic/colour.h"
9 #include "logic/board.h"
10 #include "logic/chesspieces-meta.h"
11 #include "client/remoteplayer.h"
21 static const unsigned int HALF_TURN
= 1;
22 static const unsigned int FULL_TURN
= 2;
24 Middleman(const std::vector
<AI
*>& aiList
, const std::vector
<AIInfo
>& aiInfos
);
30 std::vector
<std::size_t> getValidMovesAt(std::size_t x
, std::size_t y
) const;
32 unsigned int move( std::size_t fromX
, std::size_t fromY
,
33 std::size_t toX
, std::size_t toY
,
34 unsigned int promoteTo
= 0,
35 bool fromRemote
= false);
37 void undo(unsigned int steps
= FULL_TURN
);
39 std::size_t getAICount() const { return aiList
.size(); }
41 const AIInfo
& getAIInfoAt(std::size_t index
) const { return aiInfos
.at(index
); }
43 const std::vector
<std::string
>& getGameLog() const { return gameLog
; }
45 const Board
* getGameStateAt(std::size_t index
) const { return gameStates
.at(index
); }
47 // Should be called *after* playRound(), since that updates currentPlayer.
48 unsigned int getGameConditionMask() const;
50 void addView(EndUser
* _view
) { view
= _view
; }
52 // 0 = Human, 1..n = AI player index + 1.
53 void setControl(unsigned int whiteController
, unsigned int blackController
);
55 void setAICutoffDepth(int white
, int black
);
57 // Methods (possibly) over IP
58 void sendChallenge(const std::string
& remotePlayer
);
60 void promptChallenge(const std::string
& challenger
);
62 void respondToChallenge(bool accept
);
64 void updateUsers(const std::vector
<std::string
>& users
);
75 std::vector
<AI
*> aiList
;
76 std::vector
<AIInfo
> aiInfos
;
77 std::vector
<Board
*> gameStates
;
78 std::vector
<std::string
> gameLog
;
83 void moveUpdate(std::size_t fromX
, std::size_t fromY
,
84 std::size_t toX
, std::size_t toY
, bool continuous
= false);
86 void promoteUpdate( std::size_t fromX
, std::size_t fromY
,
87 std::size_t toX
, std::size_t toY
,
88 unsigned int promoteTo
);
90 void remoteUpdate( std::size_t fromX
, std::size_t fromY
,
91 std::size_t toX
, std::size_t toY
,
92 unsigned int promoteTo
);
96 void updateBoardForAI();
98 const std::string
newLogEntry( std::size_t fromX
, std::size_t fromY
,
99 std::size_t toX
, std::size_t toY
) const;
101 template <typename T
>
102 void deleteAndClear(std::vector
<T
>& vector
);
105 #endif // _NALCG_MIDDLEMAN_H_