Files
dusk/src/dusk/rpg/battle/state/battlestateselection.h
T
YourWishesandClaude Sonnet 5 37e7e95ace Resolve moves into per-move cutscenes during battle execution
Each queued action now resolves to its move's cutscene
(cutscenes/battle/moves/<name>.jsonc), spliced into the executing state
with a BATTLE_POST_MOVE checkpoint after each one. Fighter turn order is
tracked via fighterOrder/fighterOrderCount, and resolved actions/pending
counts are cleared so fighters aren't skipped in later rounds. Also fixes
a BATTLE_WAIT_SELECTION deadlock and adds an optional "blocking" flag to
MODAL cutscene items.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-09-20 17:49:06 -05:00

98 lines
2.9 KiB
C

/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "rpg/battle/fighter/battlefighter.h"
typedef struct {
// Cursor into BATTLE.fighters (by position index) for the fighter
// currently deciding a move this round.
uint8_t selectionIndex;
} battlestateselection_t;
/**
* Called when the battle enters BATTLE_STATE_SELECTION.
*/
void battleStateSelectionInit(void);
/**
* Updates BATTLE_STATE_SELECTION for one frame: auto-decides for every
* AI-controlled fighter the cursor passes, stopping once it reaches a
* player-controlled fighter awaiting input (see
* battleStateSelectionGetCurrentFighter), or transitions to
* BATTLE_STATE_EXECUTING once every position has decided.
*/
void battleStateSelectionUpdate(void);
/**
* Called when the battle leaves BATTLE_STATE_SELECTION.
*/
void battleStateSelectionDispose(void);
/**
* Checks whether the fighter at fighterIndex has already queued a move
* this round.
*
* @param fighterIndex Index into BATTLE.fighters to check.
* @return True if an action is already pending for this fighter.
*/
bool_t battleStateSelectionFighterHasDecided(const uint8_t fighterIndex);
/**
* Checks whether the fighter at fighterIndex is a live, undecided
* candidate that BATTLE_STATE_SELECTION should still be deciding a move
* for.
*
* @param fighterIndex Index into BATTLE.fighters to check.
* @return True if the fighter is alive and has no move queued yet.
*/
bool_t battleStateSelectionFighterNeedsDecision(const uint8_t fighterIndex);
/**
* Checks whether every fighter in BATTLE.fighterOrder has decided a move
* this round.
*
* @return True once the selection cursor has passed every fighter.
*/
bool_t battleStateSelectionIsComplete(void);
/**
* Queues a basic attack (the "slash" move) from fighterIndex against
* targetIndex.
*
* @param fighterIndex Index into BATTLE.fighters of the deciding fighter.
* @param targetIndex Index into BATTLE.fighters of the target.
*/
void battleStateSelectionQueueAttack(
const uint8_t fighterIndex,
const uint8_t targetIndex
);
/**
* Returns the fighter currently awaiting a decision in
* BATTLE_STATE_SELECTION.
*
* @return Pointer to the fighter awaiting a decision, or NULL if the
* battle isn't in BATTLE_STATE_SELECTION or every position has
* already decided.
*/
battlefighter_t *battleStateSelectionGetCurrentFighter(void);
/**
* Submits the currently-selecting fighter's attack against a target, if
* the battle is in BATTLE_STATE_SELECTION and awaiting a decision. Queues
* the move and advances the selection cursor.
*
* @param targetIndex Index into BATTLE.fighters of the target.
*/
void battleStateSelectionPlayerAttack(const uint8_t targetIndex);
/**
* Ends the battle immediately with BATTLE_STATE_FLED, if the battle is in
* BATTLE_STATE_SELECTION and awaiting a decision.
*/
void battleStateSelectionPlayerFlee(void);