raycaster/battle.hpp

47 lines
1.1 KiB
C++

#pragma once
#include "rituals.hpp"
#include "config.hpp"
#include "dinkyecs.hpp"
#include <optional>
#include "components.hpp"
#include <set>
namespace combat {
enum class BattleHostState {
not_host = 0,
agree = 1,
disagree = 2,
out_of_ap = 3
};
struct Combatant {
DinkyECS::Entity entity = DinkyECS::NONE;
ai::EntityAI* ai = nullptr;
components::Combat* combat = nullptr;
bool is_host=false;
};
struct BattleResult {
Combatant enemy;
std::string wants_to;
int cost;
BattleHostState host_state;
};
struct BattleEngine {
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);
bool plan();
std::optional<BattleResult> next();
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);
void clear_requests();
};
}