Fix up the main game based on arena changes.
This commit is contained in:
parent
f839edcd56
commit
94b46a2f95
5 changed files with 9 additions and 10 deletions
4
Makefile
4
Makefile
|
|
@ -37,7 +37,7 @@ tracy_build:
|
|||
meson compile -j 10 -C builddir
|
||||
|
||||
test: build
|
||||
./builddir/runtests -d yes "[combat-battle]"
|
||||
./builddir/runtests -d yes
|
||||
|
||||
run: build test
|
||||
ifeq '$(OS)' 'Windows_NT'
|
||||
|
|
@ -60,7 +60,7 @@ clean:
|
|||
meson compile --clean -C builddir
|
||||
|
||||
debug_test: build
|
||||
gdb --nx -x .gdbinit --ex run --ex bt --ex q --args builddir/runtests -e "[combat-battle]"
|
||||
gdb --nx -x .gdbinit --ex run --ex bt --ex q --args builddir/runtests -e
|
||||
|
||||
win_installer:
|
||||
powershell 'start "C:\Program Files (x86)\solicus\InstallForge\bin\ifbuilderenvx86.exe" scripts\win_installer.ifp'
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
{"_type": "Motion", "dx": 0, "dy": 0, "random": false},
|
||||
{"_type": "Collision", "has": true},
|
||||
{"_type": "EnemyConfig", "ai_script": "Host::actions", "ai_start_name": "Host::initial_state", "ai_goal_name": "Host::final_state"},
|
||||
{"_type": "Personality", "hearing_distance": 5, "tough": false},
|
||||
{"_type": "LightSource", "strength": 35, "radius": 2.0}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
10
battle.cpp
10
battle.cpp
|
|
@ -19,6 +19,9 @@ namespace combat {
|
|||
|
||||
fmt::println("---------- start combatants");
|
||||
for(auto& [entity, enemy] : $combatants) {
|
||||
//NOTE: this is just for asserting I'm using things right
|
||||
if(enemy.is_host) had_host = true;
|
||||
|
||||
if(enemy.combat->ap < enemy.combat->max_ap) {
|
||||
int new_ap = std::min(enemy.combat->max_ap, enemy.combat->ap_delta + enemy.combat->ap);
|
||||
|
||||
|
|
@ -29,17 +32,12 @@ namespace combat {
|
|||
enemy.combat->ap = new_ap;
|
||||
}
|
||||
|
||||
fmt::println("--- enemy {} has {} ap", entity, enemy.combat->ap);
|
||||
// reset action points
|
||||
|
||||
enemy.ai->update();
|
||||
active += enemy.ai->active();
|
||||
|
||||
if(enemy.ai->active()) {
|
||||
for(auto& action : enemy.ai->plan.script) {
|
||||
BattleHostState host_state = not_host;
|
||||
//NOTE: this is just for asserting I'm using things right
|
||||
if(enemy.is_host) had_host = true;
|
||||
|
||||
if(action.cost > enemy.combat->ap) {
|
||||
host_state = out_of_ap;
|
||||
|
|
@ -66,12 +64,12 @@ namespace combat {
|
|||
$pending_actions.emplace_back(enemy, action.name, action.cost, host_state);
|
||||
}
|
||||
|
||||
dbc::check(had_host, "FAIL, you forgot to set enemy.is_host=true for one entity");
|
||||
dbc::check(enemy.combat->ap >= 0, "enemy's AP went below 0");
|
||||
dbc::check(enemy.combat->ap <= enemy.combat->max_ap, "enemy's AP went above max");
|
||||
}
|
||||
}
|
||||
|
||||
dbc::check(had_host, "FAIL, you forgot to set enemy.is_host=true for one entity");
|
||||
fmt::println("<---- end of enemy setup, sorting");
|
||||
|
||||
if($pending_actions.size() > 0) {
|
||||
|
|
|
|||
|
|
@ -234,6 +234,7 @@ void System::combat(int attack_id) {
|
|||
auto& world = *level.world;
|
||||
const auto& player_pos = GameDB::player_position();
|
||||
auto& player_combat = world.get<Combat>(level.player);
|
||||
auto& player_ai = world.get<ai::EntityAI>(level.player);
|
||||
|
||||
// this is guaranteed to not return the given position
|
||||
auto [found, nearby] = collider.neighbors(player_pos.location);
|
||||
|
|
@ -248,6 +249,7 @@ void System::combat(int attack_id) {
|
|||
}
|
||||
}
|
||||
|
||||
battle.add_enemy({level.player, &player_ai, &player_combat, true});
|
||||
battle.set_all("enemy_found", true);
|
||||
battle.set_all("in_combat", true);
|
||||
battle.player_request("kill_enemy");
|
||||
|
|
|
|||
|
|
@ -79,8 +79,6 @@ TEST_CASE("battle operations fantasy", "[combat-battle]") {
|
|||
fmt::println("ENEMY OUT OF AP");
|
||||
break;
|
||||
}
|
||||
|
||||
fmt::println("<<<<<<<<<<<<<<<<");
|
||||
}
|
||||
|
||||
REQUIRE(!battle.next());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue