feat: game over voice over (#320)

* feat: game over voice over

* docs nits

* fixing rebase
pull/350/head
Erick 3 years ago committed by GitHub
parent 391f9cac8f
commit 79da2e9234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,6 +22,7 @@ class GameBlocStatusListener extends Component
gameRef.overlays.remove(PinballGame.playButtonOverlay); gameRef.overlays.remove(PinballGame.playButtonOverlay);
break; break;
case GameStatus.gameOver: case GameStatus.gameOver:
gameRef.player.play(PinballAudio.gameOverVoiceOver);
gameRef.descendants().whereType<Backbox>().first.requestInitials( gameRef.descendants().whereType<Backbox>().first.requestInitials(
score: state.displayScore, score: state.displayScore,
character: gameRef.characterTheme, character: gameRef.characterTheme,

@ -16,6 +16,7 @@ class $AssetsSfxGen {
String get bumperA => 'assets/sfx/bumper_a.mp3'; String get bumperA => 'assets/sfx/bumper_a.mp3';
String get bumperB => 'assets/sfx/bumper_b.mp3'; String get bumperB => 'assets/sfx/bumper_b.mp3';
String get gameOverVoiceOver => 'assets/sfx/game_over_voice_over.mp3';
String get google => 'assets/sfx/google.mp3'; String get google => 'assets/sfx/google.mp3';
String get ioPinballVoiceOver => 'assets/sfx/io_pinball_voice_over.mp3'; String get ioPinballVoiceOver => 'assets/sfx/io_pinball_voice_over.mp3';
} }

@ -18,7 +18,10 @@ enum PinballAudio {
backgroundMusic, backgroundMusic,
/// IO Pinball voice over /// IO Pinball voice over
ioPinballVoiceOver ioPinballVoiceOver,
/// Game over
gameOverVoiceOver,
} }
/// Defines the contract of the creation of an [AudioPool]. /// Defines the contract of the creation of an [AudioPool].
@ -30,20 +33,16 @@ typedef CreateAudioPool = Future<AudioPool> Function(
String? prefix, String? prefix,
}); });
/// Function that defines the contract for playing a single /// Defines the contract for playing a single audio.
/// audio
typedef PlaySingleAudio = Future<void> Function(String); typedef PlaySingleAudio = Future<void> Function(String);
/// Function that defines the contract for looping a single /// Defines the contract for looping a single audio.
/// audio
typedef LoopSingleAudio = Future<void> Function(String); typedef LoopSingleAudio = Future<void> Function(String);
/// Function that defines the contract for pre fetching an /// Defines the contract for pre fetching an audio.
/// audio
typedef PreCacheSingleAudio = Future<void> Function(String); typedef PreCacheSingleAudio = Future<void> Function(String);
/// Function that defines the contract for configuring /// Defines the contract for configuring an [AudioCache] instance.
/// an [AudioCache] instance
typedef ConfigureAudioCache = void Function(AudioCache); typedef ConfigureAudioCache = void Function(AudioCache);
abstract class _Audio { abstract class _Audio {
@ -164,6 +163,11 @@ class PinballPlayer {
playSingleAudio: _playSingleAudio, playSingleAudio: _playSingleAudio,
path: Assets.sfx.ioPinballVoiceOver, path: Assets.sfx.ioPinballVoiceOver,
), ),
PinballAudio.gameOverVoiceOver: _SimplePlayAudio(
preCacheSingleAudio: _preCacheSingleAudio,
playSingleAudio: _playSingleAudio,
path: Assets.sfx.gameOverVoiceOver,
),
PinballAudio.bumper: _BumperAudio( PinballAudio.bumper: _BumperAudio(
createAudioPool: _createAudioPool, createAudioPool: _createAudioPool,
seed: _seed, seed: _seed,

@ -146,6 +146,11 @@ void main() {
'packages/pinball_audio/assets/sfx/io_pinball_voice_over.mp3', 'packages/pinball_audio/assets/sfx/io_pinball_voice_over.mp3',
), ),
).called(1); ).called(1);
verify(
() => preCacheSingleAudio.onCall(
'packages/pinball_audio/assets/sfx/game_over_voice_over.mp3',
),
).called(1);
verify( verify(
() => preCacheSingleAudio () => preCacheSingleAudio
.onCall('packages/pinball_audio/assets/music/background.mp3'), .onCall('packages/pinball_audio/assets/music/background.mp3'),
@ -227,6 +232,19 @@ void main() {
}); });
}); });
group('gameOverVoiceOver', () {
test('plays the correct file', () async {
await Future.wait(player.load());
player.play(PinballAudio.gameOverVoiceOver);
verify(
() => playSingleAudio.onCall(
'packages/pinball_audio/${Assets.sfx.gameOverVoiceOver}',
),
).called(1);
});
});
group('backgroundMusic', () { group('backgroundMusic', () {
test('plays the correct file', () async { test('plays the correct file', () async {
await Future.wait(player.load()); await Future.wait(player.load());

@ -128,6 +128,18 @@ void main() {
.called(1); .called(1);
}, },
); );
test(
'plays the game over voice over when it is game over',
() {
gameFlowController.onNewState(
GameState.initial().copyWith(status: GameStatus.gameOver),
);
verify(() => pinballPlayer.play(PinballAudio.gameOverVoiceOver))
.called(1);
},
);
}); });
}); });
} }

Loading…
Cancel
Save