diff --git a/lib/game/behaviors/camera_focusing_behavior.dart b/lib/game/behaviors/camera_focusing_behavior.dart index 453b338c..8a13821d 100644 --- a/lib/game/behaviors/camera_focusing_behavior.dart +++ b/lib/game/behaviors/camera_focusing_behavior.dart @@ -37,7 +37,6 @@ class CameraFocusingBehavior extends Component case GameStatus.waiting: break; case GameStatus.playing: - case GameStatus.replaying: _zoom(_foci['game']!); break; case GameStatus.gameOver: diff --git a/lib/game/bloc/game_bloc.dart b/lib/game/bloc/game_bloc.dart index 16319c16..b22baa14 100644 --- a/lib/game/bloc/game_bloc.dart +++ b/lib/game/bloc/game_bloc.dart @@ -16,17 +16,12 @@ class GameBloc extends Bloc { on(_onSparkyTurboChargeActivated); on(_onGameOver); on(_onGameStarted); - on(_onGameRestarted); } void _onGameStarted(GameStarted _, Emitter emit) { emit(state.copyWith(status: GameStatus.playing)); } - void _onGameRestarted(GameRestarted _, Emitter emit) { - emit(const GameState.initial().copyWith(status: GameStatus.replaying)); - } - void _onGameOver(GameOver _, Emitter emit) { emit(state.copyWith(status: GameStatus.gameOver)); } diff --git a/lib/game/bloc/game_event.dart b/lib/game/bloc/game_event.dart index ac3de39e..6dba8056 100644 --- a/lib/game/bloc/game_event.dart +++ b/lib/game/bloc/game_event.dart @@ -67,13 +67,6 @@ class GameStarted extends GameEvent { List get props => []; } -class GameRestarted extends GameEvent { - const GameRestarted(); - - @override - List get props => []; -} - class GameOver extends GameEvent { const GameOver(); diff --git a/lib/game/components/backbox/backbox.dart b/lib/game/components/backbox/backbox.dart index 695eed09..c76cd0c6 100644 --- a/lib/game/components/backbox/backbox.dart +++ b/lib/game/components/backbox/backbox.dart @@ -70,7 +70,7 @@ class Backbox extends PositionComponent with ZIndex { ); } else if (state is InitialsSuccessState) { _display.add( - InfoDisplay( + GameOverInfoDisplay( onShare: () { _bloc.add( ShareScoreRequested( diff --git a/lib/game/components/backbox/displays/displays.dart b/lib/game/components/backbox/displays/displays.dart index 7d5582df..932a7b2a 100644 --- a/lib/game/components/backbox/displays/displays.dart +++ b/lib/game/components/backbox/displays/displays.dart @@ -1,4 +1,4 @@ -export 'info_display.dart'; +export 'game_over_info_display.dart'; export 'initials_input_display.dart'; export 'initials_submission_failure_display.dart'; export 'initials_submission_success_display.dart'; diff --git a/lib/game/components/backbox/displays/info_display.dart b/lib/game/components/backbox/displays/game_over_info_display.dart similarity index 92% rename from lib/game/components/backbox/displays/info_display.dart rename to lib/game/components/backbox/displays/game_over_info_display.dart index ee6395c2..7cca58c1 100644 --- a/lib/game/components/backbox/displays/info_display.dart +++ b/lib/game/components/backbox/displays/game_over_info_display.dart @@ -10,11 +10,11 @@ import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_ui/pinball_ui.dart'; /// Signature for the callback called when the user tries to share their score -/// from the [InfoDisplay]. +/// from the [GameOverInfoDisplay]. typedef OnShareTap = void Function(); /// Signature for the callback called when the user tries to navigate to the -/// Google IO site from the [InfoDisplay]. +/// Google IO site from the [GameOverInfoDisplay]. typedef OnNavigateTap = void Function(); final _titleTextPaint = TextPaint( @@ -52,12 +52,12 @@ final _descriptionTextPaint = TextPaint( ), ); -/// {@template info_display} +/// {@template game_over_info_display} /// Display that handles shows to the user share or goto IO website. /// {@endtemplate} -class InfoDisplay extends Component with HasGameRef { - /// {@macro info_display} - InfoDisplay({ +class GameOverInfoDisplay extends Component with HasGameRef { + /// {@macro game_over_info_display} + GameOverInfoDisplay({ OnShareTap? onShare, OnNavigateTap? onNavigate, }) : super( @@ -72,7 +72,7 @@ class InfoDisplay extends Component with HasGameRef { @override Future onLoad() async { await super.onLoad(); - gameRef.overlays.add(PinballGame.replayButtonOverlay); + //gameRef.overlays.add(PinballGame.replayButtonOverlay); } } @@ -164,7 +164,7 @@ class _LinksComponent extends PositionComponent with HasGameRef { position: Vector2(0, 9.2), children: [ ShareLinkComponent(onTap: onShare), - GotoIOLinkComponent(onTap: onNavigate), + GoogleIOLinkComponent(onTap: onNavigate), ], ); } @@ -198,12 +198,12 @@ class ShareLinkComponent extends TextComponent with HasGameRef, Tappable { } } -/// {@template goto_io_link_component} +/// {@template google_io_link_component} /// Link button to navigate to Google I/O site. /// {@endtemplate} -class GotoIOLinkComponent extends TextComponent with HasGameRef, Tappable { - /// {@macro goto_io_link_component} - GotoIOLinkComponent({ +class GoogleIOLinkComponent extends TextComponent with HasGameRef, Tappable { + /// {@macro google_io_link_component} + GoogleIOLinkComponent({ OnNavigateTap? onTap, }) : _onTap = onTap, super( diff --git a/lib/start_game/bloc/start_game_bloc.dart b/lib/start_game/bloc/start_game_bloc.dart index 004b3872..5892cd80 100644 --- a/lib/start_game/bloc/start_game_bloc.dart +++ b/lib/start_game/bloc/start_game_bloc.dart @@ -34,7 +34,6 @@ class StartGameBloc extends Bloc { emit( state.copyWith( status: StartGameStatus.selectCharacter, - restarted: true, ), ); } diff --git a/lib/start_game/bloc/start_game_state.dart b/lib/start_game/bloc/start_game_state.dart index ea8319cd..ad7c7cbe 100644 --- a/lib/start_game/bloc/start_game_state.dart +++ b/lib/start_game/bloc/start_game_state.dart @@ -22,33 +22,23 @@ class StartGameState extends Equatable { /// {@macro start_game_state} const StartGameState({ required this.status, - this.restarted = false, }); /// Initial [StartGameState]. - const StartGameState.initial() - : this( - status: StartGameStatus.initial, - restarted: false, - ); + const StartGameState.initial() : this(status: StartGameStatus.initial); /// Status of [StartGameState]. final StartGameStatus status; - /// Game has been restarted from game over screen. - final bool restarted; - /// Creates a copy of [StartGameState]. StartGameState copyWith({ StartGameStatus? status, - bool? restarted, }) { return StartGameState( status: status ?? this.status, - restarted: restarted ?? this.restarted, ); } @override - List get props => [status, restarted]; + List get props => [status]; } diff --git a/lib/start_game/widgets/start_game_listener.dart b/lib/start_game/widgets/start_game_listener.dart index 336d2474..692116f3 100644 --- a/lib/start_game/widgets/start_game_listener.dart +++ b/lib/start_game/widgets/start_game_listener.dart @@ -31,11 +31,7 @@ class StartGameListener extends StatelessWidget { break; case StartGameStatus.selectCharacter: _onSelectCharacter(context); - if (state.restarted) { - context.read().add(const GameRestarted()); - } else { - context.read().add(const GameStarted()); - } + context.read().add(const GameStarted()); break; case StartGameStatus.howToPlay: _onHowToPlay(context); diff --git a/test/game/bloc/game_bloc_test.dart b/test/game/bloc/game_bloc_test.dart index 07327b12..3e5abb74 100644 --- a/test/game/bloc/game_bloc_test.dart +++ b/test/game/bloc/game_bloc_test.dart @@ -38,20 +38,6 @@ void main() { ], ); - blocTest( - 'GameRestarted restarts the game', - build: GameBloc.new, - act: (bloc) => bloc.add(const GameRestarted()), - expect: () => [ - isA() - ..having( - (state) => state.status, - 'status', - GameStatus.replaying, - ), - ], - ); - group('RoundLost', () { blocTest( 'decreases number of rounds ' diff --git a/test/game/bloc/game_event_test.dart b/test/game/bloc/game_event_test.dart index b15a14b9..c4de5792 100644 --- a/test/game/bloc/game_event_test.dart +++ b/test/game/bloc/game_event_test.dart @@ -98,19 +98,6 @@ void main() { }); }); - group('GameRestarted', () { - test('can be instantiated', () { - expect(const GameRestarted(), isNotNull); - }); - - test('supports value equality', () { - expect( - GameRestarted(), - equals(const GameRestarted()), - ); - }); - }); - group('SparkyTurboChargeActivated', () { test('can be instantiated', () { expect(const SparkyTurboChargeActivated(), isNotNull); diff --git a/test/game/components/backbox/backbox_test.dart b/test/game/components/backbox/backbox_test.dart index 6bc36292..ddb66768 100644 --- a/test/game/components/backbox/backbox_test.dart +++ b/test/game/components/backbox/backbox_test.dart @@ -232,7 +232,7 @@ void main() { await game.pump(backbox); expect( - game.descendants().whereType().length, + game.descendants().whereType().length, equals(1), ); }, diff --git a/test/game/components/backbox/displays/info_display_test.dart b/test/game/components/backbox/displays/game_over_info_display_test.dart similarity index 90% rename from test/game/components/backbox/displays/info_display_test.dart rename to test/game/components/backbox/displays/game_over_info_display_test.dart index d1e72fc6..450fd386 100644 --- a/test/game/components/backbox/displays/info_display_test.dart +++ b/test/game/components/backbox/displays/game_over_info_display_test.dart @@ -8,7 +8,7 @@ import 'package:flame_test/flame_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; import 'package:pinball/game/bloc/game_bloc.dart'; -import 'package:pinball/game/components/backbox/displays/info_display.dart'; +import 'package:pinball/game/components/backbox/displays/game_over_info_display.dart'; import 'package:pinball/l10n/l10n.dart'; import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_flame/pinball_flame.dart'; @@ -25,7 +25,7 @@ class _TestGame extends Forge2DGame with HasTappables { ); } - Future pump(InfoDisplay component) { + Future pump(GameOverInfoDisplay component) { return ensureAdd( FlameBlocProvider.value( value: GameBloc(), @@ -71,7 +71,7 @@ void main() { flameTester.test( 'loads correctly', (game) async { - final component = InfoDisplay(); + final component = GameOverInfoDisplay(); await game.pump(component); expect(game.descendants(), contains(component)); }, @@ -83,7 +83,7 @@ void main() { var tapped = false; final tapDownInfo = _MockTapDownInfo(); - final component = InfoDisplay( + final component = GameOverInfoDisplay( onShare: () => tapped = true, ); await game.pump(component); @@ -103,7 +103,7 @@ void main() { var tapped = false; final tapDownInfo = _MockTapDownInfo(); - final component = InfoDisplay( + final component = GameOverInfoDisplay( onNavigate: () => tapped = true, ); await game.pump(component); diff --git a/test/game/components/game_bloc_status_listener_test.dart b/test/game/components/game_bloc_status_listener_test.dart index 6b51a52d..b424486f 100644 --- a/test/game/components/game_bloc_status_listener_test.dart +++ b/test/game/components/game_bloc_status_listener_test.dart @@ -167,7 +167,7 @@ void main() { await game.pump([component], pinballPlayer: player); component.onNewState( - const GameState.initial().copyWith(status: GameStatus.replaying), + const GameState.initial().copyWith(status: GameStatus.playing), ); expect( diff --git a/test/start_game/bloc/start_game_bloc_test.dart b/test/start_game/bloc/start_game_bloc_test.dart index 55c2ccc0..01789912 100644 --- a/test/start_game/bloc/start_game_bloc_test.dart +++ b/test/start_game/bloc/start_game_bloc_test.dart @@ -16,13 +16,12 @@ void main() { ); blocTest( - 'on ReplayTapped changes status to selectCharacter and restarted enabled', + 'on ReplayTapped changes status to selectCharacter', build: StartGameBloc.new, act: (bloc) => bloc.add(const ReplayTapped()), expect: () => [ const StartGameState( status: StartGameStatus.selectCharacter, - restarted: true, ) ], ); diff --git a/test/start_game/bloc/start_game_state_test.dart b/test/start_game/bloc/start_game_state_test.dart index 26e1738c..ad983417 100644 --- a/test/start_game/bloc/start_game_state_test.dart +++ b/test/start_game/bloc/start_game_state_test.dart @@ -49,14 +49,12 @@ void main() { ); final otherState = StartGameState( status: StartGameStatus.play, - restarted: true, ); expect(state, isNot(equals(otherState))); expect( state.copyWith( status: otherState.status, - restarted: otherState.restarted, ), equals(otherState), ); @@ -69,7 +67,6 @@ void main() { testState.props, equals([ StartGameStatus.selectCharacter, - false, ]), ); }); diff --git a/test/start_game/widgets/start_game_listener_test.dart b/test/start_game/widgets/start_game_listener_test.dart index 100a34d1..39a4b893 100644 --- a/test/start_game/widgets/start_game_listener_test.dart +++ b/test/start_game/widgets/start_game_listener_test.dart @@ -46,7 +46,7 @@ void main() { }); testWidgets( - 'calls GameStarted event only on play', + 'calls GameStarted event', (tester) async { whenListen( startGameBloc, @@ -66,38 +66,10 @@ void main() { startGameBloc: startGameBloc, ); - verifyNever(() => gameBloc.add(const GameRestarted())); verify(() => gameBloc.add(const GameStarted())).called(1); }, ); - testWidgets( - 'calls GameRestarted event only on replay', - (tester) async { - whenListen( - startGameBloc, - Stream.value( - const StartGameState( - status: StartGameStatus.selectCharacter, - restarted: true, - ), - ), - initialState: const StartGameState.initial(), - ); - - await tester.pumpApp( - const StartGameListener( - child: SizedBox.shrink(), - ), - gameBloc: gameBloc, - startGameBloc: startGameBloc, - ); - - verifyNever(() => gameBloc.add(const GameStarted())); - verify(() => gameBloc.add(const GameRestarted())).called(1); - }, - ); - testWidgets( 'shows SelectCharacter dialog', (tester) async {