refactor: add multiplier state on BallLost

pull/213/head
RuiAlonso 3 years ago
parent a7b8d60c1e
commit 091fd58c63

@ -19,7 +19,13 @@ class GameBloc extends Bloc<GameEvent, GameState> {
}
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<GameEvent, GameState> {
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));
}
}

@ -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<Object?> get props => [];

Loading…
Cancel
Save