@@ -121,7 +121,7 @@ GameController::GameController(GameBoard& model, GameView& view) : model(model),
121121 std::bind (&GameController::handleBoardEvent, this , _1),
122122 getGraphicsConfig ()[" screen.board.area" ]));
123123
124- stateStack. push_back ( BASESTATE) ;
124+ state = BASESTATE;
125125}
126126
127127/* *
@@ -135,28 +135,26 @@ GameController::~GameController() {
135135 * Pushes the given state onto the control stack
136136 */
137137void GameController::pushState (ControlState newState){
138- if (newState != BASESTATE){
139- stateStack. push_back (newState );
138+ if (state != BASESTATE) {
139+ throw std::runtime_error ( " oh no! i misunderstood how this function works " );
140140 }
141+ state = newState;
141142}
142143
143144/* *
144145 * Pops the latest state from the control stack
145146 */
146147ControlState GameController::popState (){
147148 ControlState currState = getState ();
148- if (currState == BASESTATE){
149- return currState;
150- }
151- stateStack.pop_back ();
149+ state = BASESTATE;
152150 return currState;
153151}
154152
155153/* *
156154 * returns the current state of the controller
157155 */
158156ControlState GameController::getState (){
159- return stateStack. back () ;
157+ return state ;
160158}
161159
162160/* *
@@ -259,14 +257,15 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
259257
260258 break ;
261259 case BUILDROAD_DEVCARD:
262- storeClick (coord);
260+ if (getClickHistorySize () <= 4 ) {
261+ storeClick (coord);
262+ }
263263 if (getClickHistorySize () >= 4 ){
264264 using namespace std ::placeholders;
265265 view.addElement (28 , makeConfirmationDialogue (
266266 std::bind (&GameController::handleConfirmRoadCard, this , _1),
267267 std::bind (&GameController::handleCancelDialogueEvent, this , _1), {{.2 , .3 }, {.8 , .6 }},
268268 " Use road building card on these points?" ));
269- pushState (MODALSTATE);
270269 }
271270 break ;
272271 case KNIGHT_DEVCARD:
0 commit comments