Skip to content

Commit fa2f10c

Browse files
committed
rolling a 7 now robs half of all player's resources iff they have more than 7 resource cards
1 parent fede5a6 commit fa2f10c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

include/GameController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class GameController {
6262
bool hasClickHistory();
6363
int getClickHistorySize();
6464

65+
void robPlayers();
66+
6567
bool handlePlayerClick(ScreenCoordinate, Player&);
6668
bool handleTradeOffer(ScreenCoordinate, Player& initiating, std::array<int, 5>, Player& receiving, std::array<int, 5>);
6769
};

src/GameController.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
177177
break;
178178
case ROBBER:
179179
//model.moveRobber(coord);
180+
robPlayers();
181+
180182
if(!hasClickHistory())
181183
storeClick(coord);
182184

@@ -215,7 +217,7 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
215217
}
216218

217219
//TODO Decrement knight count
218-
220+
219221

220222

221223
popState();
@@ -248,6 +250,26 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
248250
return true;
249251
}
250252

253+
void GameController :: robPlayers() {
254+
for (int i = 0; i < model.getNoOfPlayers(); i++) {
255+
int resources[5];
256+
model.getPlayer(i).checkResources(resources);
257+
//int rSum = resources[0] + resources[1] + resources[2] + resources[3] + resources[4];
258+
int rSum = model.getPlayer(i).getWood() +
259+
model.getPlayer(i).getOre() +
260+
model.getPlayer(i).getBrick() +
261+
model.getPlayer(i).getWheat() +
262+
model.getPlayer(i).getWool();
263+
264+
if (rSum > 7) {
265+
for (int j = 0 ; j < rSum/2; j++) {
266+
model.getPlayer(i).addResource(model.getPlayer(i).getRandomResource(), -1);
267+
268+
}
269+
}
270+
}
271+
}
272+
251273
/**
252274
* Handles the event when the cancel button in the top right corner of the screen is pressed. This will
253275
* reset the control state back to the base state.

0 commit comments

Comments
 (0)