Now have the basics of the turn based battle engine with AI rebellion working.

This commit is contained in:
Zed A. Shaw 2025-12-01 00:14:08 -05:00
parent f3b20f30c5
commit c78b2ae75e
8 changed files with 114 additions and 73 deletions

View file

@ -4,28 +4,34 @@
#include "dinkyecs.hpp"
#include <optional>
#include "components.hpp"
#include <set>
namespace combat {
enum class BattleHostState {
not_host = 0,
agree = 1,
disagree = 2
};
struct Combatant {
DinkyECS::Entity entity = DinkyECS::NONE;
ai::EntityAI* ai = nullptr;
components::Combat* combat = nullptr;
};
enum class BattleAction {
ATTACK, BLOCK, ESCAPE, OTHER
bool is_host=false;
};
struct BattleResult {
Combatant state;
ai::Action wants_to;
BattleAction action;
std::string wants_to;
int cost;
BattleHostState host_state;
};
struct BattleEngine {
std::unordered_map<DinkyECS::Entity, Combatant> combatants;
std::vector<BattleResult> pending_actions;
std::unordered_map<DinkyECS::Entity, Combatant> $combatants;
std::vector<BattleResult> $pending_actions;
std::set<std::string> $player_requests;
void add_enemy(Combatant ba);
Combatant& get_enemy(DinkyECS::Entity entity);
@ -34,5 +40,6 @@ namespace combat {
void dump();
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);
};
}