diff --git a/lib/game/bloc/game_bloc.dart b/lib/game/bloc/game_bloc.dart index ec08d90a..7c1b4f44 100644 --- a/lib/game/bloc/game_bloc.dart +++ b/lib/game/bloc/game_bloc.dart @@ -13,7 +13,6 @@ class GameBloc extends Bloc { on(_onScored); on(_onBonusLetterActivated); on(_onDashNestActivated); - on(_onSparkyFireActivated); } static const bonusWord = 'GOOGLE'; @@ -78,23 +77,4 @@ class GameBloc extends Bloc { ); } } - - void _onSparkyFireActivated(SparkyFireActivated event, Emitter emit) { - var newFires = {}; - - if (state.activatedSparkyFires.contains(event.fireId)) { - newFires = state.activatedSparkyFires.difference({event.fireId}); - } else { - newFires = { - ...state.activatedSparkyFires, - event.fireId, - }; - } - - emit( - state.copyWith( - activatedSparkyFires: newFires, - ), - ); - } } diff --git a/lib/game/bloc/game_event.dart b/lib/game/bloc/game_event.dart index fc5dcdb6..b05c5336 100644 --- a/lib/game/bloc/game_event.dart +++ b/lib/game/bloc/game_event.dart @@ -54,12 +54,3 @@ class DashNestActivated extends GameEvent { @override List get props => [nestId]; } - -class SparkyFireActivated extends GameEvent { - const SparkyFireActivated(this.fireId); - - final String fireId; - - @override - List get props => [fireId]; -} diff --git a/lib/game/bloc/game_state.dart b/lib/game/bloc/game_state.dart index ae9faa96..bbaa4cd8 100644 --- a/lib/game/bloc/game_state.dart +++ b/lib/game/bloc/game_state.dart @@ -23,7 +23,6 @@ class GameState extends Equatable { required this.activatedBonusLetters, required this.bonusHistory, required this.activatedDashNests, - required this.activatedSparkyFires, }) : assert(score >= 0, "Score can't be negative"), assert(balls >= 0, "Number of balls can't be negative"); @@ -32,7 +31,6 @@ class GameState extends Equatable { balls = 3, activatedBonusLetters = const [], activatedDashNests = const {}, - activatedSparkyFires = const {}, bonusHistory = const []; /// The current score of the game. @@ -49,9 +47,6 @@ class GameState extends Equatable { /// Active dash nests. final Set activatedDashNests; - /// Active sparky fires. - final Set activatedSparkyFires; - /// Holds the history of all the [GameBonus]es earned by the player during a /// PinballGame. final List bonusHistory; @@ -68,7 +63,6 @@ class GameState extends Equatable { int? balls, List? activatedBonusLetters, Set? activatedDashNests, - Set? activatedSparkyFires, List? bonusHistory, }) { assert( @@ -82,7 +76,6 @@ class GameState extends Equatable { activatedBonusLetters: activatedBonusLetters ?? this.activatedBonusLetters, activatedDashNests: activatedDashNests ?? this.activatedDashNests, - activatedSparkyFires: activatedSparkyFires ?? this.activatedSparkyFires, bonusHistory: bonusHistory ?? this.bonusHistory, ); } @@ -93,7 +86,6 @@ class GameState extends Equatable { balls, activatedBonusLetters, activatedDashNests, - activatedSparkyFires, bonusHistory, ]; } diff --git a/test/game/bloc/game_bloc_test.dart b/test/game/bloc/game_bloc_test.dart index 4df534b3..5636bdf4 100644 --- a/test/game/bloc/game_bloc_test.dart +++ b/test/game/bloc/game_bloc_test.dart @@ -25,7 +25,6 @@ void main() { balls: 2, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), ], @@ -46,7 +45,6 @@ void main() { balls: 3, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), const GameState( @@ -54,7 +52,6 @@ void main() { balls: 3, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), ], @@ -76,7 +73,6 @@ void main() { balls: 2, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), const GameState( @@ -84,7 +80,6 @@ void main() { balls: 1, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), const GameState( @@ -92,7 +87,6 @@ void main() { balls: 0, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), ], @@ -113,7 +107,6 @@ void main() { balls: 3, activatedBonusLetters: [0], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), GameState( @@ -121,7 +114,6 @@ void main() { balls: 3, activatedBonusLetters: [0, 1], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), GameState( @@ -129,7 +121,6 @@ void main() { balls: 3, activatedBonusLetters: [0, 1, 2], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), ], @@ -151,7 +142,6 @@ void main() { balls: 3, activatedBonusLetters: [0], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), GameState( @@ -159,7 +149,6 @@ void main() { balls: 3, activatedBonusLetters: [0, 1], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), GameState( @@ -167,7 +156,6 @@ void main() { balls: 3, activatedBonusLetters: [0, 1, 2], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), GameState( @@ -175,7 +163,6 @@ void main() { balls: 3, activatedBonusLetters: [0, 1, 2, 3], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), GameState( @@ -183,7 +170,6 @@ void main() { balls: 3, activatedBonusLetters: [0, 1, 2, 3, 4], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), GameState( @@ -191,7 +177,6 @@ void main() { balls: 3, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [GameBonus.word], ), GameState( @@ -199,7 +184,6 @@ void main() { balls: 3, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [GameBonus.word], ), ], @@ -220,7 +204,6 @@ void main() { balls: 3, activatedBonusLetters: [], activatedDashNests: {'0'}, - activatedSparkyFires: {}, bonusHistory: [], ), GameState( @@ -228,7 +211,6 @@ void main() { balls: 3, activatedBonusLetters: [], activatedDashNests: {'0', '1'}, - activatedSparkyFires: {}, bonusHistory: [], ), GameState( @@ -236,45 +218,10 @@ void main() { balls: 4, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [GameBonus.dashNest], ), ], ); }); - - group('SparkyFireActivated', () { - const fireId = '0'; - - blocTest( - 'adds fireId to collection when activate', - build: GameBloc.new, - act: (bloc) => bloc..add(const SparkyFireActivated(fireId)), - expect: () => [ - isA() - ..having( - (state) => state.activatedSparkyFires, - 'activatedSparkyFires', - contains(fireId), - ), - ], - ); - - blocTest( - 'removes fireId from collection when deactivate', - build: GameBloc.new, - seed: () => - GameState.initial().copyWith(activatedSparkyFires: {fireId}), - act: (bloc) => bloc..add(const SparkyFireActivated(fireId)), - expect: () => [ - isA() - ..having( - (state) => state.activatedSparkyFires, - 'activatedSparkyFires', - isNot(contains(fireId)), - ), - ], - ); - }); }); } diff --git a/test/game/bloc/game_event_test.dart b/test/game/bloc/game_event_test.dart index 8d0d622b..af9f6148 100644 --- a/test/game/bloc/game_event_test.dart +++ b/test/game/bloc/game_event_test.dart @@ -84,22 +84,5 @@ void main() { ); }); }); - - group('SparkyFireActivated', () { - test('can be instantiated', () { - expect(const SparkyFireActivated('0'), isNotNull); - }); - - test('supports value equality', () { - expect( - SparkyFireActivated('0'), - equals(SparkyFireActivated('0')), - ); - expect( - SparkyFireActivated('0'), - isNot(equals(SparkyFireActivated('1'))), - ); - }); - }); }); } diff --git a/test/game/bloc/game_state_test.dart b/test/game/bloc/game_state_test.dart index cd897291..ed80d192 100644 --- a/test/game/bloc/game_state_test.dart +++ b/test/game/bloc/game_state_test.dart @@ -12,7 +12,6 @@ void main() { balls: 0, activatedBonusLetters: const [], activatedDashNests: const {}, - activatedSparkyFires: const {}, bonusHistory: const [], ), equals( @@ -21,7 +20,6 @@ void main() { balls: 0, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), ), @@ -36,7 +34,6 @@ void main() { balls: 0, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ), isNotNull, @@ -54,7 +51,6 @@ void main() { score: 0, activatedBonusLetters: const [], activatedDashNests: const {}, - activatedSparkyFires: const {}, bonusHistory: const [], ), throwsAssertionError, @@ -72,7 +68,6 @@ void main() { score: -1, activatedBonusLetters: const [], activatedDashNests: const {}, - activatedSparkyFires: const {}, bonusHistory: const [], ), throwsAssertionError, @@ -89,7 +84,6 @@ void main() { score: 0, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ); expect(gameState.isGameOver, isTrue); @@ -103,7 +97,6 @@ void main() { score: 0, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ); expect(gameState.isGameOver, isFalse); @@ -119,7 +112,6 @@ void main() { score: 0, activatedBonusLetters: [1], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ); expect(gameState.isLetterActivated(1), isTrue); @@ -134,7 +126,6 @@ void main() { score: 0, activatedBonusLetters: [1], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ); expect(gameState.isLetterActivated(0), isFalse); @@ -152,7 +143,6 @@ void main() { score: 2, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ); expect( @@ -171,7 +161,6 @@ void main() { score: 2, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ); expect( @@ -190,7 +179,6 @@ void main() { balls: 0, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ); final otherGameState = GameState( @@ -198,7 +186,6 @@ void main() { balls: gameState.balls + 1, activatedBonusLetters: const [0], activatedDashNests: const {'1'}, - activatedSparkyFires: const {'1'}, bonusHistory: const [GameBonus.word], ); expect(gameState, isNot(equals(otherGameState))); @@ -209,7 +196,6 @@ void main() { balls: otherGameState.balls, activatedBonusLetters: otherGameState.activatedBonusLetters, activatedDashNests: otherGameState.activatedDashNests, - activatedSparkyFires: otherGameState.activatedSparkyFires, bonusHistory: otherGameState.bonusHistory, ), equals(otherGameState), diff --git a/test/game/components/bonus_word_test.dart b/test/game/components/bonus_word_test.dart index 8faacaad..f01fced9 100644 --- a/test/game/components/bonus_word_test.dart +++ b/test/game/components/bonus_word_test.dart @@ -264,7 +264,6 @@ void main() { balls: 2, activatedBonusLetters: [0], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ); whenListen( @@ -293,7 +292,6 @@ void main() { balls: 2, activatedBonusLetters: [0], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ); @@ -337,7 +335,6 @@ void main() { balls: 2, activatedBonusLetters: [index], activatedDashNests: const {}, - activatedSparkyFires: const {}, bonusHistory: const [], ); diff --git a/test/game/components/flutter_forest_test.dart b/test/game/components/flutter_forest_test.dart index 10727ffb..d85fe54f 100644 --- a/test/game/components/flutter_forest_test.dart +++ b/test/game/components/flutter_forest_test.dart @@ -88,7 +88,6 @@ void main() { balls: 3, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [GameBonus.dashNest], ); diff --git a/test/game/view/game_hud_test.dart b/test/game/view/game_hud_test.dart index c42f8855..953b89eb 100644 --- a/test/game/view/game_hud_test.dart +++ b/test/game/view/game_hud_test.dart @@ -14,7 +14,6 @@ void main() { balls: 2, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], ); diff --git a/test/game/view/pinball_game_page_test.dart b/test/game/view/pinball_game_page_test.dart index 8cad17ed..f16b8ef1 100644 --- a/test/game/view/pinball_game_page_test.dart +++ b/test/game/view/pinball_game_page_test.dart @@ -89,7 +89,6 @@ void main() { balls: 0, activatedBonusLetters: [], activatedDashNests: {}, - activatedSparkyFires: {}, bonusHistory: [], );