File tree Expand file tree Collapse file tree 4 files changed +23
-5
lines changed
Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,10 @@ class GameBoard {
2323 std::map<Coordinate, std::unique_ptr<GamePiece>> corners;
2424 std::map<Coordinate, std::unique_ptr<GamePiece>> resources;
2525 std::vector<std::unique_ptr<Road>> roads;
26+ std::vector<std::unique_ptr<Player>> players;
2627
2728public:
28- GameBoard ();
29+ GameBoard (std::vector<std::unique_ptr<Player>>&& players );
2930 GameBoard (std::istream& in);
3031 GameBoard (GameBoard&) = delete ;
3132 ~GameBoard ();
Original file line number Diff line number Diff line change @@ -21,8 +21,9 @@ using std::map;
2121using std::unique_ptr;
2222using std::istream;
2323using std::ostream;
24+ using std::vector;
2425
25- GameBoard::GameBoard () {
26+ GameBoard::GameBoard (vector<unique_ptr<Player>>&& players) : players(std::move(players) ) {
2627 init_resources ();
2728}
2829
Original file line number Diff line number Diff line change 99
1010#include < iostream>
1111#include < utility>
12+ #include < vector>
13+ #include < memory>
1214
1315#include " GameBoard.h"
1416#include " UserInput.h"
1517#include " Player.h"
1618#include " Renderer.h"
1719
20+ using std::vector;
21+ using std::unique_ptr;
22+
1823void initGame () {
1924
2025}
@@ -58,8 +63,12 @@ int main(int argc, char *argv[]) {
5863
5964 updateViewport (1024 , 768 );
6065
61- Player testPlayer (" test" );
62- GameBoard testBoard;
66+ vector<unique_ptr<Player>> players;
67+ players.emplace_back (unique_ptr<Player>(new Player (" test" )));
68+
69+ Player& testPlayer = *(players[0 ]);
70+
71+ GameBoard testBoard (std::move (players));
6372
6473 bool running = true ;
6574 while (running) {
Original file line number Diff line number Diff line change 88
99#include < iostream>
1010#include < sstream>
11+ #include < memory>
12+ #include < vector>
1113
14+ using std::vector;
15+ using std::unique_ptr;
1216using std::stringstream;
1317
1418TEST (emptyBoardSerialization) {
15- GameBoard testBoard;
19+ vector<unique_ptr<Player>> players;
20+ players.emplace_back (unique_ptr<Player>(new Player (" test" )));
21+
22+ GameBoard testBoard (std::move (players));
1623
1724 stringstream stream;
1825 testBoard.save (stream);
You can’t perform that action at this time.
0 commit comments