Skip to content

Commit 67630f0

Browse files
committed
merged into master to resolve conflicts
2 parents b6056ae + cb45f80 commit 67630f0

File tree

11 files changed

+366
-116
lines changed

11 files changed

+366
-116
lines changed

include/GameBoard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class GameBoard {
137137

138138
bool testRollChecking(int* rolls);
139139

140-
void moveRobber(Coordinate newRobber);
140+
bool moveRobber(Coordinate newRobber);
141141
Coordinate getRobber() const;
142142
bool canRobberRob(Player& opponent, Coordinate location);
143143

include/GameController.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ class GameController {
4747
bool handleMonopolyCardButtonEvent(ScreenCoordinate);
4848
bool handleVictoryPointCardButtonEvent(ScreenCoordinate);
4949

50+
bool handleWoodButtonEvent(ScreenCoordinate);
51+
bool handleSheepButtonEvent(ScreenCoordinate);
52+
bool handleWheatButtonEvent(ScreenCoordinate);
53+
bool handleOreButtonEvent(ScreenCoordinate);
54+
bool handleBrickButtonEvent(ScreenCoordinate);
55+
5056
bool handleCancelButtonEvent(ScreenCoordinate);
5157

5258
bool handleConfirmRoadCard(ScreenCoordinate);

include/GameView.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class GameView {
5555
void drawCardCount(std::string font, int fontSize);
5656
void drawResourceCount(std::string font, int fontSize);
5757

58+
std::string controlStateText;
59+
5860
GameView(const GameView& o) = delete;
5961
GameView& operator=(const GameView& o) = delete;
6062
public:
@@ -64,6 +66,8 @@ class GameView {
6466
void render();
6567
bool acceptInput(SDL_Event& event);
6668

69+
void setControlStateText(std::string newText);
70+
6771

6872
void addPointOfInterest(ScreenCoordinate);
6973
void clearPointsOfInterest();

src/GameBoard.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ void GameBoard::createRing(Coordinate topRight, int sideLength, vector<resourceT
108108
void 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
*/
544545
bool 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

Comments
 (0)