Skip to content

Commit cb45f80

Browse files
committed
Merge pull request #55 from Databean/polishing_controls
Polishing controls
2 parents 7dd129b + 44c9612 commit cb45f80

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed

src/GameController.cpp

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ GameController::GameController(GameBoard& model, GameView& view) : model(model),
2828
view.addElement(makeViewButtonText(std::bind(&GameController::handleSettlementButtonEvent, this, _1), {{0.20, 0.0}, {0.33, 0.1}}, font, fontSize, "Settlement"));
2929
view.addElement(makeViewButtonText(std::bind(&GameController::nextTurn, this, _1), {{0, 0.3}, {0.1, 0.4}}, font, fontSize, "End Turn"));
3030

31-
auto playerTopY = 0.9;
31+
auto playerTopY = 0.82;
3232
for(auto i = 0; i < model.getNoOfPlayers(); i++) {
3333
auto width = 0.15;
3434
Player& player = model.getPlayer(i);
@@ -174,7 +174,6 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
174174
printPlayerInfo(model.getCurrentPlayer());
175175
auto coord = screenToCoord(screenCoord);
176176
std::vector<Settlement*> neighbors;
177-
int resourceToSteal;
178177

179178
switch (getState()){
180179
case BUILDROAD:
@@ -209,13 +208,10 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
209208
}
210209
break;
211210
case KNIGHT_DEVCARD:
212-
213-
storeClick(coord);
214-
view.setControlStateText("Select a player around that tile to steal from (Select yourself if you don't want to rob anyone)");
215-
break;
216-
case VICTORYPOINT_DEVCARD:
217-
model.getCurrentPlayer().playVictoryCard();
218-
handleCancelButtonEvent(screenCoord);
211+
if(!hasClickHistory()){
212+
storeClick(coord);
213+
view.setControlStateText("Select a player around that tile to steal from (Select yourself if you don't want to rob anyone)");
214+
}
219215
break;
220216
case BUILDSETTLEMENT:
221217
std::cout << "attempting to buy a settlement" << std::endl;
@@ -405,15 +401,15 @@ bool GameController::handleMonopolyCardButtonEvent(ScreenCoordinate coord){
405401
}
406402

407403
/**
408-
* Handles a click on the VictoryPoint card button. Will push the victory point card state to the control stack
404+
* Handles a click on the VictoryPoint card button. Currently does nothing because victory point cards don't do anything
409405
* @param coord The place the user clicked
410406
* @return true
411407
*/
412408
bool GameController::handleVictoryPointCardButtonEvent(ScreenCoordinate coord){
413409
if(getState() != BASESTATE){
414-
return true;
410+
return false;
415411
}
416-
pushState(VICTORYPOINT_DEVCARD);
412+
//pushState(VICTORYPOINT_DEVCARD);
417413
return true;
418414
}
419415

@@ -455,13 +451,17 @@ bool GameController::handlePlayerClick(ScreenCoordinate coord, Player& player) {
455451
view.addElement(priority, std::unique_ptr<ViewElement>(new TradingView(initiating, receiving, tradeFunction, cancelFunction, initial)));
456452
std::cout << player.getName() << std::endl;
457453
return true;
454+
455+
//KNIGHT
458456
}else if(getState() == KNIGHT_DEVCARD){
459457
if(hasClickHistory()){
460-
model.getCurrentPlayer().playKnight(getPastClick(0), player);
458+
model.getCurrentPlayer().playKnight(getLastClick(), player);
461459
return handleCancelButtonEvent(coord);
462460
}
461+
462+
//ROBBER
463463
}else if(getState() == ROBBER){
464-
if(hasClickHistory() && (model.canRobberRob(player, getPastClick(0)) || player == model.getCurrentPlayer()) &&
464+
if(hasClickHistory() && (model.canRobberRob(player, getLastClick()) || player == model.getCurrentPlayer()) &&
465465
model.moveRobber(getPastClick(0))){
466466

467467
int resourceToSteal = player.getRandomResource();
@@ -511,6 +511,9 @@ bool GameController::handleTradeOffer(ScreenCoordinate coord, Player& initiating
511511
return true;
512512
}
513513

514+
/**
515+
* Handles clicks on the resource button for Wood
516+
*/
514517
bool GameController::handleWoodButtonEvent(ScreenCoordinate coord){
515518
if(getState() == YEAROFPLENTY_DEVCARD){
516519
model.getCurrentPlayer().playYearOfPlenty(WOOD);
@@ -521,6 +524,10 @@ bool GameController::handleWoodButtonEvent(ScreenCoordinate coord){
521524
}
522525
return false;
523526
}
527+
528+
/**
529+
* Handles clicks on the resource button for Sheep
530+
*/
524531
bool GameController::handleSheepButtonEvent(ScreenCoordinate coord){
525532
if(getState() == YEAROFPLENTY_DEVCARD){
526533
model.getCurrentPlayer().playYearOfPlenty(SHEEP);
@@ -532,6 +539,10 @@ bool GameController::handleSheepButtonEvent(ScreenCoordinate coord){
532539
return false;
533540

534541
}
542+
543+
/**
544+
* Handles clicks on the resource button for Wheat
545+
*/
535546
bool GameController::handleWheatButtonEvent(ScreenCoordinate coord){
536547
if(getState() == YEAROFPLENTY_DEVCARD){
537548
model.getCurrentPlayer().playYearOfPlenty(WHEAT);
@@ -543,6 +554,10 @@ bool GameController::handleWheatButtonEvent(ScreenCoordinate coord){
543554
return false;
544555

545556
}
557+
558+
/**
559+
* Handles clicks on the resource button for Ore
560+
*/
546561
bool GameController::handleOreButtonEvent(ScreenCoordinate coord){
547562
if(getState() == YEAROFPLENTY_DEVCARD){
548563
model.getCurrentPlayer().playYearOfPlenty(STONE);
@@ -554,6 +569,10 @@ bool GameController::handleOreButtonEvent(ScreenCoordinate coord){
554569
return false;
555570

556571
}
572+
573+
/**
574+
* Handles clicks on the resource button for Brick
575+
*/
557576
bool GameController::handleBrickButtonEvent(ScreenCoordinate coord){
558577
if(getState() == YEAROFPLENTY_DEVCARD){
559578
model.getCurrentPlayer().playYearOfPlenty(BRICK);

src/GameView.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ void GameView::drawCardCount(std::string font, int fontSize){
117117
toString(model.getCurrentPlayer().getVictoryCards())); //Victory Point
118118
}
119119

120+
/**
121+
* Draws the count of resources the currentPlayer has
122+
*/
120123
void GameView::drawResourceCount(std::string font, int fontSize){
121124
renderText(font, fontSize, {0.97, 0.35}, {1.0, 0.40},
122125
toString(model.getCurrentPlayer().getWood())); //Wood
@@ -154,6 +157,9 @@ void GameView::render() {
154157
glColor3d(1, 1, 1);
155158
renderText(font, fontSize, {.0, .9}, {.85, 1}, controlStateText);
156159

160+
renderText(font, fontSize, {.78, .82}, {.8, .92}, ">");
161+
renderText(font, fontSize, {.8, .82}, {1., .92}, model.getCurrentPlayer().getName());
162+
157163
drawCardCount(font, fontSize);
158164
drawResourceCount(font, fontSize);
159165

0 commit comments

Comments
 (0)