From d857a784b239d1546bcdc983da6e08a841b28737 Mon Sep 17 00:00:00 2001 From: Erick Date: Mon, 4 Apr 2022 10:55:00 -0300 Subject: [PATCH] fix: ball spawn logic (#136) * fix: ball spawn logic * Update lib/game/components/controlled_ball.dart Co-authored-by: Alejandro Santiago Co-authored-by: Alejandro Santiago --- lib/game/components/controlled_ball.dart | 2 +- test/game/components/controlled_ball_test.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/game/components/controlled_ball.dart b/lib/game/components/controlled_ball.dart index 257d4f1d..1981e39c 100644 --- a/lib/game/components/controlled_ball.dart +++ b/lib/game/components/controlled_ball.dart @@ -88,7 +88,7 @@ class LaunchedBallController extends BallController void onNewState(GameState state) { super.onNewState(state); component.shouldRemove = true; - if (state.balls > 1) gameRef.spawnBall(); + if (state.balls > 0) gameRef.spawnBall(); } /// Removes the [Ball] from a [PinballGame]; spawning a new [Ball] if diff --git a/test/game/components/controlled_ball_test.dart b/test/game/components/controlled_ball_test.dart index 8417aa25..f9494543 100644 --- a/test/game/components/controlled_ball_test.dart +++ b/test/game/components/controlled_ball_test.dart @@ -176,7 +176,7 @@ void main() { await game.ensureAdd(ball); final state = MockGameState(); - when(() => state.balls).thenReturn(1); + when(() => state.balls).thenReturn(0); final previousBalls = game.descendants().whereType().toList(); controller.onNewState(state);