|
|
|
@ -6,8 +6,7 @@ |
|
|
|
|
|
|
|
|
|
using namespace combat; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("cause scared rat won't run away bug", "[combat-fail]") { |
|
|
|
|
TEST_CASE("battle operations fantasy", "[combat-battle]") { |
|
|
|
|
ai::reset(); |
|
|
|
|
ai::init("assets/ai.json"); |
|
|
|
|
|
|
|
|
@ -15,41 +14,30 @@ TEST_CASE("cause scared rat won't run away bug", "[combat-fail]") { |
|
|
|
|
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", false); |
|
|
|
|
REQUIRE(!rat.active()); |
|
|
|
|
battle.add_enemy(rat_id, rat); |
|
|
|
|
battle.plan(); |
|
|
|
|
REQUIRE(rat.active()); |
|
|
|
|
rat.dump(); |
|
|
|
|
REQUIRE(rat.wants_to("run_away")); |
|
|
|
|
} |
|
|
|
|
DinkyECS::Entity axe_ranger = 0; |
|
|
|
|
ai::EntityAI axe_ai("Enemy::actions", ai_start, ai_goal); |
|
|
|
|
axe_ai.set_state("tough_personality", true); |
|
|
|
|
axe_ai.set_state("health_good", true); |
|
|
|
|
components::Combat axe_combat{100, 100, 20}; |
|
|
|
|
battle.add_enemy({axe_ranger, axe_ai, axe_combat}); |
|
|
|
|
|
|
|
|
|
TEST_CASE("battle operations fantasy", "[combat]") { |
|
|
|
|
ai::reset(); |
|
|
|
|
ai::init("assets/ai.json"); |
|
|
|
|
DinkyECS::Entity rat = 1; |
|
|
|
|
ai::EntityAI rat_ai("Enemy::actions", ai_start, ai_goal); |
|
|
|
|
rat_ai.set_state("tough_personality", false); |
|
|
|
|
rat_ai.set_state("health_good", true); |
|
|
|
|
components::Combat rat_combat{10, 10, 2}; |
|
|
|
|
battle.add_enemy({rat, rat_ai, rat_combat}); |
|
|
|
|
|
|
|
|
|
auto ai_start = ai::load_state("Enemy::initial_state"); |
|
|
|
|
auto ai_goal = ai::load_state("Enemy::final_state"); |
|
|
|
|
battle.plan(); |
|
|
|
|
|
|
|
|
|
DinkyECS::Entity enemy_id = 0; |
|
|
|
|
ai::EntityAI enemy("Enemy::actions", ai_start, ai_goal); |
|
|
|
|
enemy.set_state("tough_personality", true); |
|
|
|
|
enemy.set_state("health_good", true); |
|
|
|
|
while(auto act = battle.next()) { |
|
|
|
|
auto& [entity, enemy_ai, combat] = *act; |
|
|
|
|
|
|
|
|
|
BattleEngine battle; |
|
|
|
|
battle.add_enemy(enemy_id, enemy); |
|
|
|
|
|
|
|
|
|
// responsible for running the AI and determining:
|
|
|
|
|
// 1. Which enemy gets to go.
|
|
|
|
|
// 2. What they want to do.
|
|
|
|
|
battle.plan(); |
|
|
|
|
fmt::println("entity: {} wants to {} and has {} HP and {} damage", |
|
|
|
|
entity, |
|
|
|
|
enemy_ai.wants_to(), |
|
|
|
|
combat.hp, combat.damage); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Then it will go through each in order and
|
|
|
|
|
// have them fight, producing the results
|
|
|
|
|
battle.fight([&](auto, auto& entity_ai) { |
|
|
|
|
entity_ai.dump(); |
|
|
|
|
}); |
|
|
|
|
REQUIRE(!battle.next()); |
|
|
|
|
} |
|
|
|
|