Fix move animation defaults not working (fixes Tackle crash)

This commit is contained in:
Flashfyre 2024-04-04 09:45:25 -04:00
parent 6c59ed27ce
commit aa421b5d10
2 changed files with 8 additions and 8 deletions

View File

@ -429,10 +429,12 @@ export default class BattleScene extends SceneBase {
ui.setup(); ui.setup();
const defaultMoves = [ Moves.TACKLE, Moves.TAIL_WHIP, Moves.FOCUS_ENERGY, Moves.STRUGGLE ];
Promise.all([ Promise.all([
Promise.all(loadPokemonAssets), Promise.all(loadPokemonAssets),
initCommonAnims().then(() => loadCommonAnimAssets(this, true)), initCommonAnims().then(() => loadCommonAnimAssets(this, true)),
initMoveAnim(Moves.STRUGGLE).then(() => loadMoveAnimAssets(this, [ Moves.STRUGGLE ], true)) Promise.all([ Moves.TACKLE, Moves.TAIL_WHIP, Moves.FOCUS_ENERGY, Moves.STRUGGLE ].map(m => initMoveAnim(m))).then(() => loadMoveAnimAssets(this, defaultMoves, true))
]).then(() => { ]).then(() => {
this.pushPhase(new LoginPhase(this)); this.pushPhase(new LoginPhase(this));
this.pushPhase(new TitlePhase(this)); this.pushPhase(new TitlePhase(this));

View File

@ -455,16 +455,14 @@ export function initMoveAnim(move: Moves): Promise<void> {
} else { } else {
moveAnims.set(move, null); moveAnims.set(move, null);
const defaultMoveAnim = allMoves[move] instanceof AttackMove ? Moves.TACKLE : allMoves[move] instanceof SelfStatusMove ? Moves.FOCUS_ENERGY : Moves.TAIL_WHIP; const defaultMoveAnim = allMoves[move] instanceof AttackMove ? Moves.TACKLE : allMoves[move] instanceof SelfStatusMove ? Moves.FOCUS_ENERGY : Moves.TAIL_WHIP;
const moveName = Moves[move].toLowerCase().replace(/\_/g, '-');
const fetchAnimAndResolve = (move: Moves) => { const fetchAnimAndResolve = (move: Moves) => {
fetch(`./battle-anims/${Moves[move].toLowerCase().replace(/\_/g, '-')}.json`) fetch(`./battle-anims/${moveName}.json`)
.then(response => { .then(response => {
if (!response.ok) { if (!response.ok) {
console.error(response.status, response.statusText); console.error(`Could not load animation file for move '${moveName}'`, response.status, response.statusText);
if (move !== defaultMoveAnim) populateMoveAnim(move, moveAnims.get(defaultMoveAnim));
fetchAnimAndResolve(defaultMoveAnim); return resolve();
else
resolve();
return;
} }
return response.json(); return response.json();
}) })