From f4d96207384463907a5e4f37f5ccbf574b24336c Mon Sep 17 00:00:00 2001 From: podar <1999688+podarsmarty@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:41:58 -0500 Subject: [PATCH] Updating logging for missing animations --- src/data/battle-anims.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/data/battle-anims.ts b/src/data/battle-anims.ts index a6cc786565a..85887903f01 100644 --- a/src/data/battle-anims.ts +++ b/src/data/battle-anims.ts @@ -494,7 +494,8 @@ export function initMoveAnim(scene: BattleScene, move: Moves): Promise { .then(response => { const contentType = response.headers.get("content-type"); if (!response.ok || contentType?.indexOf("application/json") === -1) { - useAndLogDefaultAnim(move, defaultMoveAnim, response.status, response.statusText); + useDefaultAnim(move, defaultMoveAnim); + logMissingMoveAnim(move, response.status, response.statusText) return resolve(); } return response.json(); @@ -516,7 +517,8 @@ export function initMoveAnim(scene: BattleScene, move: Moves): Promise { } }) .catch(error => { - useAndLogDefaultAnim(move, defaultMoveAnim, error); + useDefaultAnim(move, defaultMoveAnim); + logMissingMoveAnim(move, error) return resolve(); }); }; @@ -530,14 +532,24 @@ export function initMoveAnim(scene: BattleScene, move: Moves): Promise { * * @param move the move to populate an animation for * @param defaultMoveAnim the default move to use as the default animation - * @param optionalParams parameters to add to the error logging */ -function useAndLogDefaultAnim(move: Moves, defaultMoveAnim: Moves, ...optionalParams: any[]) { - const moveName = Utils.animationFileName(move); - console.error(`Could not load animation file for move '${moveName}'`, ...optionalParams); +function useDefaultAnim(move: Moves, defaultMoveAnim: Moves) { populateMoveAnim(move, moveAnims.get(defaultMoveAnim)); } +/** + * Helper method to call when an move animation is missing. + * + * @param move the move to populate an animation for + * @param optionalParams parameters to add to the error logging + * + * @remarks use {@link useDefaultAnim} to use a default animation + */ +function logMissingMoveAnim(move: Moves, ...optionalParams: any[]) { + const moveName = Utils.animationFileName(move); + console.warn(`Could not load animation file for move '${moveName}'`, ...optionalParams); +} + /** * Fetches animation configs to be used in a Mystery Encounter * @param scene