From a5b05f0ac8da0ec182f48d2de843882bbb9ed27d Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Mon, 9 May 2022 11:15:32 +0200 Subject: [PATCH] refactor: ramp bonus listen when refactored --- .../android_acres/behaviors/ramp_bonus_behavior.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/game/components/android_acres/behaviors/ramp_bonus_behavior.dart b/lib/game/components/android_acres/behaviors/ramp_bonus_behavior.dart index b4fe80a0..f273319c 100644 --- a/lib/game/components/android_acres/behaviors/ramp_bonus_behavior.dart +++ b/lib/game/components/android_acres/behaviors/ramp_bonus_behavior.dart @@ -23,10 +23,13 @@ class RampBonusBehavior extends Component with ParentIsA { await super.onLoad(); await add( FlameBlocListener( - listenWhen: (previousState, newState) => - previousState.hits != newState.hits && - newState.hits != 0 && - newState.hits % 10 == 0, + listenWhen: (previousState, newState) { + final hasChanged = previousState.hits != newState.hits; + final hasHit = newState.hits != 0; + final achievedOneMillionPoints = newState.hits % 10 == 0; + + return hasChanged && hasHit && achievedOneMillionPoints; + }, onNewState: (state) { parent.add( ScoringBehavior(