From 17546026341704c7bd4fc4a44b51d0638e9e0c74 Mon Sep 17 00:00:00 2001 From: Erick Date: Mon, 14 Mar 2022 13:36:45 -0300 Subject: [PATCH 1/3] feat: adding bonus score to the user when they complete the bonus (#36) * feat: adding bonus score to the user when they complete the bonus * feat: pr suggestions --- lib/game/bloc/game_bloc.dart | 2 ++ test/game/bloc/game_bloc_test.dart | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib/game/bloc/game_bloc.dart b/lib/game/bloc/game_bloc.dart index 74685215..663fee35 100644 --- a/lib/game/bloc/game_bloc.dart +++ b/lib/game/bloc/game_bloc.dart @@ -15,6 +15,7 @@ class GameBloc extends Bloc { } static const bonusWord = 'GOOGLE'; + static const bonusWordScore = 10000; void _onBallLost(BallLost event, Emitter emit) { if (state.balls > 0) { @@ -44,6 +45,7 @@ class GameBloc extends Bloc { ], ), ); + add(const Scored(points: bonusWordScore)); } else { emit( state.copyWith(activatedBonusLetters: newBonusLetters), diff --git a/test/game/bloc/game_bloc_test.dart b/test/game/bloc/game_bloc_test.dart index ad1d6c55..18e50858 100644 --- a/test/game/bloc/game_bloc_test.dart +++ b/test/game/bloc/game_bloc_test.dart @@ -177,6 +177,12 @@ void main() { activatedBonusLetters: [], bonusHistory: [GameBonus.word], ), + GameState( + score: GameBloc.bonusWordScore, + balls: 3, + activatedBonusLetters: [], + bonusHistory: [GameBonus.word], + ), ], ); }); From 2671ec40201903b5541ccfc201fe59f34d84fcdf Mon Sep 17 00:00:00 2001 From: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Date: Mon, 14 Mar 2022 12:13:44 -0500 Subject: [PATCH 2/3] chore: anchor plunger internally (#43) * chore: anchor plunger internally * chore: remove group * Update lib/game/components/plunger.dart Co-authored-by: Alejandro Santiago Co-authored-by: Alejandro Santiago --- lib/game/components/plunger.dart | 19 +++++++++++++++++++ lib/game/pinball_game.dart | 9 --------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/game/components/plunger.dart b/lib/game/components/plunger.dart index bf63b462..9bcde451 100644 --- a/lib/game/components/plunger.dart +++ b/lib/game/components/plunger.dart @@ -74,6 +74,25 @@ class Plunger extends BodyComponent with KeyboardHandler { return true; } + + /// Anchors the [Plunger] to the [PrismaticJoint] that controls its vertical + /// motion. + Future _anchorToJoint() async { + final anchor = PlungerAnchor(plunger: this); + await add(anchor); + + final jointDef = PlungerAnchorPrismaticJointDef( + plunger: this, + anchor: anchor, + ); + world.createJoint(jointDef); + } + + @override + Future onLoad() async { + await super.onLoad(); + await _anchorToJoint(); + } } /// {@template plunger_anchor} diff --git a/lib/game/pinball_game.dart b/lib/game/pinball_game.dart index 633c2351..b67a8dad 100644 --- a/lib/game/pinball_game.dart +++ b/lib/game/pinball_game.dart @@ -101,7 +101,6 @@ class PinballGame extends Forge2DGame } Future _addPlunger() async { - late PlungerAnchor plungerAnchor; final compressionDistance = camera.viewport.effectiveSize.y / 12; await add( @@ -115,14 +114,6 @@ class PinballGame extends Forge2DGame compressionDistance: compressionDistance, ), ); - await add(plungerAnchor = PlungerAnchor(plunger: plunger)); - - world.createJoint( - PlungerAnchorPrismaticJointDef( - plunger: plunger, - anchor: plungerAnchor, - ), - ); } Future _addBaseboards() async { From b22705aaf6c1f5004b1203fd78cf1d1563c066e7 Mon Sep 17 00:00:00 2001 From: Erick Date: Mon, 14 Mar 2022 15:00:31 -0300 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> --- test/game/components/bonus_word_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/game/components/bonus_word_test.dart b/test/game/components/bonus_word_test.dart index 8d3eb0b1..145e6dd0 100644 --- a/test/game/components/bonus_word_test.dart +++ b/test/game/components/bonus_word_test.dart @@ -29,7 +29,7 @@ void main() { group('listenWhen', () { test( - 'returns true when there is a new bonus word awarded', + 'returns true when there is a new word bonus awarded', () { final previousState = MockGameState(); when(() => previousState.bonusHistory).thenReturn([]); @@ -48,7 +48,7 @@ void main() { ); test( - 'returns false when there is no new bonus word awarded', + 'returns false when there is no new word bonus awarded', () { final previousState = MockGameState(); when(() => previousState.bonusHistory).thenReturn([GameBonus.word]);