From dbb5301adeb466aa5aae537fc34f284e3b0fe6b8 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Mon, 14 Sep 2026 12:28:40 -0500 Subject: [PATCH] Extract battleactiontype_t/battleaction_t into battleaction.h Matches the existing battleability.h/battlefighter.h split - keeps battle.h focused on the overall battle_t state machine rather than also owning the action data shape. Co-Authored-By: Claude Sonnet 5 --- src/dusk/rpg/battle/battle.h | 18 +----------------- src/dusk/rpg/battle/battleaction.h | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 src/dusk/rpg/battle/battleaction.h diff --git a/src/dusk/rpg/battle/battle.h b/src/dusk/rpg/battle/battle.h index bf5dad2c..eb7910d6 100644 --- a/src/dusk/rpg/battle/battle.h +++ b/src/dusk/rpg/battle/battle.h @@ -7,6 +7,7 @@ #pragma once #include "battlefighter.h" +#include "battleaction.h" #define BATTLE_FIGHTER_COUNT_MAX 8 @@ -46,28 +47,11 @@ typedef enum { BATTLE_STATE_COUNT } battlestate_t; -typedef enum { - BATTLE_ACTION_NONE, // No action decided yet for this fighter this round. - BATTLE_ACTION_ATTACK, - - BATTLE_ACTION_COUNT -} battleactiontype_t; - -typedef struct { - battleactiontype_t type; - uint8_t targetIndex; // Meaningful for BATTLE_ACTION_ATTACK. -} battleaction_t; - typedef void (*battlestatechangedcallback_t)( const battlestate_t previous, const battlestate_t next ); -typedef void (*battleactiondecidedcallback_t)( - const battlefighter_t *fighter, - const battleaction_t *action -); - typedef struct { battlestate_t state; battlefighter_t fighters[BATTLE_FIGHTER_COUNT_MAX]; diff --git a/src/dusk/rpg/battle/battleaction.h b/src/dusk/rpg/battle/battleaction.h new file mode 100644 index 00000000..c786bcfd --- /dev/null +++ b/src/dusk/rpg/battle/battleaction.h @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2026 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "error/error.h" +#include "battlefighter.h" + +typedef enum { + BATTLE_ACTION_NONE, // No action decided yet for this fighter this round. + BATTLE_ACTION_ATTACK, + + BATTLE_ACTION_COUNT +} battleactiontype_t; + +typedef struct { + battleactiontype_t type; + uint8_t targetIndex; // Meaningful for BATTLE_ACTION_ATTACK. +} battleaction_t; + +typedef void (*battleactiondecidedcallback_t)( + const battlefighter_t *fighter, + const battleaction_t *action +);