@@ -100,8 +100,6 @@ void GameBoard::createRing(Coordinate topRight, int sideLength, vector<resourceT
100100void GameBoard::insertTile (Coordinate location, vector<resourceType>& resources, vector<int >& rolls) {
101101 if (rolls.back () == 0 ) {
102102 addResource (location.first , location.second , DESERT, rolls.back ());
103- // moveRobber(Coordinate(location.first, location.second));
104- // std::cout << location.first << location.second << "\n";
105103 rolls.pop_back ();
106104 } else {
107105 addResource (location.first , location.second , resources.back (), rolls.back ());
@@ -406,16 +404,15 @@ std::vector<Settlement*> GameBoard::GetNeighboringSettlements(
406404 * @param location The location to search the neighbors of.
407405 * @return A vector of the corner pieces in the vicinity.
408406 */
409- std::vector<CornerPiece*> GameBoard::GetNeighboringCorners (
410- Coordinate location) const {
411- static Coordinate adjacentCoordDiffs[] = { Coordinate (0 , 1 ), Coordinate (1 ,
412- 0 ), Coordinate (1 , -1 ), Coordinate (0 , -1 ), Coordinate (-1 , 0 ),
413- Coordinate (-1 , 1 ) };
407+ std::vector<CornerPiece*> GameBoard::GetNeighboringCorners (Coordinate location) const {
408+ static Coordinate adjacentCoordDiffs[] = { Coordinate (0 , 1 ), Coordinate (1 ,0 ),
409+ Coordinate (1 , -1 ), Coordinate (0 , -1 ), Coordinate (-1 , 0 ), Coordinate (-1 , 1 ) };
410+
414411 std::vector<CornerPiece*> v;
415412 for (unsigned int i = 0 ; i < 6 ; i++) {
416413 const Coordinate& diff = adjacentCoordDiffs[i];
417- Coordinate adjacentPoint (location.first + diff.first ,
418- location. second + diff. second );
414+ Coordinate adjacentPoint (location.first + diff.first , location. second + diff. second );
415+
419416 auto it = corners.find (adjacentPoint);
420417 if (it != corners.end ()) {
421418 GamePiece* piece = it->second .get ();
@@ -523,21 +520,22 @@ bool GameBoard::verifyRoadPlacement(Coordinate start, Coordinate end, Player& Ow
523520 * Move the robber to a new coordinate on the board.
524521 * @param newRobber The coordinate to move the robber to.
525522 */
526- void GameBoard::moveRobber (Coordinate newRobber) {
523+ bool GameBoard::moveRobber (Coordinate newRobber) {
527524
528525 // Bounds check
529- if (resources.count (newRobber) > 0 )
526+ if (resources.find (newRobber) != resources. end ()){
530527 robber = newRobber;
528+ return true ;
529+ }
530+ return false ;
531531}
532532
533533/* *
534- * DOES NOT WORK BECAUSE getNeighboringCorners() does not work
534+ * Returns whether the robber can rob the Player opponent at the recourse tile Coordinate location
535+ * @return true if the robber can rob the opponent, false otherwise
535536 */
536537bool GameBoard::canRobberRob (Player& opponent, Coordinate location){
537- std::cout << GetNeighboringCorners (location).size () << " \n " ;
538-
539538 for (auto corner : GetNeighboringCorners (location)){
540- std::cout << corner->getOwner ().getName () << " derp\n " ;
541539 if (corner->getOwner () == opponent){
542540 return true ;
543541 }
0 commit comments