Fixed some things but now the world and boss fight worlds are out of sync and need to be fixed. tools/arena is broken.

This commit is contained in:
Zed A. Shaw 2025-12-13 13:13:59 -05:00
parent 37b007d79c
commit bf8ce7e16b
6 changed files with 48 additions and 21 deletions

View file

@ -1,6 +1,7 @@
#include "boss/fight.hpp"
#include "boss/system.hpp"
#include "animation.hpp"
#include "game_level.hpp"
namespace boss {
Fight::Fight(shared_ptr<World> world, Entity boss_id, Entity player_id) :
@ -87,10 +88,6 @@ namespace boss {
break;
case START_COMBAT:
$ui.status(L"EXEC PLAN");
while(auto action = $battle.next()) {
System::combat(*action, $world, $boss_id, 0);
run_systems();
}
state(State::EXEC_PLAN);
break;
case TICK:
@ -109,6 +106,15 @@ namespace boss {
state(State::END);
break;
case TICK:
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);
@ -132,7 +138,7 @@ namespace boss {
$ui.update_stats();
$battle.set($host, "tough_personality", false);
$battle.set($host, "have_healing", false);
$battle.set($host, "health_good", $host_combat.hp > 20);
$battle.set($host, "health_good", $host_combat.hp > 100);
}
void Fight::render(sf::RenderWindow& window) {
@ -176,4 +182,33 @@ namespace boss {
System::initialize_actor_ai(*$world, $boss_id);
run_systems();
}
void Fight::handle_world_events() {
fmt::println(">>>>>>>>>>>>>>>>> BOSS FIGHT EVENTS");
dbc::check($world->has_event<Events::GUI>(), "World doesn't have GUI events.");
while($world->has_event<Events::GUI>()) {
auto [evt, entity, data] = $world->recv<Events::GUI>();
fmt::println("boss fight received event", int(evt));
switch(evt) {
case Events::GUI::ATTACK:
fmt::println("sending attack");
event(gui::Event::ATTACK, data);
break;
case Events::GUI::COMBAT_START:
fmt::println("sending combat start");
event(gui::Event::START_COMBAT, data);
break;
case Events::GUI::COMBAT:
fmt::println("sending combat");
event(gui::Event::COMBAT, data);
break;
default:
fmt::println("GUI EVENT: {} entity={}", int(evt), entity);
}
}
dbc::check(!$world->has_event<Events::GUI>(), "World still has events!");
fmt::println("<<<<<<<<<<<<<<<< BOSS FIGHT EVENTS");
}
}

View file

@ -42,6 +42,7 @@ namespace boss {
void END(gui::Event ev, std::any data);
void render(sf::RenderWindow& window);
void handle_world_events();
void run_systems();
bool player_dead();
void init_fight();