changeset 232:085c2a02a93f

rpg: some cleanups in battle
author David Demelier <markand@malikania.fr>
date Tue, 24 Nov 2020 16:44:49 +0100
parents 1a8b81c91d7c
children 081c71d1f723
files librpg/rpg/battle-state-attacking.c librpg/rpg/battle-state-opening.c librpg/rpg/battle.c
diffstat 3 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/librpg/rpg/battle-state-attacking.c	Tue Nov 24 16:44:16 2020 +0100
+++ b/librpg/rpg/battle-state-attacking.c	Tue Nov 24 16:44:49 2020 +0100
@@ -105,6 +105,7 @@
 	case SUBSTATE_BLINKING:
 		/* Just wait. */
 		battle_entity_state_normal(data->source);
+		damage(data->source, data->target, bt);
 		battle_state_check(bt);
 		break;
 	default:
--- a/librpg/rpg/battle-state-opening.c	Tue Nov 24 16:44:16 2020 +0100
+++ b/librpg/rpg/battle-state-opening.c	Tue Nov 24 16:44:49 2020 +0100
@@ -27,6 +27,7 @@
 
 #include "battle.h"
 #include "battle-state.h"
+#include "battle-state-check.h"
 #include "battle-state-opening.h"
 #include "battle-state-menu.h"
 
@@ -50,10 +51,8 @@
 	 * Those function will effectively change state accordingly to the
 	 * order of playing.
 	 */
-	if (opening->elapsed >= DELAY) {
-		battle_order(bt);
-		battle_next(bt);
-	}
+	if (opening->elapsed >= DELAY)
+		battle_state_check(bt);
 
 	return false;
 }
@@ -81,7 +80,7 @@
 {
 	(void)bt;
 
-	free(st);
+	free(st->data);
 }
 
 void
--- a/librpg/rpg/battle.c	Tue Nov 24 16:44:16 2020 +0100
+++ b/librpg/rpg/battle.c	Tue Nov 24 16:44:49 2020 +0100
@@ -40,6 +40,7 @@
 #include "battle-indicator.h"
 #include "battle-state.h"
 #include "battle-state-attacking.h"
+#include "battle-state-check.h"
 #include "battle-state-opening.h"
 #include "battle-state-menu.h"
 #include "battle-state-ai.h"
@@ -284,6 +285,7 @@
 	/* TODO: animate. */
 	source->mp -= spell->mp;
 	spell_action(spell, bt, source, selection);
+	battle_state_check(bt);
 }
 
 void
@@ -293,9 +295,10 @@
 
 	battle_bar_reset(&bt->bar);
 
-	if (!bt->order_cur)
+	if (!bt->order_cur) {
+		battle_order(bt);
 		bt->order_cur = bt->order[bt->order_curindex = 0];
-	else {
+	} else {
 		/* End of turn. */
 		if (++bt->order_curindex >= BATTLE_ENTITY_MAX || !bt->order[bt->order_curindex]) {
 			battle_order(bt);