Fix move animation defaults not working (fixes Tackle crash)
This commit is contained in:
parent
6c59ed27ce
commit
aa421b5d10
|
@ -429,10 +429,12 @@ export default class BattleScene extends SceneBase {
|
|||
|
||||
ui.setup();
|
||||
|
||||
const defaultMoves = [ Moves.TACKLE, Moves.TAIL_WHIP, Moves.FOCUS_ENERGY, Moves.STRUGGLE ];
|
||||
|
||||
Promise.all([
|
||||
Promise.all(loadPokemonAssets),
|
||||
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(() => {
|
||||
this.pushPhase(new LoginPhase(this));
|
||||
this.pushPhase(new TitlePhase(this));
|
||||
|
|
|
@ -455,16 +455,14 @@ export function initMoveAnim(move: Moves): Promise<void> {
|
|||
} else {
|
||||
moveAnims.set(move, null);
|
||||
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) => {
|
||||
fetch(`./battle-anims/${Moves[move].toLowerCase().replace(/\_/g, '-')}.json`)
|
||||
fetch(`./battle-anims/${moveName}.json`)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
console.error(response.status, response.statusText);
|
||||
if (move !== defaultMoveAnim)
|
||||
fetchAnimAndResolve(defaultMoveAnim);
|
||||
else
|
||||
resolve();
|
||||
return;
|
||||
console.error(`Could not load animation file for move '${moveName}'`, response.status, response.statusText);
|
||||
populateMoveAnim(move, moveAnims.get(defaultMoveAnim));
|
||||
return resolve();
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue