From f93cdd8ef9556e30062c92dd18ae9ff2e447620b Mon Sep 17 00:00:00 2001 From: alestiago Date: Tue, 5 Apr 2022 13:41:01 +0100 Subject: [PATCH] feat: improved listenWhen logic --- lib/game/components/flutter_forest.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/game/components/flutter_forest.dart b/lib/game/components/flutter_forest.dart index 966b0a6b..c54c9a68 100644 --- a/lib/game/components/flutter_forest.dart +++ b/lib/game/components/flutter_forest.dart @@ -59,9 +59,13 @@ class _FlutterForestController extends ComponentController @override bool listenWhen(GameState? previousState, GameState newState) { - return (previousState?.bonusHistory.length ?? 0) < + final gainedBonus = (previousState?.bonusHistory.length ?? 0) < newState.bonusHistory.length && newState.bonusHistory.last == GameBonus.dashNest; + final gainedBonusBall = + (previousState?.bonusBalls ?? 0) < newState.bonusBalls; + + return gainedBonus && gainedBonusBall; } @override