diff --git a/lib/game/bloc/game_bloc.dart b/lib/game/bloc/game_bloc.dart index 001d9f25..048d9bb4 100644 --- a/lib/game/bloc/game_bloc.dart +++ b/lib/game/bloc/game_bloc.dart @@ -6,14 +6,14 @@ part 'game_event.dart'; part 'game_state.dart'; class GameBloc extends Bloc { - GameBloc() : super(const GameState(score: 0, ballsLeft: 3)) { + GameBloc() : super(const GameState(score: 0, balls: 3)) { on(_onBallLost); on(_onScored); } void _onBallLost(BallLost event, Emitter emit) { - if (state.ballsLeft > 0) { - emit(state.copyWith(ballsLeft: state.ballsLeft - 1)); + if (state.balls > 0) { + emit(state.copyWith(balls: state.balls - 1)); } } diff --git a/lib/game/bloc/game_state.dart b/lib/game/bloc/game_state.dart index 0874bb9d..e630d709 100644 --- a/lib/game/bloc/game_state.dart +++ b/lib/game/bloc/game_state.dart @@ -3,27 +3,27 @@ part of 'game_bloc.dart'; class GameState extends Equatable { const GameState({ required this.score, - required this.ballsLeft, + required this.balls, }); final int score; - final int ballsLeft; + final int balls; - bool get isGameOver => ballsLeft == 0; + bool get isGameOver => balls == 0; GameState copyWith({ int? score, - int? ballsLeft, + int? balls, }) { return GameState( score: score ?? this.score, - ballsLeft: ballsLeft ?? this.ballsLeft, + balls: balls ?? this.balls, ); } @override List get props => [ score, - ballsLeft, + balls, ]; }