feat: pr suggestions

pull/24/head
Erick Zanardo 4 years ago
parent 0e70483c3e
commit acc5a8a3e4

@ -9,15 +9,16 @@ part 'game_state.dart';
class GameBloc extends Bloc<GameEvent, GameState> {
GameBloc({
int bonusLettersCount = 'GOOGLE'.length,
}) : _bonusLettersCount = bonusLettersCount,
int bonusLettersLength = bonusWord.length,
}) : _bonusLettersLength = bonusLettersLength,
super(const GameState.initial()) {
on<BallLost>(_onBallLost);
on<Scored>(_onScored);
on<BonusLetterActivated>(_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<GameEvent, GameState> {
event.letterIndex,
];
if (newBonusLetters.length == _bonusLettersCount) {
if (newBonusLetters.length == _bonusLettersLength) {
emit(
state.copyWith(
activatedBonusLetters: [],

@ -132,7 +132,7 @@ void main() {
blocTest<GameBloc, GameState>(
'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))

Loading…
Cancel
Save