A bit of restructuring and some color output for fun.

master
Zed A. Shaw 2 months ago
parent 5c1b6d9243
commit 00597c0aaa
  1. 32
      watchgit.cpp

@ -1,38 +1,49 @@
#include <iostream>
#include <iomanip>
#include <fstream>
#include <fmt/core.h>
#include <fmt/color.h>
#include <fmt/chrono.h>
#include <regex>
#include <string>
#include <iterator>
#include <ctime>
#include "dbc.h"
#include <unistd.h>
#include <stdio.h>
#include <git2.h>
#include <efsw/efsw.hpp>
#include <regex>
#include <set>
#include <filesystem>
#include <map>
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 GameEngine {
int hit_points = 0;
map<string, int> damage_types{
{"error", 4}, {"warning", 1}};
public:
GameEngine(int hp) : hit_points(hp) {};
bool hit(unsigned int damage) {
int determine_damage(string &type) {
try {
return damage_types.at(type);
} catch(std::out_of_range &err) {
print(ERROR, "BAD DAMAGE TYPE {}\n", type);
return 1000;
}
}
bool hit(string &type) {
int damage = determine_damage(type);
hit_points -= damage;
if(is_dead()) {
println("YOU DIED!");
print(ERROR, "YOU DIED!\n");
} else {
println("DAMAGE {}, HP: {}", damage, hit_points);
}
@ -121,12 +132,7 @@ void run_build(GameEngine &game, const char* command) {
stats_out << result;
println("{} @ {}:{}:{} {}", type, file_name, lnumber, col, message);
if(type == "error") {
game.hit(4);
} else {
game.hit(1);
}
game.hit(type);
}
}

Loading…
Cancel
Save