|
|
@ -28,18 +28,15 @@ class GameState extends Equatable {
|
|
|
|
const GameState({
|
|
|
|
const GameState({
|
|
|
|
required this.score,
|
|
|
|
required this.score,
|
|
|
|
required this.multiplier,
|
|
|
|
required this.multiplier,
|
|
|
|
required this.balls,
|
|
|
|
|
|
|
|
required this.rounds,
|
|
|
|
required this.rounds,
|
|
|
|
required this.bonusHistory,
|
|
|
|
required this.bonusHistory,
|
|
|
|
}) : assert(score >= 0, "Score can't be negative"),
|
|
|
|
}) : assert(score >= 0, "Score can't be negative"),
|
|
|
|
assert(multiplier > 0, 'Multiplier must be greater than zero'),
|
|
|
|
assert(multiplier > 0, 'Multiplier must be greater than zero'),
|
|
|
|
assert(balls >= 0, "Number of balls can't be negative"),
|
|
|
|
|
|
|
|
assert(rounds >= 0, "Number of rounds can't be negative");
|
|
|
|
assert(rounds >= 0, "Number of rounds can't be negative");
|
|
|
|
|
|
|
|
|
|
|
|
const GameState.initial()
|
|
|
|
const GameState.initial()
|
|
|
|
: score = 0,
|
|
|
|
: score = 0,
|
|
|
|
multiplier = 1,
|
|
|
|
multiplier = 1,
|
|
|
|
balls = 0,
|
|
|
|
|
|
|
|
rounds = 3,
|
|
|
|
rounds = 3,
|
|
|
|
bonusHistory = const [];
|
|
|
|
bonusHistory = const [];
|
|
|
|
|
|
|
|
|
|
|
@ -49,11 +46,6 @@ class GameState extends Equatable {
|
|
|
|
/// The current multiplier for the score.
|
|
|
|
/// The current multiplier for the score.
|
|
|
|
final int multiplier;
|
|
|
|
final int multiplier;
|
|
|
|
|
|
|
|
|
|
|
|
/// The number of balls left in each round.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// When the number of balls is 0, round is lost.
|
|
|
|
|
|
|
|
final int balls;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The number of rounds left in the game.
|
|
|
|
/// The number of rounds left in the game.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// When the number of rounds is 0, the game is over.
|
|
|
|
/// When the number of rounds is 0, the game is over.
|
|
|
@ -63,9 +55,6 @@ class GameState extends Equatable {
|
|
|
|
/// PinballGame.
|
|
|
|
/// PinballGame.
|
|
|
|
final List<GameBonus> bonusHistory;
|
|
|
|
final List<GameBonus> bonusHistory;
|
|
|
|
|
|
|
|
|
|
|
|
/// Determines when the round is over.
|
|
|
|
|
|
|
|
bool get isRoundOver => balls == 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Determines when the game is over.
|
|
|
|
/// Determines when the game is over.
|
|
|
|
bool get isGameOver => rounds == 0;
|
|
|
|
bool get isGameOver => rounds == 0;
|
|
|
|
|
|
|
|
|
|
|
@ -84,7 +73,6 @@ class GameState extends Equatable {
|
|
|
|
return GameState(
|
|
|
|
return GameState(
|
|
|
|
score: score ?? this.score,
|
|
|
|
score: score ?? this.score,
|
|
|
|
multiplier: multiplier ?? this.multiplier,
|
|
|
|
multiplier: multiplier ?? this.multiplier,
|
|
|
|
balls: balls ?? this.balls,
|
|
|
|
|
|
|
|
rounds: rounds ?? this.rounds,
|
|
|
|
rounds: rounds ?? this.rounds,
|
|
|
|
bonusHistory: bonusHistory ?? this.bonusHistory,
|
|
|
|
bonusHistory: bonusHistory ?? this.bonusHistory,
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -94,7 +82,6 @@ class GameState extends Equatable {
|
|
|
|
List<Object?> get props => [
|
|
|
|
List<Object?> get props => [
|
|
|
|
score,
|
|
|
|
score,
|
|
|
|
multiplier,
|
|
|
|
multiplier,
|
|
|
|
balls,
|
|
|
|
|
|
|
|
rounds,
|
|
|
|
rounds,
|
|
|
|
bonusHistory,
|
|
|
|
bonusHistory,
|
|
|
|
];
|
|
|
|
];
|
|
|
|