@@ -224,6 +224,13 @@ const map<Coordinate, unique_ptr<ResourceTile>>& GameBoard::getResources() const
224
224
return resources;
225
225
}
226
226
227
+ ResourceTile& GameBoard::getResourceTile (Coordinate location) const
228
+ {
229
+ // return resources.at(location);
230
+
231
+ return *(resources.find (location)->second );
232
+ }
233
+
227
234
std::vector<Settlement*> GameBoard::GetNeighboringSettlements (
228
235
Coordinate location) const {
229
236
static Coordinate adjacentCoordDiffs[] = { Coordinate (0 , 1 ), Coordinate (1 ,
@@ -463,7 +470,9 @@ int GameBoard::FindLongestRoad_FromPoint(Coordinate curr, const Player & owner,
463
470
464
471
465
472
void GameBoard::PlaceSettlement (Coordinate location, Player& Owner){
466
- corners[location] = std::unique_ptr<CornerPiece>(new Settlement (*this , location, Owner));
473
+ if (resources.find (location) == resources.end () && !outOfBounds (location))
474
+ corners[location] = std::unique_ptr<CornerPiece>(new Settlement (*this , location, Owner));
475
+
467
476
}
468
477
469
478
void GameBoard::PlaceCity (Coordinate location, Player& Owner){
@@ -472,6 +481,7 @@ void GameBoard::PlaceCity(Coordinate location, Player& Owner){
472
481
}
473
482
474
483
void GameBoard::UpgradeSettlement (Coordinate location){
484
+ if (corners.find (location) != corners.end ())
475
485
corners[location] = std::unique_ptr<CornerPiece>(new City (*corners[location])); // TODO test for memory leak
476
486
}
477
487
0 commit comments