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:
parent
37b007d79c
commit
bf8ce7e16b
6 changed files with 48 additions and 21 deletions
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ namespace GameDB {
|
|||
using std::shared_ptr, std::string, std::make_shared;
|
||||
|
||||
struct LevelDB {
|
||||
public:
|
||||
std::vector<GameDB::Level> levels;
|
||||
size_t current_level = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ namespace gui {
|
|||
MOUSE_DRAG_START=24,
|
||||
MOUSE_DROP=25,
|
||||
KEY_PRESS=26,
|
||||
AIM_CLICK=27
|
||||
AIM_CLICK=27,
|
||||
COMBAT=28
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ TEST_CASE("boss/systems.cpp works", "[combat-battle]") {
|
|||
animation::init();
|
||||
GameDB::init();
|
||||
cinematic::init();
|
||||
auto host = GameDB::current_level().player;
|
||||
auto host = GameDB::the_player();
|
||||
|
||||
auto fight = System::create_bossfight();
|
||||
auto battle = System::create_battle(fight->$world, fight->$boss_id);
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ int main(int, char*[]) {
|
|||
|
||||
auto main = boss::System::create_bossfight();
|
||||
auto world = GameDB::current_world();
|
||||
dbc::check(main->$world == world, "GameDB::current_world doesn't match boss fight world.");
|
||||
|
||||
while(!main->in_state(boss::State::END)) {
|
||||
main->mouse_pos = window.mapPixelToCoords(router.position);
|
||||
|
|
@ -61,19 +62,9 @@ int main(int, char*[]) {
|
|||
}
|
||||
}
|
||||
|
||||
while(world->has_event<Events::GUI>()) {
|
||||
auto [evt, entity, data] = world->recv<Events::GUI>();
|
||||
|
||||
switch(evt) {
|
||||
case Events::GUI::ATTACK:
|
||||
main->event(gui::Event::ATTACK, data);
|
||||
break;
|
||||
case Events::GUI::COMBAT_START:
|
||||
main->event(gui::Event::START_COMBAT, data);
|
||||
break;
|
||||
default:
|
||||
fmt::println("GUI EVENT: {} entity={}", int(evt), entity);
|
||||
}
|
||||
if(main->$world->has_event<Events::GUI>()) {
|
||||
main->handle_world_events();
|
||||
dbc::check(!main->$world->has_event<Events::GUI>(), "You didn't eat all the events.");
|
||||
}
|
||||
|
||||
main->render(window);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue