@@ -41,11 +41,12 @@ GameController::GameController(GameBoard& model, GameView& view) : model(model),
4141
4242 view.addElement (makeViewButtonColor (std::bind (&GameController::handleCancelButtonEvent, this , _1), {{.95 , .95 }, {1.0 , 1.0 }}, std::make_tuple (1 .f , 0 .0f , 0 .f )));
4343
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 )));
44+ view.addElement (makeViewButtonText (std::bind (&GameController::handleRoadCardButtonEvent, this , _1), {{0.85 , 0.0 }, {0.97 , 0.05 }}, font, fontSize, " Road Building " ));
45+ view.addElement (makeViewButtonText (std::bind (&GameController::handleKnightCardButtonEvent, this , _1), {{0.85 , 0.05 }, {0.97 , 0.10 }}, font, fontSize, " Knight " ));
46+ view.addElement (makeViewButtonText (std::bind (&GameController::handleYearOfPlentyCardButtonEvent, this , _1), {{0.85 , 0.10 }, {0.97 , 0.15 }}, font, fontSize, " Year of Plenty " ));
47+ view.addElement (makeViewButtonText (std::bind (&GameController::handleMonopolyCardButtonEvent, this , _1), {{0.85 , 0.15 }, {0.97 , 0.20 }}, font, fontSize, " Monopoly " ));
48+ view.addElement (makeViewButtonText (std::bind (&GameController::handleVictoryPointCardButtonEvent, this , _1), {{0.85 , 0.20 }, {0.97 , 0.25 }}, font, fontSize, " Victory Point " ));
49+
4950
5051
5152 stateStack.push_back (BASESTATE);
@@ -178,7 +179,8 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
178179 using namespace std ::placeholders;
179180 view.addElement (28 , makeConfirmationDialogue (
180181 std::bind (&GameController::handleConfirmRoadCard, this , _1),
181- std::bind (&GameController::handleCancelDialogueEvent, this , _1), {{.2 , .3 }, {.8 , .6 }}));
182+ std::bind (&GameController::handleCancelDialogueEvent, this , _1), {{.2 , .3 }, {.8 , .6 }},
183+ " Use road building card on these points?" ));
182184 pushState (MODALSTATE);
183185 }
184186 break ;
@@ -209,6 +211,10 @@ bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
209211 return true ;
210212}
211213
214+ /* *
215+ * Handles the event when the cancel button in the top right corner of the screen is pressed. This will
216+ * reset the control state back to the base state.
217+ */
212218bool GameController::handleCancelButtonEvent (ScreenCoordinate){
213219 while (getState () != BASESTATE){
214220 popState ();
@@ -235,7 +241,7 @@ bool GameController::handleRoadButtonEvent(ScreenCoordinate coord) {
235241/* *
236242 * 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.
237243 * @param coord The place the user clicked on screen.
238- * @return Whether thi sevent was handled by this element. Always true.
244+ * @return Whether this event was handled by this element. Always true.
239245 */
240246bool GameController::handleSettlementButtonEvent (ScreenCoordinate coord) {
241247 if (getState () != BASESTATE){
@@ -245,6 +251,12 @@ bool GameController::handleSettlementButtonEvent(ScreenCoordinate coord) {
245251 return true ;
246252}
247253
254+
255+ /* *
256+ * 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.
257+ * @param coord The place the user clicked on the screen
258+ * @return whether this event was handles by this element. Always true.
259+ */
248260bool GameController::handleRoadCardButtonEvent (ScreenCoordinate coord){
249261 if (getState () != BASESTATE){
250262 return true ;
@@ -254,42 +266,73 @@ bool GameController::handleRoadCardButtonEvent(ScreenCoordinate coord){
254266 return true ;
255267}
256268
269+ /* *
270+ * Handles a click on the confirm button in the confirmation dialogues for the Road Building Card. This will attempt to place the roads the
271+ * user chose and clear the control state.
272+ * @param coord The place the user clicked on the screen
273+ * @return true
274+ */
257275bool GameController::handleConfirmRoadCard (ScreenCoordinate coord){
258276 model.getCurrentPlayer ().playRoadBuilding (getPastClick (3 ), getPastClick (2 ), getPastClick (1 ), getPastClick (0 ));
259277 view.removeElement (28 );
260278 return handleCancelButtonEvent (coord);
261279}
262280
281+ /* *
282+ * 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.
283+ * @param coord The place the user clicked on the screen
284+ * @return true
285+ */
263286bool GameController::handleCancelDialogueEvent (ScreenCoordinate coord){
264287 view.removeElement (28 );
265288 return handleCancelButtonEvent (coord);
266289}
267290
268-
269- bool GameController::handleKnightCardButtonEvent (ScreenCoordinate){
291+ /* *
292+ * Handles a click on the Knight Card button.
293+ * @param coord The place the user clicked
294+ * @return true
295+ */
296+ bool GameController::handleKnightCardButtonEvent (ScreenCoordinate coord){
270297 if (getState () != BASESTATE){
271298 return true ;
272299 }
273300 pushState (KNIGHT_DEVCARD);
274301 return true ;
275302}
276303
277- bool GameController::handleYearOfPlentyCardButtonEvent (ScreenCoordinate){
304+ /* *
305+ * Handles a click on the Year of Plenty Card button
306+ * @param coord The place the user clicked
307+ * @return true
308+ */
309+ bool GameController::handleYearOfPlentyCardButtonEvent (ScreenCoordinate coord){
278310 if (getState () != BASESTATE){
279311 return true ;
280312 }
281313 pushState (YEAROFPLENTY_DEVCARD);
282314 return true ;
283315}
284- bool GameController::handleMonopolyCardButtonEvent (ScreenCoordinate){
316+
317+ /* *
318+ * Handles a click on the Monopoly Card Button
319+ * @param coord The place the user clicked
320+ * @return true;
321+ */
322+ bool GameController::handleMonopolyCardButtonEvent (ScreenCoordinate coord){
285323 if (getState () != BASESTATE){
286324 return true ;
287325 }
288326 pushState (MONOPOLY_DEVCARD);
289327 return true ;
290328}
291329
292- bool GameController::handleVictoryPointCardButtonEvent (ScreenCoordinate){
330+ /* *
331+ * Handles a click on the VictoryPoint card button. Will push the victory point card state to the control stack
332+ * @param coord The place the user clicked
333+ * @return true
334+ */
335+ bool GameController::handleVictoryPointCardButtonEvent (ScreenCoordinate coord){
293336 if (getState () != BASESTATE){
294337 return true ;
295338 }
0 commit comments