You can now take damage to your head.

This commit is contained in:
Zed A. Shaw 2026-03-29 23:54:21 -04:00
parent cbd4b858ac
commit d22eaa554d
7 changed files with 64 additions and 49 deletions

View file

@ -25,20 +25,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{
.hp=100, .max_hp=100, .ap_delta=6, .max_ap=12, .damage=20};
components::Combat host_combat{.ap_delta=6, .max_ap=12, .damage=20};
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{
.hp=20, .max_hp=20, .ap_delta=8, .max_ap=12, .damage=20};
components::Combat axe_combat{.ap_delta=8, .max_ap=12, .damage=20};
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{
.hp=10, .max_hp=10, .ap_delta=2, .max_ap=10, .damage=10};
components::Combat rat_combat{.ap_delta=2, .max_ap=10, .damage=10};
battle.add_enemy({rat, &rat_ai, &rat_combat});
battle.set_all("enemy_found", true);
@ -50,8 +47,8 @@ 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);
while(!host_combat.is_dead()) {
battle.set(host, "health_good", host_combat.almost_dead());
battle.player_request("use_healing");
battle.player_request("kill_enemy");
@ -62,11 +59,6 @@ TEST_CASE("battle operations fantasy", "[combat-battle]") {
while(auto act = battle.next()) {
auto& [enemy, wants_to, cost, enemy_state] = *act;
// fmt::println(">>>>> entity: {} wants to {} cost={}; has {} HP; {} ap",
// enemy.entity, wants_to,
// cost, enemy.combat->hp,
// enemy.combat->ap);
switch(enemy_state) {
case BattleHostState::agree:
// fmt::println("HOST and PLAYER requests match {}, doing it.", wants_to);