Skip to content

Commit

Permalink
Removed async operations from starting battles (#719)
Browse files Browse the repository at this point in the history
We shouldn't be `.then`-ing a play Promise. It's meant to be async.

Pipes through a `startTransition` name if it exists.
  • Loading branch information
Josh Goldberg committed Apr 24, 2018
1 parent 2fb15b1 commit 5653e61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/components/Battles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ export interface IPartialBattleOptions {
*/
onComplete?: IOnBattleComplete;

/**
* Transition name to start with, if not a random one.
*/
startTransition?: string;

/**
* Opposing teams in the battle.
*/
Expand Down
15 changes: 8 additions & 7 deletions src/components/battles/animations/Starting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ export class Starting<TGameStartr extends FullScreenPokemon> extends GeneralComp
this.gameStarter.graphics.moveThingsToText(battleInfo.keptThings);
}

// tslint:disable-next-line no-floating-promises
this.gameStarter.audioPlayer.play(battleInfo.theme, {
alias: this.gameStarter.audio.aliases.theme,
loop: true,
}).then(() => {
this.transitions.play({
onComplete: (): void => {
this.setupThings(battleInfo);
this.runTeamEntrances(battleInfo, onComplete);
},
});
});

this.transitions.play({
name: battleInfo.startTransition,
onComplete: (): void => {
this.setupThings(battleInfo);
this.runTeamEntrances(battleInfo, onComplete);
},
});
}

/**
Expand Down

0 comments on commit 5653e61

Please sign in to comment.