fix: ball spawn logic

pull/136/head
Erick Zanardo 4 years ago
parent b67b08a18d
commit 5f8bddce97

@ -88,7 +88,7 @@ class LaunchedBallController extends BallController
void onNewState(GameState state) { void onNewState(GameState state) {
super.onNewState(state); super.onNewState(state);
component.shouldRemove = true; component.shouldRemove = true;
if (state.balls > 1) gameRef.spawnBall(); if (state.balls >= 1) gameRef.spawnBall();
} }
/// Removes the [Ball] from a [PinballGame]; spawning a new [Ball] if /// Removes the [Ball] from a [PinballGame]; spawning a new [Ball] if

@ -176,7 +176,7 @@ void main() {
await game.ensureAdd(ball); await game.ensureAdd(ball);
final state = MockGameState(); final state = MockGameState();
when(() => state.balls).thenReturn(1); when(() => state.balls).thenReturn(0);
final previousBalls = game.descendants().whereType<Ball>().toList(); final previousBalls = game.descendants().whereType<Ball>().toList();
controller.onNewState(state); controller.onNewState(state);

Loading…
Cancel
Save