Skip to content

Commit aff7266

Browse files
committed
Merge remote-tracking branch 'origin/verify_board' into serialization
Conflicts: include/GameBoard.h src/GameBoard.cpp
2 parents 64e04c8 + 5655149 commit aff7266

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

include/GameBoard.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ 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;
26+
std::vector<std::unique_ptr<Player>> players;
27+
28+
void addResource(int x, int y, resourceType res, int val);
2729

2830
public:
2931
GameBoard(std::vector<std::unique_ptr<Player>>&& players);

src/GameBoard.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#include "Serialization.h"
1111
#include "tinyxml2.h"
1212

13-
#define ADD_RESOURCE(x, y, res, val) (this->resources[Coordinate(x,y)] = \
14-
std::unique_ptr<GamePiece>(new ResourceTile(*this, Coordinate(x,y), res, val)))
15-
#define DUMMY_BOARD //define to instantiate dummy board for debugging
16-
1713
using std::random_shuffle;
1814
using std::time;
1915
using std::string;
@@ -106,8 +102,9 @@ std::vector<Settlement*> GameBoard::GetNeighboringSettlements(Coordinate locatio
106102
return v;
107103
}
108104

109-
/* initialize board with a set of resources. Currently only the standard configuration (no custom shapes or expansion packs) is implemented. Board tiles and roll numbers are randomized.
110-
@todo Change the dummy board to the actual board
105+
/*
106+
* Initialize board with a set of resources. Currently only the standard configuration (no custom shapes or expansion packs) is implemented.
107+
* Board tiles and roll numbers are randomized.
111108
*/
112109

113110
void GameBoard::init_resources()
@@ -124,21 +121,21 @@ void GameBoard::init_resources()
124121
int ycoords[] = {1, 2, 0, 4, 3, 2, 1, 6, 5, 4, 3, 2, 7, 6, 5, 4, 8, 7, 6};
125122

126123

127-
#ifdef DUMMY_BOARD
124+
128125
int rollCount = 0;
129126
for (int i = 0; i<19; i++)
130127
{
131128
if (resources[i]==DESERT)
132129
{
133-
ADD_RESOURCE(xcoords[i], ycoords[i], resources[i], 0);
130+
addResource(xcoords[i], ycoords[i], resources[i], 0);
134131
}
135132
else
136133
{
137-
ADD_RESOURCE(xcoords[i], ycoords[i], resources[i], rolls[rollCount]);
134+
addResource(xcoords[i], ycoords[i], resources[i], rolls[rollCount]);
138135
rollCount++;
139136
}
140137
}
141-
#endif
138+
142139
}
143140

144141
void GameBoard::PlaceSettlement(Coordinate location, Player& Owner){
@@ -204,4 +201,15 @@ bool GameBoard::operator==(const GameBoard& other) const {
204201
}
205202
return true;
206203
}
204+
/*
205+
* Adds a resource and roll tile combo to the board
206+
* @param x The first coordinate
207+
* @param y The second coordinate
208+
* @param res The resource type to be added
209+
* @param val The roll tile to be added
210+
*/
211+
void GameBoard::addResource(int x, int y, resourceType res, int val)
212+
{
213+
this->resources[Coordinate(x,y)] = std::unique_ptr<GamePiece>(new ResourceTile(*this, Coordinate(x,y), res, val));
214+
}
207215

0 commit comments

Comments
 (0)