diff --git a/lib/game/bloc/game_bloc.dart b/lib/game/bloc/game_bloc.dart index b9987935..bfe27db5 100644 --- a/lib/game/bloc/game_bloc.dart +++ b/lib/game/bloc/game_bloc.dart @@ -9,15 +9,16 @@ part 'game_state.dart'; class GameBloc extends Bloc { GameBloc({ - int bonusLettersCount = 'GOOGLE'.length, - }) : _bonusLettersCount = bonusLettersCount, + int bonusLettersLength = bonusWord.length, + }) : _bonusLettersLength = bonusLettersLength, super(const GameState.initial()) { on(_onBallLost); on(_onScored); on(_onBonusLetterActivated); } - final int _bonusLettersCount; + final int _bonusLettersLength; + static const bonusWord = 'GOOGLE'; void _onBallLost(BallLost event, Emitter emit) { if (state.balls > 0) { @@ -37,7 +38,7 @@ class GameBloc extends Bloc { event.letterIndex, ]; - if (newBonusLetters.length == _bonusLettersCount) { + if (newBonusLetters.length == _bonusLettersLength) { emit( state.copyWith( activatedBonusLetters: [], diff --git a/test/game/bloc/game_bloc_test.dart b/test/game/bloc/game_bloc_test.dart index f2abc20c..ebef6293 100644 --- a/test/game/bloc/game_bloc_test.dart +++ b/test/game/bloc/game_bloc_test.dart @@ -132,7 +132,7 @@ void main() { blocTest( 'adds the bonus when the sequence is completed', - build: () => GameBloc(bonusLettersCount: 3), + build: () => GameBloc(bonusLettersLength: 3), act: (bloc) => bloc ..add(const BonusLetterActivated(0)) ..add(const BonusLetterActivated(1))