diff --git a/assets/config.json b/assets/config.json index 484c2f7..c63d676 100644 --- a/assets/config.json +++ b/assets/config.json @@ -1,8 +1,8 @@ { "sounds": { "you_died": "./assets/you_died.mp3", - "build_success": "./assets/build_success.mp3", - "build_failed": "./assets/build_failed.mp3", + "build_success": "./assets/nothing.mp3", + "build_failed": "./assets/nothing.mp3", "building": "./mysounds/building.mp3" }, "sprites": { diff --git a/builder.cpp b/builder.cpp index cce481a..e68faab 100644 --- a/builder.cpp +++ b/builder.cpp @@ -93,9 +93,16 @@ void Builder::BUILDING(BuildEvent) { auto m = parse_line(line); if(m.match) { - fmt::println("HIT WITH {} @ {}:{}:{} {}", m.type, m.file_name, m.lnumber, m.col, m.message); + std::string hit_line = fmt::format("{} @ {}:{}:{}", + m.type, m.file_name, m.lnumber, m.col); + + fmt::println("HIT WITH {} {}", hit_line, m.message); + + if(!$hit_line_stats.contains(hit_line)) { + $hit_line_stats.insert_or_assign(hit_line, 1); + game.event(GameEvent::HIT, m.type); + } - game.event(GameEvent::HIT, m.type); gui.update_status(game, line.size(), true); } else { gui.update_status(game, line.size(), false); @@ -180,6 +187,8 @@ void Builder::DONE(BuildEvent) { gui.you_died(); } + $hit_line_stats.clear(); + game.event(GameEvent::BUILD_DONE); listener->reset_state(); gui.output("^^^^^^^^^^^ END ^^^^^^^^^^^"); diff --git a/builder.hpp b/builder.hpp index 6c53bc7..a63db54 100644 --- a/builder.hpp +++ b/builder.hpp @@ -29,7 +29,6 @@ enum BuildEvent { }; class Builder : DeadSimpleFSM { - // FOUND BUG: this was interesting, it got copied but the gui kept working until the refactor GUI &gui; GameEngine &game; string git_path = "NOT SET"; @@ -44,6 +43,7 @@ class Builder : DeadSimpleFSM { std::future read_fut; std::mutex fsm_mutex; git_repository* repo = nullptr; + std::unordered_map $hit_line_stats; public: diff --git a/gui.cpp b/gui.cpp index 7e5e3bd..6dcc57e 100644 --- a/gui.cpp +++ b/gui.cpp @@ -16,8 +16,9 @@ using std::string, std::vector; -GUI::GUI(int timer_seconds) : +GUI::GUI(int timer_seconds, const std::wstring &g) : $timer_seconds(timer_seconds), + $goal(g), $window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Turing's Tarpit") { using namespace guecs; @@ -26,11 +27,11 @@ GUI::GUI(int timer_seconds) : $gui.position(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); $gui.layout( - "[*%(200,300)face|_|*%(100,300)status|*%(200,500)log|_]" + "[*%(200,500)log|_|*%(100,300)status|*%(200,300)face|_]" "[_|_|_|_|_]" "[_|_|_|_|_]" - "[*%(300,200)clock|_|_|_|_]" - "[_|_|_|_|_]" + "[_|_|*%(300,100)goal|_|_]" + "[_|_|*%(300,100)clock|_|_]" "[hp_bar]"); $gui.world().set_the({$gui.$parser, {0,0,0,0}}); @@ -52,7 +53,15 @@ GUI::GUI(int timer_seconds) : $gui.set($log, {(float)$timer_seconds, "build_status"}); auto clock = $gui.entity("clock"); - $gui.set