test: remove deleted balls property from GameState

pull/213/head
RuiAlonso 3 years ago
parent 7ab5320585
commit eb1f05f23d

@ -7,12 +7,12 @@ import 'package:pinball_theme/pinball_theme.dart';
/// {@template controlled_ball}
/// A [Ball] with a [BallController] attached.
///
/// When a [Ball] is lost, if there aren't more [Ball]s and game is not over,
/// a new [Ball] will be spawned.
/// {@endtemplate}
class ControlledBall extends Ball with Controls<BallController> {
/// A [Ball] that launches from the [Plunger].
///
/// When a launched [Ball] is lost, it will decrease the [GameState.balls]
/// count, and a new [Ball] is spawned.
ControlledBall.launch({
required CharacterTheme characterTheme,
}) : super(baseColor: characterTheme.ballColor) {
@ -23,8 +23,6 @@ class ControlledBall extends Ball with Controls<BallController> {
/// {@template bonus_ball}
/// {@macro controlled_ball}
///
/// When a bonus [Ball] is lost, the [GameState.balls] doesn't change.
/// {@endtemplate}
ControlledBall.bonus({
required CharacterTheme characterTheme,

@ -102,8 +102,6 @@ class _GameBallsController extends ComponentController<PinballGame>
final noBallsLeft = component.descendants().whereType<Ball>().isEmpty;
final notGameOver = !newState.isGameOver;
print("noBallsLeft $noBallsLeft");
print("notGameOver $notGameOver");
return noBallsLeft && notGameOver;
}

@ -7,7 +7,7 @@ import 'package:pinball/theme/app_colors.dart';
/// {@template game_hud}
/// Overlay on the [PinballGame].
///
/// Displays the current [GameState.score], [GameState.balls] and animates when
/// Displays the current [GameState.score], [GameState.rounds] and animates when
/// the player gets a [GameBonus].
/// {@endtemplate}
class GameHud extends StatefulWidget {

@ -53,30 +53,39 @@ void main() {
});
flameBlocTester.testGameWidget(
'when loaded adds BallAdded to GameBloc',
"lost doesn't adds RoundLost to GameBloc "
'when there are balls left',
setUp: (game, tester) async {
final controller = BallController(ball);
await ball.add(controller);
await game.ensureAdd(ball);
final otherBall = Ball(baseColor: const Color(0xFF00FFFF));
final otherController = BallController(otherBall);
await otherBall.add(otherController);
await game.ensureAdd(otherBall);
controller.lost();
await game.ready();
},
verify: (game, tester) async {
verify(() => gameBloc.add(const BallAdded())).called(1);
verifyNever(() => gameBloc.add(const RoundLost()));
},
);
flameBlocTester.testGameWidget(
'lost adds BallLost to GameBloc',
'lost adds RoundLost to GameBloc '
'when there are no balls left',
setUp: (game, tester) async {
final controller = BallController(ball);
await ball.add(controller);
await game.ensureAdd(ball);
controller.lost();
await game.ready();
},
verify: (game, tester) async {
verify(() => gameBloc.add(const BallLost())).called(1);
verify(() => gameBloc.add(const RoundLost())).called(1);
},
);

@ -24,7 +24,6 @@ void main() {
const state = GameState(
score: 0,
multiplier: 1,
balls: 0,
rounds: 0,
bonusHistory: [],
);

@ -21,7 +21,6 @@ void main() {
const state = GameState(
score: 0,
multiplier: 1,
balls: 0,
rounds: 0,
bonusHistory: [],
);

@ -16,7 +16,6 @@ void main() {
final state = GameState(
score: 10,
multiplier: 1,
balls: 0,
rounds: 0,
bonusHistory: const [],
);
@ -69,7 +68,6 @@ void main() {
GameState(
score: 10,
multiplier: 1,
balls: 0,
rounds: 0,
bonusHistory: const [],
),

@ -86,17 +86,6 @@ void main() {
final flameTester = FlameTester(() => PinballTestGame(assets));
final debugModeFlameTester = FlameTester(() => DebugPinballTestGame(assets));
late GameBloc gameBloc;
setUp(() {
gameBloc = GameBloc();
});
final flameBlocTester = FlameBlocTester<PinballGame, GameBloc>(
gameBuilder: EmptyPinballTestGame.new,
blocBuilder: () => gameBloc,
// assets: assets,
);
group('PinballGame', () {
// TODO(alestiago): test if [PinballGame] registers

@ -19,7 +19,6 @@ void main() {
const initialState = GameState(
score: 1000,
multiplier: 1,
balls: 2,
rounds: 1,
bonusHistory: [],
);

@ -12,7 +12,6 @@ void main() {
const initialState = GameState(
score: 0,
multiplier: 1,
balls: 1,
rounds: 3,
bonusHistory: [],
);

@ -16,7 +16,6 @@ void main() {
const initialState = GameState(
score: score,
multiplier: 1,
balls: 1,
rounds: 1,
bonusHistory: [],
);

Loading…
Cancel
Save