Skip to content

Commit 59dc8b8

Browse files
committed
Polished some game stuff to get it to work better. Trading does not
work, I don't know what to do!
1 parent 7dd129b commit 59dc8b8

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

src/GameController.cpp

Lines changed: 33 additions & 13 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);
@@ -209,13 +209,10 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
209209
}
210210
break;
211211
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);
212+
if(!hasClickHistory()){
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+
}
219216
break;
220217
case BUILDSETTLEMENT:
221218
std::cout << "attempting to buy a settlement" << std::endl;
@@ -405,15 +402,15 @@ bool GameController::handleMonopolyCardButtonEvent(ScreenCoordinate coord){
405402
}
406403

407404
/**
408-
* Handles a click on the VictoryPoint card button. Will push the victory point card state to the control stack
405+
* Handles a click on the VictoryPoint card button. Currently does nothing because victory point cards don't do anything
409406
* @param coord The place the user clicked
410407
* @return true
411408
*/
412409
bool GameController::handleVictoryPointCardButtonEvent(ScreenCoordinate coord){
413410
if(getState() != BASESTATE){
414-
return true;
411+
return false;
415412
}
416-
pushState(VICTORYPOINT_DEVCARD);
413+
//pushState(VICTORYPOINT_DEVCARD);
417414
return true;
418415
}
419416

@@ -455,13 +452,17 @@ bool GameController::handlePlayerClick(ScreenCoordinate coord, Player& player) {
455452
view.addElement(priority, std::unique_ptr<ViewElement>(new TradingView(initiating, receiving, tradeFunction, cancelFunction, initial)));
456453
std::cout << player.getName() << std::endl;
457454
return true;
455+
456+
//KNIGHT
458457
}else if(getState() == KNIGHT_DEVCARD){
459458
if(hasClickHistory()){
460-
model.getCurrentPlayer().playKnight(getPastClick(0), player);
459+
model.getCurrentPlayer().playKnight(getLastClick(), player);
461460
return handleCancelButtonEvent(coord);
462461
}
462+
463+
//ROBBER
463464
}else if(getState() == ROBBER){
464-
if(hasClickHistory() && (model.canRobberRob(player, getPastClick(0)) || player == model.getCurrentPlayer()) &&
465+
if(hasClickHistory() && (model.canRobberRob(player, getLastClick()) || player == model.getCurrentPlayer()) &&
465466
model.moveRobber(getPastClick(0))){
466467

467468
int resourceToSteal = player.getRandomResource();
@@ -511,6 +512,9 @@ bool GameController::handleTradeOffer(ScreenCoordinate coord, Player& initiating
511512
return true;
512513
}
513514

515+
/**
516+
* Handles clicks on the resource button for Wood
517+
*/
514518
bool GameController::handleWoodButtonEvent(ScreenCoordinate coord){
515519
if(getState() == YEAROFPLENTY_DEVCARD){
516520
model.getCurrentPlayer().playYearOfPlenty(WOOD);
@@ -521,6 +525,10 @@ bool GameController::handleWoodButtonEvent(ScreenCoordinate coord){
521525
}
522526
return false;
523527
}
528+
529+
/**
530+
* Handles clicks on the resource button for Sheep
531+
*/
524532
bool GameController::handleSheepButtonEvent(ScreenCoordinate coord){
525533
if(getState() == YEAROFPLENTY_DEVCARD){
526534
model.getCurrentPlayer().playYearOfPlenty(SHEEP);
@@ -532,6 +540,10 @@ bool GameController::handleSheepButtonEvent(ScreenCoordinate coord){
532540
return false;
533541

534542
}
543+
544+
/**
545+
* Handles clicks on the resource button for Wheat
546+
*/
535547
bool GameController::handleWheatButtonEvent(ScreenCoordinate coord){
536548
if(getState() == YEAROFPLENTY_DEVCARD){
537549
model.getCurrentPlayer().playYearOfPlenty(WHEAT);
@@ -543,6 +555,10 @@ bool GameController::handleWheatButtonEvent(ScreenCoordinate coord){
543555
return false;
544556

545557
}
558+
559+
/**
560+
* Handles clicks on the resource button for Ore
561+
*/
546562
bool GameController::handleOreButtonEvent(ScreenCoordinate coord){
547563
if(getState() == YEAROFPLENTY_DEVCARD){
548564
model.getCurrentPlayer().playYearOfPlenty(STONE);
@@ -554,6 +570,10 @@ bool GameController::handleOreButtonEvent(ScreenCoordinate coord){
554570
return false;
555571

556572
}
573+
574+
/**
575+
* Handles clicks on the resource button for Brick
576+
*/
557577
bool GameController::handleBrickButtonEvent(ScreenCoordinate coord){
558578
if(getState() == YEAROFPLENTY_DEVCARD){
559579
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)