Getting more UI elements sorted out in the boss fight.

This commit is contained in:
Zed A. Shaw 2025-12-20 14:07:52 -05:00
parent d4d8d8ca99
commit a8863cf687
4 changed files with 28 additions and 44 deletions

View file

@ -30,7 +30,6 @@ namespace boss {
switch($state) { switch($state) {
FSM_STATE(State, START, ev, data); FSM_STATE(State, START, ev, data);
FSM_STATE(State, PLAYER_REQUESTS, ev, data); FSM_STATE(State, PLAYER_REQUESTS, ev, data);
FSM_STATE(State, PLAN_BATTLE, ev, data);
FSM_STATE(State, EXEC_PLAN, ev, data); FSM_STATE(State, EXEC_PLAN, ev, data);
FSM_STATE(State, END, ev, data); FSM_STATE(State, END, ev, data);
} }
@ -43,7 +42,7 @@ namespace boss {
// this is only if using the debug X key to skip it // this is only if using the debug X key to skip it
case TICK: case TICK:
case BOSS_START: case BOSS_START:
$ui.status(L"PLAYER REQUESTS"); $ui.status(L"PLAYER REQUESTS", L"COMMIT");
$battle.ap_refresh(); $battle.ap_refresh();
state(State::PLAYER_REQUESTS); state(State::PLAYER_REQUESTS);
break; break;
@ -62,8 +61,8 @@ namespace boss {
break; break;
case COMBAT_START: case COMBAT_START:
System::plan_battle($battle, $world, $boss_id); System::plan_battle($battle, $world, $boss_id);
$ui.status(L"PLANNING BATTLE"); $ui.status(L"EXEC PLAN", L"START");
state(State::PLAN_BATTLE); state(State::EXEC_PLAN);
break; break;
case ATTACK: case ATTACK:
if($battle.player_request("kill_enemy")) { if($battle.player_request("kill_enemy")) {
@ -80,7 +79,7 @@ namespace boss {
} }
} }
void Fight::PLAN_BATTLE(game::Event ev, std::any data) { void Fight::EXEC_PLAN(game::Event ev, std::any data) {
using enum game::Event; using enum game::Event;
switch(ev) { switch(ev) {
@ -89,23 +88,27 @@ namespace boss {
state(State::END); state(State::END);
break; break;
case COMBAT_START: case COMBAT_START:
$ui.status(L"EXEC PLAN"); $ui.status(L"X TURN", L"STEP");
state(State::EXEC_PLAN); next_combat_dumb_name();
break;
case COMBAT:
do_combat(data);
break; break;
case TICK:
break; // ignore tick
default: default:
break; break;
} }
} }
void Fight::next_combat_dumb_name() { void Fight::next_combat_dumb_name() {
if(auto action = $battle.next()) { if(auto action = $battle.next()) {
System::combat(*action, $world, $boss_id, 0); System::combat(*action, $world, $boss_id, 0);
} else if(player_dead()) { } else if(player_dead()) {
$ui.status(L"YOU DIED", L"DEAD");
state(State::END); state(State::END);
} else { } else {
$ui.status(L"PLAYER REQUESTS"); $ui.zoom("", 1.0);
$ui.status(L"PLAYER REQUESTS", L"COMMIT");
$battle.ap_refresh(); $battle.ap_refresh();
$battle.clear_requests(); $battle.clear_requests();
state(State::PLAYER_REQUESTS); state(State::PLAYER_REQUESTS);
@ -124,35 +127,8 @@ namespace boss {
$ui.move_actor("player", player_move); $ui.move_actor("player", player_move);
$ui.move_actor("boss", boss_move); $ui.move_actor("boss", boss_move);
if(result.enemy_did > 0) { $ui.damage("player", result.enemy_did);
// make boss move $ui.damage("boss", result.player_did);
$ui.animate_actor("boss");
}
if(result.player_did > 0) {
// make player move
$ui.animate_actor("player");
$ui.zoom(player_move, 2.0);
}
}
void Fight::EXEC_PLAN(game::Event ev, std::any data) {
using enum game::Event;
switch(ev) {
// this is only if using the debug X key to skip it
case BOSS_START:
state(State::END);
break;
case COMBAT_START:
next_combat_dumb_name();
break;
case COMBAT:
do_combat(data);
break;
default:
break;
}
} }
void Fight::END(game::Event ev, std::any) { void Fight::END(game::Event ev, std::any) {

View file

@ -15,7 +15,6 @@ namespace boss {
enum class State { enum class State {
START=__LINE__, START=__LINE__,
PLAYER_REQUESTS=__LINE__, PLAYER_REQUESTS=__LINE__,
PLAN_BATTLE=__LINE__,
EXEC_PLAN=__LINE__, EXEC_PLAN=__LINE__,
END=__LINE__ END=__LINE__
}; };
@ -42,7 +41,6 @@ namespace boss {
void START(game::Event ev, std::any data); void START(game::Event ev, std::any data);
void PLAYER_REQUESTS(game::Event ev, std::any data); void PLAYER_REQUESTS(game::Event ev, std::any data);
void PLAN_BATTLE(game::Event ev, std::any data);
void EXEC_PLAN(game::Event ev, std::any data); void EXEC_PLAN(game::Event ev, std::any data);
void END(game::Event ev, std::any data); void END(game::Event ev, std::any data);
void render(sf::RenderWindow& window); void render(sf::RenderWindow& window);

View file

@ -87,8 +87,9 @@ namespace boss {
|| $actions.mouse(x, y, mods) || $arena.mouse(x, y, mods); || $actions.mouse(x, y, mods) || $arena.mouse(x, y, mods);
} }
void UI::status(const std::wstring& msg) { void UI::status(const std::wstring& msg, const std::wstring &button_msg) {
$arena.$ui.show_text("status", msg); $arena.$ui.show_text("status", msg);
$actions.show_text("commit", button_msg);
} }
void UI::move_actor(const std::string& actor, const std::string& cell_name) { void UI::move_actor(const std::string& actor, const std::string& cell_name) {
@ -103,6 +104,14 @@ namespace boss {
$arena.play_animations(); $arena.play_animations();
} }
void UI::damage(const std::string& actor, int amount) {
if(amount == 0) {
$arena.$ui.show_text("boss7", fmt::format(L"{} MISSED!", guecs::to_wstring(actor)));
} else {
$arena.$ui.show_text("boss7", fmt::format(L"{} HIT {}!", guecs::to_wstring(actor), amount));
}
}
void UI::zoom(const std::string &cell_name, double ratio) { void UI::zoom(const std::string &cell_name, double ratio) {
if(cell_name == "") { if(cell_name == "") {
dbc::log("!!!!!!!!! you should add this to guecs"); dbc::log("!!!!!!!!! you should add this to guecs");

View file

@ -33,11 +33,12 @@ namespace boss {
void init(); void init();
void render(sf::RenderWindow& window); void render(sf::RenderWindow& window);
bool mouse(float x, float y, guecs::Modifiers mods); bool mouse(float x, float y, guecs::Modifiers mods);
void status(const std::wstring& msg); void status(const std::wstring& msg, const std::wstring &button_msg);
void move_actor(const std::string& actor, const std::string& cell_name); void move_actor(const std::string& actor, const std::string& cell_name);
void animate_actor(const std::string& actor); void animate_actor(const std::string& actor);
void update_stats(); void update_stats();
void play_animations(); void play_animations();
void zoom(const std::string &cell, double ratio); void zoom(const std::string& cell, double ratio);
void damage(const std::string& actor, int amount);
}; };
} }