diff --git a/lib/game/bloc/start_game_bloc.dart b/lib/start_game/bloc/start_game_bloc.dart similarity index 82% rename from lib/game/bloc/start_game_bloc.dart rename to lib/start_game/bloc/start_game_bloc.dart index 3541b60c..d0d98913 100644 --- a/lib/game/bloc/start_game_bloc.dart +++ b/lib/start_game/bloc/start_game_bloc.dart @@ -6,7 +6,7 @@ part 'start_game_event.dart'; part 'start_game_state.dart'; /// {@template start_game_bloc} -/// Bloc which allows to control user state before launch the game. +/// Bloc that manages the app flow before the game starts. /// {@endtemplate} class StartGameBloc extends Bloc { /// {@macro start_game_bloc} @@ -14,22 +14,22 @@ class StartGameBloc extends Bloc { required PinballGame game, }) : _game = game, super(const StartGameState.initial()) { - on(_onSelectCharacter); + on(_onStartGame); on(_onHowToPlay); on(_onPlay); } final PinballGame _game; - void _onSelectCharacter( - SelectCharacter event, + void _onStartGame( + StartGame event, Emitter emit, ) { _game.gameFlowController.start(); emit( state.copyWith( - status: StartGameStatus.selectCharacter, + status: StartGameStatus.startGame, ), ); } diff --git a/lib/game/bloc/start_game_event.dart b/lib/start_game/bloc/start_game_event.dart similarity index 85% rename from lib/game/bloc/start_game_event.dart rename to lib/start_game/bloc/start_game_event.dart index 590aa8a9..ce5f8b02 100644 --- a/lib/game/bloc/start_game_event.dart +++ b/lib/start_game/bloc/start_game_event.dart @@ -1,7 +1,7 @@ part of 'start_game_bloc.dart'; /// {@template start_game_event} -/// Event added when user is staring the game. +/// Event added during the start game flow. /// {@endtemplate} abstract class StartGameEvent extends Equatable { /// {@macro start_game_event} @@ -11,9 +11,9 @@ abstract class StartGameEvent extends Equatable { /// {@template select_character} /// Select character event. /// {@endtemplate} -class SelectCharacter extends StartGameEvent { +class StartGame extends StartGameEvent { /// {@macro select_character} - const SelectCharacter(); + const StartGame(); @override List get props => []; diff --git a/lib/game/bloc/start_game_state.dart b/lib/start_game/bloc/start_game_state.dart similarity index 91% rename from lib/game/bloc/start_game_state.dart rename to lib/start_game/bloc/start_game_state.dart index 9cff3ac2..34fbd3c5 100644 --- a/lib/game/bloc/start_game_state.dart +++ b/lib/start_game/bloc/start_game_state.dart @@ -6,7 +6,7 @@ enum StartGameStatus { initial, /// Selection characters status. - selectCharacter, + startGame, /// How to play status. howToPlay, @@ -16,7 +16,7 @@ enum StartGameStatus { } /// {@template start_game_state} -/// Represents the state of flow before launch the game. +/// Represents the state of flow before the game starts. /// {@endtemplate} class StartGameState extends Equatable { /// {@macro start_game_state} diff --git a/test/game/bloc/start_game_bloc_test.dart b/test/start_game/bloc/start_game_bloc_test.dart similarity index 77% rename from test/game/bloc/start_game_bloc_test.dart rename to test/start_game/bloc/start_game_bloc_test.dart index 7b2aff56..250955bf 100644 --- a/test/game/bloc/start_game_bloc_test.dart +++ b/test/start_game/bloc/start_game_bloc_test.dart @@ -1,12 +1,10 @@ import 'package:bloc_test/bloc_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; -import 'package:pinball/game/bloc/start_game_bloc.dart'; import 'package:pinball/game/game.dart'; +import 'package:pinball/start_game/bloc/start_game_bloc.dart'; -class MockPinballGame extends Mock implements PinballGame {} - -class MockGameFlowController extends Mock implements GameFlowController {} +import '../../helpers/helpers.dart'; void main() { late PinballGame pinballGame; @@ -23,14 +21,14 @@ void main() { group('StartGameBloc', () { blocTest( - 'on SelectCharacter changes status to selectCharacter', + 'on StartGame changes status to StartGame', build: () => StartGameBloc( game: pinballGame, ), - act: (bloc) => bloc.add(const SelectCharacter()), + act: (bloc) => bloc.add(const StartGame()), expect: () => [ const StartGameState( - status: StartGameStatus.selectCharacter, + status: StartGameStatus.startGame, ) ], ); diff --git a/test/game/bloc/start_game_event_test.dart b/test/start_game/bloc/start_game_event_test.dart similarity index 71% rename from test/game/bloc/start_game_event_test.dart rename to test/start_game/bloc/start_game_event_test.dart index 4fd5623b..7a80783f 100644 --- a/test/game/bloc/start_game_event_test.dart +++ b/test/start_game/bloc/start_game_event_test.dart @@ -1,14 +1,14 @@ // ignore_for_file: prefer_const_constructors import 'package:flutter_test/flutter_test.dart'; -import 'package:pinball/game/bloc/start_game_bloc.dart'; +import 'package:pinball/start_game/bloc/start_game_bloc.dart'; void main() { group('StartGameEvent', () { - test('SelectCharacter supports value equality', () { + test('StartGame supports value equality', () { expect( - SelectCharacter(), - equals(SelectCharacter()), + StartGame(), + equals(StartGame()), ); }); diff --git a/test/game/bloc/start_game_state_test.dart b/test/start_game/bloc/start_game_state_test.dart similarity index 79% rename from test/game/bloc/start_game_state_test.dart rename to test/start_game/bloc/start_game_state_test.dart index b59c5c2c..20c7803a 100644 --- a/test/game/bloc/start_game_state_test.dart +++ b/test/start_game/bloc/start_game_state_test.dart @@ -1,12 +1,12 @@ // ignore_for_file: prefer_const_constructors import 'package:flutter_test/flutter_test.dart'; -import 'package:pinball/game/bloc/start_game_bloc.dart'; +import 'package:pinball/start_game/bloc/start_game_bloc.dart'; void main() { group('StartGameState', () { final testState = StartGameState( - status: StartGameStatus.selectCharacter, + status: StartGameStatus.startGame, ); test('initial state has correct values', () { @@ -19,7 +19,7 @@ void main() { test('supports value equality', () { final secondState = StartGameState( - status: StartGameStatus.selectCharacter, + status: StartGameStatus.startGame, ); expect(testState, secondState); @@ -35,7 +35,7 @@ void main() { expect( testState.props, equals([ - StartGameStatus.selectCharacter, + StartGameStatus.startGame, ]), ); });