Skip to content

Commit

Permalink
fix: Game: added new gamestatus_t flag
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
tcoyvwac committed Oct 13, 2019
1 parent 0cddb3b commit d798895
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
Expand All @@ -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 =
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit d798895

Please sign in to comment.