Basic AP (Action Points) system tied to the AI actions, but there's no way to set 'has AP' for the AI?

This commit is contained in:
Zed A. Shaw 2025-12-03 15:24:41 -05:00
parent c78b2ae75e
commit a38bb5b691
8 changed files with 64 additions and 18 deletions

View file

@ -20,17 +20,17 @@ TEST_CASE("battle operations fantasy", "[combat-battle]") {
DinkyECS::Entity host = 0;
ai::EntityAI host_ai("Host::actions", host_start, host_goal);
components::Combat host_combat{100, 100, 20};
components::Combat host_combat{100, 100, 20, 6, 12};
battle.add_enemy({host, &host_ai, &host_combat, true});
DinkyECS::Entity axe_ranger = 1;
ai::EntityAI axe_ai("Enemy::actions", ai_start, ai_goal);
components::Combat axe_combat{100, 100, 20};
components::Combat axe_combat{100, 100, 20, 8, 12};
battle.add_enemy({axe_ranger, &axe_ai, &axe_combat});
DinkyECS::Entity rat = 2;
ai::EntityAI rat_ai("Enemy::actions", ai_start, ai_goal);
components::Combat rat_combat{10, 10, 2};
components::Combat rat_combat{10, 10, 2, 12, 18};
battle.add_enemy({rat, &rat_ai, &rat_combat});
battle.set_all("enemy_found", true);
@ -42,7 +42,6 @@ TEST_CASE("battle operations fantasy", "[combat-battle]") {
battle.set(host, "have_healing", false);
battle.set(host, "tough_personality", false);
while(host_combat.hp > 0) {
battle.set(host, "health_good", host_combat.hp > 20);
@ -52,14 +51,14 @@ TEST_CASE("battle operations fantasy", "[combat-battle]") {
battle.plan();
while(auto act = battle.next()) {
auto& [enemy, wants_to, cost, host_behavior] = *act;
auto& [enemy, wants_to, cost, enemy_state] = *act;
fmt::println(">>>>> entity: {} wants to {} cost={} and has {} HP and {} damage",
fmt::println(">>>>> entity: {} wants to {} cost={}; has {} HP; {} ap",
enemy.entity, wants_to,
cost, enemy.combat->hp,
enemy.combat->damage);
enemy.combat->ap);
switch(host_behavior) {
switch(enemy_state) {
case BattleHostState::agree:
fmt::println("HOST and PLAYER requests match {}, doing it.",
wants_to);
@ -72,6 +71,10 @@ TEST_CASE("battle operations fantasy", "[combat-battle]") {
if(wants_to == "kill_enemy") {
enemy.combat->attack(host_combat);
}
break;
case BattleHostState::out_of_ap:
fmt::println("ENEMY OUT OF AP");
break;
}
fmt::println("<<<<<<<<<<<<<<<<");