Just a little cleanup before getting serious again.

master
Zed A. Shaw 2 months ago
parent 52b59d38ad
commit 5b18849ddc
  1. 14
      escape_turings_tarpit.cpp
  2. 6
      game_engine.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");
}
}
}

@ -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();
}

Loading…
Cancel
Save