Boss fight working better now, but I need to fix the events.
This commit is contained in:
parent
fe76196f83
commit
6c34fea64a
3 changed files with 46 additions and 38 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "boss/system.hpp"
|
||||
#include "animation.hpp"
|
||||
#include "game_level.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace boss {
|
||||
Fight::Fight(shared_ptr<World> 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<Events::Combat>(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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue