@@ -108,8 +108,6 @@ void GameBoard::createRing(Coordinate topRight, int sideLength, vector<resourceT
108108void GameBoard::insertTile (Coordinate location, vector<resourceType>& resources, vector<int >& rolls) {
109109 if (rolls.back () == 0 ) {
110110 addResource (location.first , location.second , DESERT, rolls.back ());
111- // moveRobber(Coordinate(location.first, location.second));
112- // std::cout << location.first << location.second << "\n";
113111 rolls.pop_back ();
114112 } else {
115113 addResource (location.first , location.second , resources.back (), rolls.back ());
@@ -414,16 +412,15 @@ std::vector<Settlement*> GameBoard::GetNeighboringSettlements(
414412 * @param location The location to search the neighbors of.
415413 * @return A vector of the corner pieces in the vicinity.
416414 */
417- std::vector<CornerPiece*> GameBoard::GetNeighboringCorners (
418- Coordinate location) const {
419- static Coordinate adjacentCoordDiffs[] = { Coordinate (0 , 1 ), Coordinate (1 ,
420- 0 ), Coordinate (1 , -1 ), Coordinate (0 , -1 ), Coordinate (-1 , 0 ),
421- Coordinate (-1 , 1 ) };
415+ std::vector<CornerPiece*> GameBoard::GetNeighboringCorners (Coordinate location) const {
416+ static Coordinate adjacentCoordDiffs[] = { Coordinate (0 , 1 ), Coordinate (1 ,0 ),
417+ Coordinate (1 , -1 ), Coordinate (0 , -1 ), Coordinate (-1 , 0 ), Coordinate (-1 , 1 ) };
418+
422419 std::vector<CornerPiece*> v;
423420 for (unsigned int i = 0 ; i < 6 ; i++) {
424421 const Coordinate& diff = adjacentCoordDiffs[i];
425- Coordinate adjacentPoint (location.first + diff.first ,
426- location. second + diff. second );
422+ Coordinate adjacentPoint (location.first + diff.first , location. second + diff. second );
423+
427424 auto it = corners.find (adjacentPoint);
428425 if (it != corners.end ()) {
429426 GamePiece* piece = it->second .get ();
@@ -531,21 +528,22 @@ bool GameBoard::verifyRoadPlacement(Coordinate start, Coordinate end, Player& Ow
531528 * Move the robber to a new coordinate on the board.
532529 * @param newRobber The coordinate to move the robber to.
533530 */
534- void GameBoard::moveRobber (Coordinate newRobber) {
531+ bool GameBoard::moveRobber (Coordinate newRobber) {
535532
536533 // Bounds check
537- if (resources.count (newRobber) > 0 )
534+ if (resources.find (newRobber) != resources. end ()){
538535 robber = newRobber;
536+ return true ;
537+ }
538+ return false ;
539539}
540540
541541/* *
542- * DOES NOT WORK BECAUSE getNeighboringCorners() does not work
542+ * Returns whether the robber can rob the Player opponent at the recourse tile Coordinate location
543+ * @return true if the robber can rob the opponent, false otherwise
543544 */
544545bool GameBoard::canRobberRob (Player& opponent, Coordinate location){
545- std::cout << GetNeighboringCorners (location).size () << " \n " ;
546-
547546 for (auto corner : GetNeighboringCorners (location)){
548- std::cout << corner->getOwner ().getName () << " derp\n " ;
549547 if (corner->getOwner () == opponent){
550548 return true ;
551549 }
0 commit comments