diff --git a/src/dusk/rpg/battle/CMakeLists.txt b/src/dusk/rpg/battle/CMakeLists.txt index 5b0a546c..41f3315a 100644 --- a/src/dusk/rpg/battle/CMakeLists.txt +++ b/src/dusk/rpg/battle/CMakeLists.txt @@ -10,3 +10,6 @@ target_sources(${DUSK_LIBRARY_TARGET_NAME} battlefighter.c party.c ) + +# Subdirs +add_subdirectory(testbattle) diff --git a/src/dusk/rpg/battle/testbattle/CMakeLists.txt b/src/dusk/rpg/battle/testbattle/CMakeLists.txt new file mode 100644 index 00000000..790611c0 --- /dev/null +++ b/src/dusk/rpg/battle/testbattle/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2026 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Sources +target_sources(${DUSK_LIBRARY_TARGET_NAME} + PUBLIC + testbattle.c +) diff --git a/src/dusk/rpg/battle/testbattle/testbattle.c b/src/dusk/rpg/battle/testbattle/testbattle.c new file mode 100644 index 00000000..6ebf73d9 --- /dev/null +++ b/src/dusk/rpg/battle/testbattle/testbattle.c @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2026 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#include "testbattle.h" +#include "rpg/battle/battle.h" +#include "scene/scene.h" + +void testBattleStart(void) { + battleInit(); + + const battlefighterstats_t allyOneStats = + { .attack = 10, .defense = 5, .magic = 0, .speed = 10, .luck = 0 }; + const battlefighterstats_t allyTwoStats = + { .attack = 8, .defense = 4, .magic = 0, .speed = 8, .luck = 0 }; + const battlefighterstats_t enemyOneStats = + { .attack = 6, .defense = 3, .magic = 0, .speed = 6, .luck = 0 }; + const battlefighterstats_t enemyTwoStats = + { .attack = 7, .defense = 3, .magic = 0, .speed = 5, .luck = 0 }; + + battleAddFighter( + BATTLE_FIGHTER_TEAM_ALLY, BATTLE_FIGHTER_CONTROLLER_PLAYER, + allyOneStats, 30, 10 + ); + battleAddFighter( + BATTLE_FIGHTER_TEAM_ALLY, BATTLE_FIGHTER_CONTROLLER_PLAYER, + allyTwoStats, 25, 10 + ); + battleAddFighter( + BATTLE_FIGHTER_TEAM_ENEMY, BATTLE_FIGHTER_CONTROLLER_AI, + enemyOneStats, 20, 5 + ); + battleAddFighter( + BATTLE_FIGHTER_TEAM_ENEMY, BATTLE_FIGHTER_CONTROLLER_AI, + enemyTwoStats, 20, 5 + ); + + battleStart(BATTLE_ENCOUNTER_REGULAR, true); + sceneSet(SCENE_TYPE_BATTLE); +} diff --git a/src/dusk/rpg/battle/testbattle/testbattle.h b/src/dusk/rpg/battle/testbattle/testbattle.h new file mode 100644 index 00000000..f2e4ab15 --- /dev/null +++ b/src/dusk/rpg/battle/testbattle/testbattle.h @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2026 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "error/error.h" + +/** + * TEMPORARY test hook: sets up a hardcoded mock battle and switches to the + * battle scene, so the battle scene (camera/fighters/HUD) can be seen and + * played without a real encounter trigger yet. + */ +void testBattleStart(void); diff --git a/src/dusk/ui/frame/mainmenu/uimainmenu.c b/src/dusk/ui/frame/mainmenu/uimainmenu.c index 63918af9..8b224bcf 100644 --- a/src/dusk/ui/frame/mainmenu/uimainmenu.c +++ b/src/dusk/ui/frame/mainmenu/uimainmenu.c @@ -9,7 +9,7 @@ #include "ui/frame/uiframe.h" #include "scene/scene.h" #include "engine/engine.h" -#include "rpg/battle/battle.h" +#include "rpg/battle/testbattle/testbattle.h" #include "save/save.h" #include "util/memory.h" #include "display/spritebatch/spritebatch.h" @@ -23,42 +23,6 @@ uimainmenu_t UI_MAIN_MENU; -// TEMPORARY test hook: New Game starts a hardcoded mock battle instead of -// the overworld, so the battle scene (camera/fighters/HUD) can be seen and -// played without a real encounter trigger yet. -void uiMainMenuStartTestBattle(void) { - battleInit(); - - const battlefighterstats_t allyOneStats = - { .attack = 10, .defense = 5, .magic = 0, .speed = 10, .luck = 0 }; - const battlefighterstats_t allyTwoStats = - { .attack = 8, .defense = 4, .magic = 0, .speed = 8, .luck = 0 }; - const battlefighterstats_t enemyOneStats = - { .attack = 6, .defense = 3, .magic = 0, .speed = 6, .luck = 0 }; - const battlefighterstats_t enemyTwoStats = - { .attack = 7, .defense = 3, .magic = 0, .speed = 5, .luck = 0 }; - - battleAddFighter( - BATTLE_FIGHTER_TEAM_ALLY, BATTLE_FIGHTER_CONTROLLER_PLAYER, - allyOneStats, 30, 10 - ); - battleAddFighter( - BATTLE_FIGHTER_TEAM_ALLY, BATTLE_FIGHTER_CONTROLLER_PLAYER, - allyTwoStats, 25, 10 - ); - battleAddFighter( - BATTLE_FIGHTER_TEAM_ENEMY, BATTLE_FIGHTER_CONTROLLER_AI, - enemyOneStats, 20, 5 - ); - battleAddFighter( - BATTLE_FIGHTER_TEAM_ENEMY, BATTLE_FIGHTER_CONTROLLER_AI, - enemyTwoStats, 20, 5 - ); - - battleStart(BATTLE_ENCOUNTER_REGULAR, true); - sceneSet(SCENE_TYPE_BATTLE); -} - void uiMainMenuSelected( const uimenu_t *menu, const uint8_t index, @@ -71,7 +35,7 @@ void uiMainMenuSelected( // Resets the active slot to SAVE_DEFAULT in memory -- no disk I/O, // unlike Load Game (which will read a real slot via saveLoadSlot()). saveLoadDefault(SAVE_ACTIVE_SLOT); - uiMainMenuStartTestBattle(); + testBattleStart(); break; case UI_MAIN_MENU_INDEX_LOAD_GAME: