-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameFlow.h
72 lines (59 loc) · 1.67 KB
/
GameFlow.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Yael Hacmon, ID 313597897
* Roni Fultheim, ID 313465965
*/
#ifndef GameManager_H_
#define GameManager_H_
#include <iostream>
#include "Board.h"
#include "MoveLogic.h"
#include "Player.h"
#include "Location.h"
/**
* Controls the game flow of a Reversi game when given a board, two players
* and an object to control the logic of every move.
*
* Is responsible for playing the turns, knowing and notifying when the game ends, and printing
* messages to the players.
*/
class GameManager {
public:
/**
* Constructor taking a board on which to play game, two players, and the logic of the moves.
* @param b board of game
* @param black black player
* @param white white player
* @param log logic to handle moves
*/
GameManager(Board* b, Player* black, Player* white, MoveLogic* log);
/**
* Plays game with the given board, players and logic.
*/
void playGame();
private:
//board of game
Board* board_;
//black player - by reference, to allow polymorphism
Player* black_;
//white player - by reference, to allow polymorphism
Player* white_;
//handles logic of moves - by reference, to allow polymorphism
MoveLogic* logic_;
//location of last played move - must be allocated in
Location lastMove_;
/**
* Plays turn of a given player. Method for clarity and code reuse.
* Is not constant, since playing a turn can cause either player's to change.
*
* @param playing player currently playing
* @param other other player
* @return true if player has played this turn
*/
bool playTurn(Player* playing, Player* other);
/**
* Returns winner of game.
* @return player who won this game
*/
void showWinner();
};
#endif /* GameManager_H_ */