Skip to content

Commit

Permalink
fix: Gameboard-Graphics: drawGameBoard renamed; wrapped in new namespace
Browse files Browse the repository at this point in the history
- drawGameBoard() now renamed to GameBoardTextOutput().
- GameBoardTextOutput() wrapped in Gameboard::Graphics namespace.
  • Loading branch information
tcoyvwac committed Oct 12, 2019
1 parent 065106d commit 32894a4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
23 changes: 13 additions & 10 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,21 @@ make_input_controls_display_data(gamestatus_t gamestatus) {
};

gamestatus_t drawGraphics(std::ostream &os, gamestatus_t gamestatus) {
using namespace Graphics;
using namespace Gameboard::Graphics;
const auto scdd = make_scoreboard_display_data();
clearScreen();
DrawAlways(os, DataSuppliment(scdd, Graphics::GameScoreBoardOverlay));
DrawAlways(os, DataSuppliment(gamePlayBoard, drawGameBoard));
DrawAsOneTimeFlag(os, gamestatus[FLAG_SAVED_GAME],
Graphics::GameStateNowSavedPrompt);
DrawAlways(os, DataSuppliment(scdd, GameScoreBoardOverlay));
DrawAlways(os, DataSuppliment(gamePlayBoard, GameBoardTextOutput));
DrawAsOneTimeFlag(os, gamestatus[FLAG_SAVED_GAME], GameStateNowSavedPrompt);
DrawOnlyWhen(os, gamestatus[FLAG_QUESTION_STAY_OR_QUIT],
Graphics::QuestionEndOfWinningGamePrompt);
QuestionEndOfWinningGamePrompt);
const auto input_controls_display_data =
make_input_controls_display_data(gamestatus);
DrawAlways(os, DataSuppliment(input_controls_display_data,
Graphics::GameInputControlsOverlay));
GameInputControlsOverlay));
DrawAsOneTimeFlag(os, gamestatus[FLAG_INPUT_ERROR],
Graphics::InvalidInputGameBoardErrorPrompt);
InvalidInputGameBoardErrorPrompt);
return gamestatus;
}

Expand Down Expand Up @@ -264,6 +265,8 @@ make_end_screen_display_data(gamestatus_t world_gamestatus) {
};

void endlessGameLoop() {
using namespace Graphics;
using namespace Gameboard::Graphics;
auto loop_again{true};
gamestatus_t world_gamestatus{};

Expand All @@ -273,10 +276,10 @@ void endlessGameLoop() {

const auto scdd = make_scoreboard_display_data();
clearScreen();
DrawAlways(std::cout, DataSuppliment(scdd, Graphics::GameScoreBoardOverlay));
DrawAlways(std::cout, DataSuppliment(gamePlayBoard, drawGameBoard));
DrawAlways(std::cout, DataSuppliment(scdd, GameScoreBoardOverlay));
DrawAlways(std::cout, DataSuppliment(gamePlayBoard, GameBoardTextOutput));
const auto esdd = make_end_screen_display_data(world_gamestatus);
DrawAlways(std::cout, DataSuppliment(esdd, Graphics::GameEndScreenOverlay));
DrawAlways(std::cout, DataSuppliment(esdd, GameEndScreenOverlay));
}

void saveEndGameStats(Scoreboard::Score finalscore) {
Expand Down
7 changes: 5 additions & 2 deletions src/gameboard-graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <sstream>

namespace Game {
namespace Gameboard {
namespace Graphics {
namespace {

template<size_t num_of_bars>
Expand Down Expand Up @@ -66,8 +68,9 @@ std::string drawSelf(GameBoard::gameboard_data_array_t gbda) {

} // namespace

std::string drawGameBoard(GameBoard gb) {
std::string GameBoardTextOutput(GameBoard gb) {
return drawSelf(gb.gbda);
}

} // namespace Graphics
} // namespace Gameboard
} // namespace Game
7 changes: 6 additions & 1 deletion src/headers/gameboard-graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

namespace Game {
struct GameBoard;
std::string drawGameBoard(GameBoard gb);
namespace Gameboard {
namespace Graphics {
std::string GameBoardTextOutput(GameBoard gb);

}
} // namespace Gameboard
} // namespace Game

#endif

0 comments on commit 32894a4

Please sign in to comment.