1717GameController::GameController (GameBoard& model, GameView& view) : model(model), view(view) {
1818 using namespace std ::placeholders;
1919
20+ view.addElement (makeViewButton (std::bind (&GameController::handleBoardEvent, this , _1), {{0 , 0 }, {1 , 1 }}));
2021
2122 view.addElement (makeViewButtonColor (std::bind (&GameController::nextTurn, this , _1), {{0 , 0.2 }, {0.1 , 0.3 }}, std::make_tuple (0 .f , 0 .f , 1 .f )));
2223 view.addElement (makeViewButtonColor (std::bind (&GameController::handleRoadButtonEvent, this , _1), {{0 , 0 }, {0.1 , 0.1 }}, std::make_tuple (1 .f , 0 .f , 0 .f )));
2324 view.addElement (makeViewButtonColor (std::bind (&GameController::handleSettlementButtonEvent, this , _1), {{0 , 0.1 }, {0.1 , 0.2 }}, std::make_tuple (0 .f , 1 .0f , 0 .f )));
2425
25- view.addElement (makeViewButton (std::bind (&GameController::handleBoardEvent, this , _1), {{0 , 0 }, {1 , 1 }}));
26-
2726 auto font = " resources/TypeWritersSubstitute-Black.ttf" ;
2827 auto fontSize = 50 ;
2928
@@ -41,11 +40,12 @@ GameController::GameController(GameBoard& model, GameView& view) : model(model),
4140
4241 view.addElement (makeViewButtonColor (std::bind (&GameController::handleCancelButtonEvent, this , _1), {{.95 , .95 }, {1.0 , 1.0 }}, std::make_tuple (1 .f , 0 .0f , 0 .f )));
4342
44- view.addElement (makeViewButtonColor (std::bind (&GameController::handleRoadCardButtonEvent, this , _1), {{.2 , 0 }, {.3 , .05 }}, std::make_tuple (1 .f , 0 .0f , 0 .f )));
45- view.addElement (makeViewButtonColor (std::bind (&GameController::handleKnightCardButtonEvent, this , _1), {{0.3 , 0 }, {.4 , .05 }}, std::make_tuple (0 .f , 0 .0f , 0 .f )));
46- view.addElement (makeViewButtonColor (std::bind (&GameController::handleYearOfPlentyCardButtonEvent, this , _1), {{0.4 , 0 }, {.5 , .05 }}, std::make_tuple (1 .f , 1 .0f , 0 .f )));
47- view.addElement (makeViewButtonColor (std::bind (&GameController::handleMonopolyCardButtonEvent, this , _1), {{0.5 , 0 }, {.6 , .05 }}, std::make_tuple (1 .f , 0 .0f , 1 .f )));
48- view.addElement (makeViewButtonColor (std::bind (&GameController::handleVictoryPointCardButtonEvent, this , _1), {{0.6 , 0 }, {.7 , .05 }}, std::make_tuple (0 .f , 1 .0f , 1 .f )));
43+ view.addElement (makeViewButtonText (std::bind (&GameController::handleRoadCardButtonEvent, this , _1), {{0.85 , 0.0 }, {0.97 , 0.05 }}, font, fontSize, " Road Building " ));
44+ view.addElement (makeViewButtonText (std::bind (&GameController::handleKnightCardButtonEvent, this , _1), {{0.85 , 0.05 }, {0.97 , 0.10 }}, font, fontSize, " Knight " ));
45+ view.addElement (makeViewButtonText (std::bind (&GameController::handleYearOfPlentyCardButtonEvent, this , _1), {{0.85 , 0.10 }, {0.97 , 0.15 }}, font, fontSize, " Year of Plenty " ));
46+ view.addElement (makeViewButtonText (std::bind (&GameController::handleMonopolyCardButtonEvent, this , _1), {{0.85 , 0.15 }, {0.97 , 0.20 }}, font, fontSize, " Monopoly " ));
47+ view.addElement (makeViewButtonText (std::bind (&GameController::handleVictoryPointCardButtonEvent, this , _1), {{0.85 , 0.20 }, {0.97 , 0.25 }}, font, fontSize, " Victory Point " ));
48+
4949
5050
5151 stateStack.push_back (BASESTATE);
@@ -157,7 +157,6 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
157157
158158 switch (getState ()){
159159 case BUILDROAD:
160- std::cout << " BUILDROAD\n " ;
161160 if (!hasClickHistory ()) {
162161 storeClick (coord);
163162 } else {
@@ -178,7 +177,8 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
178177 using namespace std ::placeholders;
179178 view.addElement (28 , makeConfirmationDialogue (
180179 std::bind (&GameController::handleConfirmRoadCard, this , _1),
181- std::bind (&GameController::handleCancelDialogueEvent, this , _1), {{.2 , .3 }, {.8 , .6 }}));
180+ std::bind (&GameController::handleCancelDialogueEvent, this , _1), {{.2 , .3 }, {.8 , .6 }},
181+ " Use road building card on these points?" ));
182182 pushState (MODALSTATE);
183183 }
184184 break ;
@@ -209,6 +209,10 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
209209 return true ;
210210}
211211
212+ /* *
213+ * Handles the event when the cancel button in the top right corner of the screen is pressed. This will
214+ * reset the control state back to the base state.
215+ */
212216bool GameController::handleCancelButtonEvent (ScreenCoordinate){
213217 while (getState () != BASESTATE){
214218 popState ();
@@ -235,7 +239,7 @@ bool GameController::handleRoadButtonEvent(ScreenCoordinate coord) {
235239/* *
236240 * Handles a click on the "create settlement" button. Changes the internal state to indicate the user is going to be making roads on the board.
237241 * @param coord The place the user clicked on screen.
238- * @return Whether thi sevent was handled by this element. Always true.
242+ * @return Whether this event was handled by this element. Always true.
239243 */
240244bool GameController::handleSettlementButtonEvent (ScreenCoordinate coord) {
241245 if (getState () != BASESTATE){
@@ -245,6 +249,12 @@ bool GameController::handleSettlementButtonEvent(ScreenCoordinate coord) {
245249 return true ;
246250}
247251
252+
253+ /* *
254+ * Handles a click on the road Building Card button. This changes the control state to indicate the user is going to be building roads on the board.
255+ * @param coord The place the user clicked on the screen
256+ * @return whether this event was handles by this element. Always true.
257+ */
248258bool GameController::handleRoadCardButtonEvent (ScreenCoordinate coord){
249259 if (getState () != BASESTATE){
250260 return true ;
@@ -254,42 +264,73 @@ bool GameController::handleRoadCardButtonEvent(ScreenCoordinate coord){
254264 return true ;
255265}
256266
267+ /* *
268+ * Handles a click on the confirm button in the confirmation dialogues for the Road Building Card. This will attempt to place the roads the
269+ * user chose and clear the control state.
270+ * @param coord The place the user clicked on the screen
271+ * @return true
272+ */
257273bool GameController::handleConfirmRoadCard (ScreenCoordinate coord){
258274 model.getCurrentPlayer ().playRoadBuilding (getPastClick (3 ), getPastClick (2 ), getPastClick (1 ), getPastClick (0 ));
259275 view.removeElement (28 );
260276 return handleCancelButtonEvent (coord);
261277}
262278
279+ /* *
280+ * Handles a click on the cancel button in the confrimation dialogue for the Road Building Card. This will clear the control state back to default.
281+ * @param coord The place the user clicked on the screen
282+ * @return true
283+ */
263284bool GameController::handleCancelDialogueEvent (ScreenCoordinate coord){
264285 view.removeElement (28 );
265286 return handleCancelButtonEvent (coord);
266287}
267288
268-
269- bool GameController::handleKnightCardButtonEvent (ScreenCoordinate){
289+ /* *
290+ * Handles a click on the Knight Card button.
291+ * @param coord The place the user clicked
292+ * @return true
293+ */
294+ bool GameController::handleKnightCardButtonEvent (ScreenCoordinate coord){
270295 if (getState () != BASESTATE){
271296 return true ;
272297 }
273298 pushState (KNIGHT_DEVCARD);
274299 return true ;
275300}
276301
277- bool GameController::handleYearOfPlentyCardButtonEvent (ScreenCoordinate){
302+ /* *
303+ * Handles a click on the Year of Plenty Card button
304+ * @param coord The place the user clicked
305+ * @return true
306+ */
307+ bool GameController::handleYearOfPlentyCardButtonEvent (ScreenCoordinate coord){
278308 if (getState () != BASESTATE){
279309 return true ;
280310 }
281311 pushState (YEAROFPLENTY_DEVCARD);
282312 return true ;
283313}
284- bool GameController::handleMonopolyCardButtonEvent (ScreenCoordinate){
314+
315+ /* *
316+ * Handles a click on the Monopoly Card Button
317+ * @param coord The place the user clicked
318+ * @return true;
319+ */
320+ bool GameController::handleMonopolyCardButtonEvent (ScreenCoordinate coord){
285321 if (getState () != BASESTATE){
286322 return true ;
287323 }
288324 pushState (MONOPOLY_DEVCARD);
289325 return true ;
290326}
291327
292- bool GameController::handleVictoryPointCardButtonEvent (ScreenCoordinate){
328+ /* *
329+ * Handles a click on the VictoryPoint card button. Will push the victory point card state to the control stack
330+ * @param coord The place the user clicked
331+ * @return true
332+ */
333+ bool GameController::handleVictoryPointCardButtonEvent (ScreenCoordinate coord){
293334 if (getState () != BASESTATE){
294335 return true ;
295336 }
0 commit comments