Fixed the boss::UI::damage so it says who hit who.

This commit is contained in:
Zed A. Shaw 2025-12-30 01:11:08 -05:00
parent 5676382fbb
commit 6dc9d564c6
4 changed files with 11 additions and 7 deletions

View file

@ -127,14 +127,14 @@ namespace boss {
std::string player_move = Random::uniform(0, 1) == 0 ? "player1" : "player3"; std::string player_move = Random::uniform(0, 1) == 0 ? "player1" : "player3";
$ui.move_actor("player", player_move); $ui.move_actor("player", player_move);
if(result.player_did > 0) $ui.animate_actor("player"); if(result.player_did > 0) $ui.animate_actor("player");
$ui.damage("player", result.player_did); $ui.damage("player", "boss", result.player_did);
} break; } break;
case BattleHostState::not_host: { case BattleHostState::not_host: {
std::string boss_move = Random::uniform(0, 1) == 0 ? "boss5" : "boss6"; std::string boss_move = Random::uniform(0, 1) == 0 ? "boss5" : "boss6";
$ui.move_actor("boss", boss_move); $ui.move_actor("boss", boss_move);
if(result.enemy_did > 0) $ui.animate_actor("boss"); if(result.enemy_did > 0) $ui.animate_actor("boss");
$ui.damage("boss", result.enemy_did); $ui.damage("boss", "player", result.enemy_did);
} break; } break;
case BattleHostState::out_of_ap: case BattleHostState::out_of_ap:
break; break;

View file

@ -106,11 +106,12 @@ namespace boss {
$arena.play_animations(); $arena.play_animations();
} }
void UI::damage(const std::string& actor, int amount) { void UI::damage(const std::string& actor, const std::string& target, int amount) {
$arena.attach_text(actor, fmt::format("{}", amount));
if(amount > 0) { if(amount > 0) {
$arena.attach_text(target, fmt::format("{}", amount));
$arena.apply_effect(actor, "flame"); $arena.apply_effect(actor, "flame");
} else {
$arena.attach_text(actor, "MISSED");
} }
} }
} }

View file

@ -38,6 +38,6 @@ namespace boss {
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 damage(const std::string& actor, int amount); void damage(const std::string& actor, const std::string& target, int amount);
}; };
} }

View file

@ -2,6 +2,8 @@
#include "animation.hpp" #include "animation.hpp"
#include <ranges> #include <ranges>
#include "shaders.hpp" #include "shaders.hpp"
#include <fmt/core.h>
#include "dbc.hpp"
const bool DEBUG=false; const bool DEBUG=false;
@ -109,6 +111,7 @@ namespace scene {
} }
Element& Engine::actor_config(const std::string& actor) { Element& Engine::actor_config(const std::string& actor) {
dbc::check($actor_name_ids.contains(actor), fmt::format("scene does not contain actor {}", actor));
return $actors.at($actor_name_ids.at(actor)); return $actors.at($actor_name_ids.at(actor));
} }
@ -119,7 +122,7 @@ namespace scene {
} }
void Engine::animate_actor(const std::string& actor) { void Engine::animate_actor(const std::string& actor) {
auto& config = $actors.at($actor_name_ids.at(actor)); auto& config = actor_config(actor);
config.anim.play(); config.anim.play();
} }