refactor: changed listenWhen conditions

pull/416/head
RuiAlonso 3 years ago
parent 27c488354c
commit 4aa555cebc

@ -23,11 +23,10 @@ class RampBonusBehavior extends Component
SpaceshipRampState previousState,
SpaceshipRampState newState,
) {
final hasChanged = previousState.hits != newState.hits;
final hasHit = newState.hits != 0;
final hitsIncreased = previousState.hits < newState.hits;
final achievedOneMillionPoints = newState.hits % 10 == 0;
return hasChanged && hasHit && achievedOneMillionPoints;
return hitsIncreased && achievedOneMillionPoints;
}
@override

@ -13,11 +13,10 @@ class RampMultiplierBehavior extends Component
SpaceshipRampState previousState,
SpaceshipRampState newState,
) {
final hasChanged =
previousState.hits != newState.hits && newState.hits != 0;
final hitsIncreased = previousState.hits < newState.hits;
final achievedFiveShots = newState.hits % 5 == 0;
final canIncrease = readBloc<GameBloc, GameState>().state.multiplier != 6;
return hasChanged && achievedFiveShots && canIncrease;
return hitsIncreased & achievedFiveShots && canIncrease;
}
@override

@ -12,7 +12,7 @@ class RampProgressBehavior extends Component
SpaceshipRampState previousState,
SpaceshipRampState newState,
) {
return previousState.hits != newState.hits && newState.hits != 0;
return previousState.hits < newState.hits;
}
@override

@ -23,7 +23,7 @@ class RampShotBehavior extends Component
SpaceshipRampState previousState,
SpaceshipRampState newState,
) {
return previousState.hits != newState.hits && newState.hits != 0;
return previousState.hits < newState.hits;
}
@override

@ -103,9 +103,7 @@ void main() {
);
},
);
});
group('adds', () {
flameTester.test('new children', (game) async {
final component = Component();
final ramp = SpaceshipRamp(children: [component]);

Loading…
Cancel
Save