From d798895702fddfc6b99374ea3b46a979737960a9 Mon Sep 17 00:00:00 2001 From: tcoyvwac <53616399+tcoyvwac@users.noreply.github.com> Date: Sun, 13 Oct 2019 07:06:08 +0200 Subject: [PATCH] fix: Game: added new gamestatus_t flag - FLAG_GAME_IS_ASKING_QUESTION_MODE added to gamestatus_t. - DisplayGameQuestionsToPlayerPrompt() created to hold all text prompt for questions to player. Only active when FLAG_GAME_IS_ASKING_QUESTION_MODE is active. --- src/game.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 27129f6a..737ea76c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -25,6 +25,7 @@ enum GameStatusFlag { FLAG_SAVED_GAME, FLAG_INPUT_ERROR, FLAG_ENDLESS_MODE, + FLAG_GAME_IS_ASKING_QUESTION_MODE, FLAG_QUESTION_STAY_OR_QUIT, MAX_NO_GAME_STATUS_FLAGS }; @@ -63,6 +64,7 @@ gamestatus_t process_gamelogic(gamestatus_t gamestatus) { if (!gamestatus[FLAG_ENDLESS_MODE]) { if (hasWonOnGameboard(gamePlayBoard)) { gamestatus[FLAG_WIN] = true; + gamestatus[FLAG_GAME_IS_ASKING_QUESTION_MODE] = true; gamestatus[FLAG_QUESTION_STAY_OR_QUIT] = true; } } @@ -92,6 +94,15 @@ make_input_controls_display_data(gamestatus_t gamestatus) { return icdd; }; +std::string DisplayGameQuestionsToPlayerPrompt(gamestatus_t gamestatus) { + using namespace Graphics; + + std::ostringstream str_os; + DrawOnlyWhen(str_os, gamestatus[FLAG_QUESTION_STAY_OR_QUIT], + QuestionEndOfWinningGamePrompt); + return str_os.str(); +} + gamestatus_t drawGraphics(std::ostream &os, gamestatus_t gamestatus) { // Graphical Output has a specific ordering... using namespace Graphics; @@ -114,8 +125,8 @@ gamestatus_t drawGraphics(std::ostream &os, gamestatus_t gamestatus) { DrawAsOneTimeFlag(os, gamestatus[FLAG_SAVED_GAME], GameStateNowSavedPrompt); // 6. Draw any "questions to the player" (from the game) text output - DrawOnlyWhen(os, gamestatus[FLAG_QUESTION_STAY_OR_QUIT], - QuestionEndOfWinningGamePrompt); + DrawOnlyWhen(os, gamestatus[FLAG_GAME_IS_ASKING_QUESTION_MODE], + DataSuppliment(gamestatus, DisplayGameQuestionsToPlayerPrompt)); // 7. Draw Keyboard / Input Keycodes to the player const auto input_controls_display_data = @@ -262,6 +273,9 @@ wrapper_bool_gamestatus_t process_gameStatus(gamestatus_t gamestatus) { if (gamestatus[FLAG_SAVED_GAME]) { saveGamePlayState(); } + + // New loop cycle: reset question asking event trigger + gamestatus[FLAG_GAME_IS_ASKING_QUESTION_MODE] = false; return std::make_tuple(loop_again, gamestatus); }