Valgrind passes. Fixed a bug in combat.
This commit is contained in:
parent
55af06821c
commit
568171c4a2
6 changed files with 18 additions and 21 deletions
|
|
@ -32,7 +32,7 @@ namespace components {
|
|||
|
||||
// don't go below 0
|
||||
body_parts[name] = std::max(0, hp - my_dmg);
|
||||
fmt::println("BODY PART {} was {} now {}", name, hp, body_parts[name]);
|
||||
fmt::println("BODY PART {} was {} now {} damage is {}", name, hp, body_parts[name], my_dmg);
|
||||
}
|
||||
|
||||
bool Combat::less_than(int level) {
|
||||
|
|
|
|||
|
|
@ -264,7 +264,9 @@ void System::combat(int attack_id) {
|
|||
|
||||
// battle.dump();
|
||||
|
||||
bool battle_ran = false;
|
||||
while(auto act = battle.next()) {
|
||||
battle_ran = true;
|
||||
auto [enemy, enemy_action, cost, host_state] = *act;
|
||||
|
||||
// player shouldn't hit theirself
|
||||
|
|
|
|||
|
|
@ -181,22 +181,10 @@ namespace gui {
|
|||
}
|
||||
|
||||
void FSM::ATTACKING(Event ev, std::any data) {
|
||||
using enum Event;
|
||||
switch(ev) {
|
||||
case TICK: {
|
||||
dbc::log("!!!!!! FIX System::combat(0) doesn't use any weapons, only first");
|
||||
$systems.runCombat(0);
|
||||
run_systems();
|
||||
state(State::IDLE);
|
||||
} break;
|
||||
case ATTACK: {
|
||||
int attack_id = std::any_cast<int>(data);
|
||||
$systems.runCombat(attack_id);
|
||||
run_systems();
|
||||
} break;
|
||||
default:
|
||||
dbc::log($F("In ATTACKING state, unhandled event {}", (int)ev));
|
||||
state(State::IDLE);
|
||||
if(!$main_ui.hands_playing()) {
|
||||
// run combat one more time
|
||||
$systems.runCombat(0);
|
||||
state(State::IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -254,13 +242,15 @@ namespace gui {
|
|||
$main_ui.plan_rotate(1, DEFAULT_ROTATE);
|
||||
state(State::ROTATING);
|
||||
break;
|
||||
case ATTACK:
|
||||
case ATTACK: {
|
||||
$main_ui.play_hands();
|
||||
$main_ui.dirty();
|
||||
sound::play("Sword_Hit_1");
|
||||
$systems.runCombat(0);
|
||||
run_systems();
|
||||
$status_ui.update();
|
||||
state(State::ATTACKING);
|
||||
break;
|
||||
} break;
|
||||
case CLOSE:
|
||||
dbc::log("Nothing to close.");
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -146,6 +146,10 @@ namespace gui {
|
|||
if(!$hand_anim.playing) $hand_anim.play();
|
||||
}
|
||||
|
||||
bool MainUI::hands_playing() {
|
||||
return $hand_anim.playing;
|
||||
}
|
||||
|
||||
void MainUI::render_hands() {
|
||||
if($hand_anim.playing) {
|
||||
$hand_anim.update();
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ namespace gui {
|
|||
void toggle_mind_reading();
|
||||
void render_mind_reading();
|
||||
void play_hands();
|
||||
bool hands_playing();
|
||||
void render_hands();
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue