diff --git a/boss/fight.cpp b/boss/fight.cpp index 8110b5d..786adc8 100644 --- a/boss/fight.cpp +++ b/boss/fight.cpp @@ -2,6 +2,7 @@ #include "boss/system.hpp" #include "animation.hpp" #include "game_level.hpp" +#include namespace boss { Fight::Fight(shared_ptr world, Entity boss_id, Entity player_id) : @@ -99,6 +100,40 @@ namespace boss { } } + void Fight::next_combat_dumb_name() { + if(auto action = $battle.next()) { + System::combat(*action, $world, $boss_id, 0); + } else if(player_dead()) { + state(State::END); + } else { + $ui.status(L"PLAYER REQUESTS"); + $battle.ap_refresh(); + $battle.clear_requests(); + state(State::PLAYER_REQUESTS); + } + } + + void Fight::do_combat(std::any data) { + if(data.type() != typeid(Events::Combat)) { + std::cout << "!!!!!! INVALID thing do_combat received: {}" << data.type().name() << std::endl; + return; + } + + auto result = std::any_cast(data); + + if(result.enemy_did > 0) { + // make boss move + fmt::println("!!!! BOSS MOVE!"); + } + + if(result.player_did > 0) { + // make player move + fmt::println("!!!! PLAYER MOVE!"); + + } + + } + void Fight::EXEC_PLAN(gui::Event ev, std::any data) { using enum gui::Event; @@ -107,26 +142,13 @@ namespace boss { case BOSS_START: state(State::END); break; - case TICK: + case START_COMBAT: + next_combat_dumb_name(); + break; case COMBAT: - if(auto action = $battle.next()) { - fmt::println("COMBAT!"); - System::combat(*action, $world, $boss_id, 0); - run_systems(); - } else { - fmt::println("NO MORE BATTLE ACTIONS!"); - } - - if(player_dead()) { - $ui.status(L"YOU DIED"); - state(State::END); - } else { - $ui.status(L"PLAYER REQUESTS"); - $battle.ap_refresh(); - $battle.clear_requests(); - state(State::PLAYER_REQUESTS); - } - break; // ignore tick + do_combat(data); + next_combat_dumb_name(); + break; default: break; } @@ -199,11 +221,11 @@ namespace boss { event(gui::Event::ATTACK, data); break; case Events::GUI::COMBAT_START: - fmt::println("sending combat start"); + fmt::println("sending combat start {}", data.type().name()); event(gui::Event::START_COMBAT, data); break; case Events::GUI::COMBAT: - fmt::println("sending combat"); + fmt::println("sending combat {}", data.type().name()); event(gui::Event::COMBAT, data); break; default: diff --git a/boss/fight.hpp b/boss/fight.hpp index 0785c55..fa493ba 100644 --- a/boss/fight.hpp +++ b/boss/fight.hpp @@ -46,5 +46,8 @@ namespace boss { void run_systems(); bool player_dead(); void init_fight(); + + void do_combat(std::any data); + void next_combat_dumb_name(); }; } diff --git a/boss/ui.cpp b/boss/ui.cpp index e75e9e8..f8b860f 100644 --- a/boss/ui.cpp +++ b/boss/ui.cpp @@ -68,23 +68,6 @@ namespace boss { boss_combat.hp, boss_combat.max_hp, boss_combat.ap, boss_combat.max_ap); - if($world->has_event()) { - auto [evt, entity, data] = $world->recv(); - auto result = std::any_cast(data); - - if(result.player_did > 0) { - status += L"\nYOU HIT!"; - } else { - status += L"\nYOU MISSED!"; - } - - if(result.enemy_did > 0) { - status += L"\nBOSS HIT!"; - } else { - status += L"\nBOSS MISSED!"; - } - } - $actions.show_text("stats", status); }