From 5b18849ddcf9d5094fc2e01c7d79ac30403db462 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sat, 10 Aug 2024 15:09:54 -0400 Subject: [PATCH] Just a little cleanup before getting serious again. --- escape_turings_tarpit.cpp | 14 ++++++++++++-- game_engine.cpp | 6 ------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/escape_turings_tarpit.cpp b/escape_turings_tarpit.cpp index 64241e4..f50f4ca 100644 --- a/escape_turings_tarpit.cpp +++ b/escape_turings_tarpit.cpp @@ -17,6 +17,8 @@ using namespace std; using namespace fmt; namespace fs = std::filesystem; +const auto ERROR = fmt::emphasis::bold | fg(fmt::color::red); + #define BUF_MAX 1024 class UpdateListener : public efsw::FileWatchListener { @@ -47,9 +49,11 @@ class UpdateListener : public efsw::FileWatchListener { dbc::check(rc == 0, "git ignored failed."); if(!ignored) { - println("filename={}, ignored={}", full_path.c_str(), ignored); + println("\nCHANGE: filename={} .gitignored?={}", full_path.c_str(), ignored); changes = changes || !ignored; + } else { + print("."); } } @@ -69,6 +73,7 @@ void run_build(GameEngine &game, const char* command) { dbc::check(stats_out.good(), "Error opening stats.csv file."); dbc::pre("simple test", [&]() { return stats_out.good(); }); + // need to catch the error message when the command is bad FILE *build_out = popen(command, "r"); dbc::check(build_out != nullptr, "Failed to run command."); @@ -90,9 +95,14 @@ void run_build(GameEngine &game, const char* command) { lnumber, col, type, message); stats_out << result; - println("{} @ {}:{}:{} {}", type, file_name, lnumber, col, message); + print(ERROR, "\nHIT WITH {} @ {}:{}:{} {}", type, file_name, lnumber, col, message); game.hit(type); + + // refactor this + if(game.is_dead()) { + print(ERROR, "YOU DIED!\n"); + } } } diff --git a/game_engine.cpp b/game_engine.cpp index 3c38f6e..3cc706f 100644 --- a/game_engine.cpp +++ b/game_engine.cpp @@ -116,12 +116,6 @@ bool GameEngine::hit(string &type) { int damage = determine_damage(type); hit_points -= damage; - if(is_dead()) { - print(ERROR, "YOU DIED!\n"); - } else { - println("DAMAGE {}, HP: {}", damage, hit_points); - } - // super dumb but I'll clean it up later return is_dead(); }