AI engine is working and I have a little BattleEngine going but the AI is working better than it should in systems.cpp. Need to find out why then make the BattleEngine avoid running entities that have END in action lists.
parent
da273cbee6
commit
47c6bfd531
@ -1,9 +1,39 @@ |
||||
#include <catch2/catch_test_macros.hpp> |
||||
#include <iostream> |
||||
#include "rituals.hpp" |
||||
#include "fsm.hpp" |
||||
#include "dinkyecs.hpp" |
||||
|
||||
using namespace combat; |
||||
|
||||
TEST_CASE("turn based combat engine sorted", "[combat]") { |
||||
dbc::log("does nothing."); |
||||
|
||||
TEST_CASE("cause scared rat won't run away bug", "[combat]") { |
||||
ai::reset(); |
||||
ai::init("assets/ai.json"); |
||||
auto ai_start = ai::load_state("Enemy::initial_state"); |
||||
auto ai_goal = ai::load_state("Enemy::final_state"); |
||||
BattleEngine battle; |
||||
|
||||
DinkyECS::Entity rat_id = 1; |
||||
ai::EntityAI rat("Enemy::actions", ai_start, ai_goal); |
||||
rat.set_state("tough_personality", false); |
||||
rat.set_state("health_good", true); |
||||
|
||||
battle.add_enemy(rat_id, rat); |
||||
|
||||
// first confirm that everyone stops fightings
|
||||
bool active = battle.plan(); |
||||
REQUIRE(active); |
||||
|
||||
// this causes the plan to read END but if you set
|
||||
// health_good to false it will run_away
|
||||
|
||||
rat.set_state("health_good", false); |
||||
active = battle.plan(); |
||||
REQUIRE(rat.wants_to("run_away")); |
||||
|
||||
battle.fight([&](const auto entity, auto& ai) { |
||||
fmt::println("\n\n======= FIGHT! {}", entity); |
||||
ai.dump(); |
||||
}); |
||||
} |
||||
|
Loading…
Reference in new issue