-
Notifications
You must be signed in to change notification settings - Fork 2
/
scrabble_game_builder.hpp
59 lines (48 loc) · 1.32 KB
/
scrabble_game_builder.hpp
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
#ifndef scrabble_game_builder_h
#define scrabble_game_builder_h
#include "scrabble_game.hpp"
#include "ai_player.hpp"
#include "human_player.hpp"
#include "scrabble_board.hpp"
#include "scrabble_config.hpp"
#include "piece_source.hpp"
#include <string>
class Scrabble_Game_Builder
{
public:
Scrabble_Game_Builder() : m_game(NULL) {}
void build_scrabble_game(const Scrabble_Config& config)
{
m_game = new Scrabble_Game(config);
}
template <class BOARD_BUILDER_CLASS>
void build_game_board()
{
my_static_assert(m_game, "m_game was null");
BOARD_BUILDER_CLASS builder(*m_game);
m_game->add_board(new Scrabble_Board(builder));
}
template <class PLAYER_CLASS>
void build_player(const std::string& name)
{
my_static_assert(m_game, "m_game was null");
m_game->add_player(new PLAYER_CLASS(name, m_game));
}
template <class LETTER_SOURCE_CLASS>
void build_piece_source()
{
my_static_assert(m_game, "m_game was null");
m_game->add_piece_source(new LETTER_SOURCE_CLASS(*m_game));
}
Scrabble_Game* get_game() const
{
return m_game;
}
private:
//forbidden methods
Scrabble_Game_Builder(const Scrabble_Game_Builder&) = delete;
Scrabble_Game_Builder& operator=(const Scrabble_Game_Builder&) = delete;
//internal state
Scrabble_Game* m_game; // do not delete
};
#endif