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 "boss/system.hpp"
|
||||||
#include "animation.hpp"
|
#include "animation.hpp"
|
||||||
#include "game_level.hpp"
|
#include "game_level.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace boss {
|
namespace boss {
|
||||||
Fight::Fight(shared_ptr<World> world, Entity boss_id, Entity player_id) :
|
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) {
|
void Fight::EXEC_PLAN(gui::Event ev, std::any data) {
|
||||||
using enum gui::Event;
|
using enum gui::Event;
|
||||||
|
|
||||||
|
|
@ -107,26 +142,13 @@ namespace boss {
|
||||||
case BOSS_START:
|
case BOSS_START:
|
||||||
state(State::END);
|
state(State::END);
|
||||||
break;
|
break;
|
||||||
case TICK:
|
case START_COMBAT:
|
||||||
|
next_combat_dumb_name();
|
||||||
|
break;
|
||||||
case COMBAT:
|
case COMBAT:
|
||||||
if(auto action = $battle.next()) {
|
do_combat(data);
|
||||||
fmt::println("COMBAT!");
|
next_combat_dumb_name();
|
||||||
System::combat(*action, $world, $boss_id, 0);
|
break;
|
||||||
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
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -199,11 +221,11 @@ namespace boss {
|
||||||
event(gui::Event::ATTACK, data);
|
event(gui::Event::ATTACK, data);
|
||||||
break;
|
break;
|
||||||
case Events::GUI::COMBAT_START:
|
case Events::GUI::COMBAT_START:
|
||||||
fmt::println("sending combat start");
|
fmt::println("sending combat start {}", data.type().name());
|
||||||
event(gui::Event::START_COMBAT, data);
|
event(gui::Event::START_COMBAT, data);
|
||||||
break;
|
break;
|
||||||
case Events::GUI::COMBAT:
|
case Events::GUI::COMBAT:
|
||||||
fmt::println("sending combat");
|
fmt::println("sending combat {}", data.type().name());
|
||||||
event(gui::Event::COMBAT, data);
|
event(gui::Event::COMBAT, data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -46,5 +46,8 @@ namespace boss {
|
||||||
void run_systems();
|
void run_systems();
|
||||||
bool player_dead();
|
bool player_dead();
|
||||||
void init_fight();
|
void init_fight();
|
||||||
|
|
||||||
|
void do_combat(std::any data);
|
||||||
|
void next_combat_dumb_name();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
17
boss/ui.cpp
17
boss/ui.cpp
|
|
@ -68,23 +68,6 @@ namespace boss {
|
||||||
boss_combat.hp, boss_combat.max_hp,
|
boss_combat.hp, boss_combat.max_hp,
|
||||||
boss_combat.ap, boss_combat.max_ap);
|
boss_combat.ap, boss_combat.max_ap);
|
||||||
|
|
||||||
if($world->has_event<Events::GUI>()) {
|
|
||||||
auto [evt, entity, data] = $world->recv<Events::GUI>();
|
|
||||||
auto result = std::any_cast<Events::Combat>(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);
|
$actions.show_text("stats", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue