diff --git a/lib/game/components/sparky_fire_zone.dart b/lib/game/components/sparky_fire_zone.dart index c71209f0..87d393f4 100644 --- a/lib/game/components/sparky_fire_zone.dart +++ b/lib/game/components/sparky_fire_zone.dart @@ -106,6 +106,6 @@ class SparkyComputerSensorBallContactCallback @override void begin(_, ControlledBall controlledBall, __) { controlledBall.controller.turboCharge(); - // ball.gameRef.firstChild()?.playing = true; + controlledBall.gameRef.firstChild()?.playing = true; } } diff --git a/lib/game/game_assets.dart b/lib/game/game_assets.dart index ec323b92..c1c0bf38 100644 --- a/lib/game/game_assets.dart +++ b/lib/game/game_assets.dart @@ -81,6 +81,8 @@ extension PinballGameAssetsX on PinballGame { images.load(components.Assets.images.chromeDino.mouth.keyName), images.load(components.Assets.images.chromeDino.head.keyName), images.load(components.Assets.images.sparky.computer.top.keyName), + images.load(components.Assets.images.sparky.computer.base.keyName), + images.load(components.Assets.images.sparky.animatronic.keyName), images.load(components.Assets.images.sparky.bumper.a.inactive.keyName), images.load(components.Assets.images.sparky.bumper.b.active.keyName), images.load(components.Assets.images.sparky.bumper.b.inactive.keyName), diff --git a/packages/pinball_components/lib/src/components/sparky_animatronic.dart b/packages/pinball_components/lib/src/components/sparky_animatronic.dart index a9f68723..714a5700 100644 --- a/packages/pinball_components/lib/src/components/sparky_animatronic.dart +++ b/packages/pinball_components/lib/src/components/sparky_animatronic.dart @@ -17,7 +17,7 @@ class SparkyAnimatronic extends SpriteAnimationComponent with HasGameRef { Future onLoad() async { await super.onLoad(); - final spriteSheet = await gameRef.images.load( + final spriteSheet = gameRef.images.fromCache( Assets.images.sparky.animatronic.keyName, ); diff --git a/test/game/components/sparky_fire_zone_test.dart b/test/game/components/sparky_fire_zone_test.dart index bc47106a..1d0eada2 100644 --- a/test/game/components/sparky_fire_zone_test.dart +++ b/test/game/components/sparky_fire_zone_test.dart @@ -21,6 +21,7 @@ void main() { Assets.images.sparky.bumper.b.inactive.keyName, Assets.images.sparky.bumper.c.active.keyName, Assets.images.sparky.bumper.c.inactive.keyName, + Assets.images.sparky.animatronic.keyName, ]; final flameTester = FlameTester(() => EmptyPinballTestGame(assets)); @@ -128,36 +129,39 @@ void main() { }); }); - group( - 'SparkyTurboChargeSensorBallContactCallback', - () { - // TODO(alestiago): Make tests pass. - flameTester.test('calls turboCharge', (game) async { - final callback = SparkyComputerSensorBallContactCallback(); - final ball = MockControlledBall(); - when(() => ball.controller).thenReturn(MockBallController()); - when(() => ball.gameRef).thenReturn(game); + group('SparkyTurboChargeSensorBallContactCallback', () { + flameTester.test('calls turboCharge', (game) async { + final callback = SparkyComputerSensorBallContactCallback(); + final ball = MockControlledBall(); + final controller = MockBallController(); + when(() => ball.controller).thenReturn(controller); + when(() => ball.gameRef).thenReturn(game); + when(controller.turboCharge).thenAnswer((_) async {}); - await game.ready(); - callback.begin(MockSparkyComputerSensor(), ball, MockContact()); + callback.begin(MockSparkyComputerSensor(), ball, MockContact()); - verify(() => ball.controller.turboCharge()).called(1); - }); + verify(() => ball.controller.turboCharge()).called(1); + }); - flameTester.test('plays DashAnimatronic', (game) async { - final callback = SparkyComputerSensorBallContactCallback(); - final ball = MockControlledBall(); - when(() => ball.gameRef).thenReturn(game); - when(() => ball.controller).thenReturn(MockBallController()); - final dashAnimatronic = DashAnimatronic(); - await game.ensureAdd(dashAnimatronic); + flameTester.test('plays SparkyAnimatronic', (game) async { + final callback = SparkyComputerSensorBallContactCallback(); + final ball = MockControlledBall(); + final controller = MockBallController(); + when(() => ball.controller).thenReturn(controller); + when(() => ball.gameRef).thenReturn(game); + when(controller.turboCharge).thenAnswer((_) async {}); - expect(dashAnimatronic.playing, isFalse); - callback.begin(MockSparkyComputerSensor(), ball, MockContact()); - await game.ready(); + final sparkyFireZone = SparkyFireZone(); + await game.addFromBlueprint(sparkyFireZone); + await game.ready(); - expect(dashAnimatronic.playing, isTrue); - }); - }, - ); + final sparkyAnimatronic = + game.descendants().whereType().single; + + expect(sparkyAnimatronic.playing, isFalse); + callback.begin(MockSparkyComputerSensor(), ball, MockContact()); + + expect(sparkyAnimatronic.playing, isTrue); + }); + }); } diff --git a/test/game/pinball_game_test.dart b/test/game/pinball_game_test.dart index ebdcd3a0..ba997078 100644 --- a/test/game/pinball_game_test.dart +++ b/test/game/pinball_game_test.dart @@ -33,6 +33,7 @@ void main() { Assets.images.sparky.bumper.b.inactive.keyName, Assets.images.sparky.bumper.c.active.keyName, Assets.images.sparky.bumper.c.inactive.keyName, + Assets.images.sparky.animatronic.keyName, Assets.images.spaceship.ramp.boardOpening.keyName, Assets.images.spaceship.ramp.railingForeground.keyName, Assets.images.spaceship.ramp.railingBackground.keyName,