From 091fd58c63dea14a045cc9d21f2ea545c99b7366 Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Fri, 22 Apr 2022 09:49:59 +0200 Subject: [PATCH] refactor: add multiplier state on BallLost --- lib/game/bloc/game_bloc.dart | 10 +++++++--- lib/game/bloc/game_event.dart | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/game/bloc/game_bloc.dart b/lib/game/bloc/game_bloc.dart index 28c04902..507c4a51 100644 --- a/lib/game/bloc/game_bloc.dart +++ b/lib/game/bloc/game_bloc.dart @@ -19,7 +19,13 @@ class GameBloc extends Bloc { } void _onBallLost(BallLost event, Emitter emit) { - emit(state.copyWith(balls: state.balls - 1)); + emit( + state.copyWith( + balls: state.balls - 1, + score: state.score * state.multiplier, + multiplier: 1, + ), + ); } void _onScored(Scored event, Emitter emit) { @@ -32,8 +38,6 @@ class GameBloc extends Bloc { void _onIncreasedMultiplier(MultiplierIncreased event, Emitter emit) { if (!state.isGameOver) { - // TODO(ruimiguel): confirm that x6 is going to be the max value, to add - // assertion here or at MultiplierIncreased event const. emit(state.copyWith(multiplier: state.multiplier + 1)); } } diff --git a/lib/game/bloc/game_event.dart b/lib/game/bloc/game_event.dart index 7b30aace..7a22f415 100644 --- a/lib/game/bloc/game_event.dart +++ b/lib/game/bloc/game_event.dart @@ -55,6 +55,8 @@ class SparkyTurboChargeActivated extends GameEvent { class MultiplierIncreased extends GameEvent { /// {@macro multiplier_increased_game_event} const MultiplierIncreased(); + // TODO(ruimiguel): confirm that x6 is going to be the max value, to add + // assertion here @override List get props => [];