Skip to content

Commit a300c1f

Browse files
committed
UI elements are starting to work properly. Road Building card works,
yay. Still working on other cards.
1 parent c16982d commit a300c1f

File tree

8 files changed

+30
-20
lines changed

8 files changed

+30
-20
lines changed

include/GameController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class GameController {
4141
bool handleCancelButtonEvent(ScreenCoordinate);
4242

4343
bool handleConfirmRoadCard(ScreenCoordinate);
44-
bool handleCancelRoadCard(ScreenCoordinate);
44+
bool handleCancelDialogueEvent(ScreenCoordinate);
4545

4646
void pushState(ControlState);
4747
ControlState getState();

include/Player.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class Player {
112112
int getWheat() const;
113113
int getWool() const;
114114

115+
void giveDevCardBoon();
116+
115117
int getDevelopmentCards(int card_type) const;
116118
int getVictoryCards() const;
117119
int getKnightCards() const;

include/Util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ std::string toString(T t) {
3232
return stream.str();
3333
}
3434

35-
#endif
35+
#endif

src/GameBoard.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,13 @@ const std::vector<std::unique_ptr<Player>>& GameBoard::getPlayers() const {
822822
return players;
823823
}
824824

825+
/**
826+
* WARNING THIS FUNCTION GIVES THE PLAYERS CHEATS SO I COULD DEBUG
827+
*/
825828
Player& GameBoard::getCurrentPlayer(){
826-
return *(players[0]);
829+
Player & curr_player = getPlayer(0);
830+
curr_player.giveDevCardBoon();
831+
return getPlayer(0);
827832
}
828833

829834
/**

src/GameController.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
126126
using namespace std::placeholders;
127127
view.addElement(makeConfirmationDialogue(
128128
std::bind(&GameController::handleConfirmRoadCard, this, _1),
129-
std::bind(&GameController::handleCancelRoadCard, this, _1), {{.2, .3}, {.8, .6}}));
129+
std::bind(&GameController::handleCancelDialogueEvent, this, _1), {{.2, .3}, {.8, .6}}));
130130
pushState(MODALSTATE);
131131
}
132132
break;
@@ -196,15 +196,12 @@ bool GameController::handleRoadCardButtonEvent(ScreenCoordinate coord){
196196
}
197197

198198
bool GameController::handleConfirmRoadCard(ScreenCoordinate coord){
199-
//play card
200-
std::cout << "CONFIRMED!";
201199
model.getCurrentPlayer().playRoadBuilding(getPastClick(3), getPastClick(2), getPastClick(1), getPastClick(0));
202200
view.removeLastElement();
203201
return handleCancelButtonEvent(coord);
204202
}
205203

206-
bool GameController::handleCancelRoadCard(ScreenCoordinate coord){
207-
std::cout << "CANCELLED!";
204+
bool GameController::handleCancelDialogueEvent(ScreenCoordinate coord){
208205
view.removeLastElement();
209206
return handleCancelButtonEvent(coord);
210207
}
@@ -215,7 +212,6 @@ bool GameController::handleKnightCardButtonEvent(ScreenCoordinate){
215212
return true;
216213
}
217214
pushState(KNIGHT_DEVCARD);
218-
pushState(ROBBER);
219215
return true;
220216
}
221217

src/Player.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,12 @@ bool Player::playRoadBuilding(Coordinate start1, Coordinate end1, Coordinate sta
378378
}
379379

380380

381+
void Player::giveDevCardBoon(){
382+
for(int i = 0; i < 5; i++){
383+
developmentCards[i]+=5;
384+
}
385+
}
386+
381387
int Player::getDevelopmentCards(int card_type) const{
382388
return developmentCards[card_type];
383389
}

tests/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include <UnitTest++.h>
2-
3-
int main() {
4-
return UnitTest::RunAllTests();
5-
}
6-
1+
//#include <UnitTest++.h>
2+
//
3+
//int main() {
4+
// return UnitTest::RunAllTests();
5+
//}
6+
//

tests/test_DevelopmentCards.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,17 @@ TEST(RoadBuildingCard){
9090
test_board.PlaceSettlement(Coordinate(0,0), test_player);
9191
std::unique_ptr<DevelopmentCard> test_card = std::unique_ptr<DevelopmentCard>(new RoadBuildingCard());
9292

93-
test_player.addOre(3);
94-
test_player.addWheat(3);
95-
test_player.addWool(3);
93+
test_player.addOre(4);
94+
test_player.addWheat(4);
95+
test_player.addWool(4);
96+
test_player.buyCard(test_card);
9697
test_player.buyCard(test_card);
9798
test_player.buyCard(test_card);
9899
test_player.buyCard(test_card);
99100

100-
101+
testRoadBuildingCard(test_player, true, test_board, Coordinate(0,0), Coordinate(-1,1), Coordinate(-1,1), Coordinate(-1,2));
101102
testRoadBuildingCard(test_player, true, test_board, Coordinate(0,0), Coordinate(1,0), Coordinate(1,0), Coordinate(1,1));
102-
testRoadBuildingCard(test_player, true, test_board, Coordinate(0,2), Coordinate(1,1), Coordinate(-1,1), Coordinate(0,0));
103+
testRoadBuildingCard(test_player, true, test_board, Coordinate(0,2), Coordinate(1,1), Coordinate(1,1), Coordinate(2,1));
103104
testRoadBuildingCard(test_player, true, test_board, Coordinate(1,3), Coordinate(0,3), Coordinate(0,3), Coordinate(0,2));
104105

105106
testRoadBuildingCard(test_player, false, test_board, Coordinate(-500,200), Coordinate(100,340), Coordinate(21123,12312), Coordinate(343,321));

0 commit comments

Comments
 (0)