Cleanup before refactoring the boss/fight.cpp code.

This commit is contained in:
Zed A. Shaw 2025-12-05 12:02:57 -05:00
parent 94c0d2dc0b
commit 1537a81aac
3 changed files with 7 additions and 15 deletions

View file

@ -10,6 +10,10 @@ namespace combat {
$player_requests.emplace(request);
}
void BattleEngine::clear_requests() {
$player_requests.clear();
}
bool BattleEngine::plan() {
dbc::check($player_requests.size() > 0, "Calling plan without any player reqeusts queued.");
using enum BattleHostState;
@ -17,7 +21,6 @@ namespace combat {
int active = 0;
bool had_host = false;
fmt::println("---------- start combatants");
for(auto& [entity, enemy] : $combatants) {
//NOTE: this is just for asserting I'm using things right
if(enemy.is_host) had_host = true;
@ -46,21 +49,10 @@ namespace combat {
}
if(host_state == out_of_ap) {
fmt::println("--- enemy CANNOT go: {}-{}={}",
enemy.combat->ap, action.cost,
enemy.combat->ap - action.cost);
break;
} else {
fmt::println("--- enemy can go, {}-{}={}",
enemy.combat->ap, action.cost,
enemy.combat->ap - action.cost);
enemy.combat->ap -= action.cost;
}
fmt::println("--- active enemy {} ap={}, host_state={}",
entity, enemy.combat->ap, int(host_state));
$pending_actions.emplace_back(enemy, action.name, action.cost, host_state);
}
@ -70,8 +62,6 @@ namespace combat {
}
dbc::check(had_host, "FAIL, you forgot to set enemy.is_host=true for one entity");
fmt::println("<---- end of enemy setup, sorting");
if($pending_actions.size() > 0) {
std::sort($pending_actions.begin(), $pending_actions.end(),
[](const auto& a, const auto& b) -> bool

View file

@ -42,5 +42,6 @@ namespace combat {
void set(DinkyECS::Entity entity, const std::string& state, bool setting);
void set_all(const std::string& state, bool setting);
void player_request(const std::string& request);
void clear_requests();
};
}

View file

@ -68,7 +68,8 @@ TEST_CASE("battle operations fantasy", "[combat-battle]") {
break;
case BattleHostState::disagree:
fmt::println("REBELIOUS ACT: {}", wants_to);
battle.$player_requests.clear();
battle.clear_requests();
REQUIRE(battle.$player_requests.size() == 0);
break;
case BattleHostState::not_host:
if(wants_to == "kill_enemy") {