refactor: alien to android (#246)
Co-authored-by: Alejandro Santiago <dev@alestiago.com>pull/249/head
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
@ -1,2 +0,0 @@
|
|||||||
export 'alien_bumper_ball_contact_behavior.dart';
|
|
||||||
export 'alien_bumper_blinking_behavior.dart';
|
|
@ -1,17 +0,0 @@
|
|||||||
// ignore_for_file: public_member_api_docs
|
|
||||||
|
|
||||||
import 'package:bloc/bloc.dart';
|
|
||||||
|
|
||||||
part 'alien_bumper_state.dart';
|
|
||||||
|
|
||||||
class AlienBumperCubit extends Cubit<AlienBumperState> {
|
|
||||||
AlienBumperCubit() : super(AlienBumperState.active);
|
|
||||||
|
|
||||||
void onBallContacted() {
|
|
||||||
emit(AlienBumperState.inactive);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onBlinked() {
|
|
||||||
emit(AlienBumperState.active);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
part of 'alien_bumper_cubit.dart';
|
|
||||||
|
|
||||||
/// Indicates the [AlienBumperCubit]'s current state.
|
|
||||||
enum AlienBumperState {
|
|
||||||
/// A lit up bumper.
|
|
||||||
active,
|
|
||||||
|
|
||||||
/// A dimmed bumper.
|
|
||||||
inactive,
|
|
||||||
}
|
|
@ -0,0 +1,2 @@
|
|||||||
|
export 'android_bumper_ball_contact_behavior.dart';
|
||||||
|
export 'android_bumper_blinking_behavior.dart';
|
@ -0,0 +1,17 @@
|
|||||||
|
// ignore_for_file: public_member_api_docs
|
||||||
|
|
||||||
|
import 'package:bloc/bloc.dart';
|
||||||
|
|
||||||
|
part 'android_bumper_state.dart';
|
||||||
|
|
||||||
|
class AndroidBumperCubit extends Cubit<AndroidBumperState> {
|
||||||
|
AndroidBumperCubit() : super(AndroidBumperState.dimmed);
|
||||||
|
|
||||||
|
void onBallContacted() {
|
||||||
|
emit(AndroidBumperState.dimmed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onBlinked() {
|
||||||
|
emit(AndroidBumperState.lit);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
// ignore_for_file: public_member_api_docs
|
||||||
|
|
||||||
|
part of 'android_bumper_cubit.dart';
|
||||||
|
|
||||||
|
enum AndroidBumperState {
|
||||||
|
lit,
|
||||||
|
dimmed,
|
||||||
|
}
|
@ -1,36 +0,0 @@
|
|||||||
import 'package:dashbook/dashbook.dart';
|
|
||||||
import 'package:sandbox/common/common.dart';
|
|
||||||
import 'package:sandbox/stories/alien_zone/alien_bumper_a_game.dart';
|
|
||||||
import 'package:sandbox/stories/alien_zone/alien_bumper_b_game.dart';
|
|
||||||
import 'package:sandbox/stories/alien_zone/spaceship_game.dart';
|
|
||||||
import 'package:sandbox/stories/alien_zone/spaceship_rail_game.dart';
|
|
||||||
import 'package:sandbox/stories/alien_zone/spaceship_ramp_game.dart';
|
|
||||||
|
|
||||||
void addAlienZoneStories(Dashbook dashbook) {
|
|
||||||
dashbook.storiesOf('Alien Zone')
|
|
||||||
..addGame(
|
|
||||||
title: 'Alien Bumper A',
|
|
||||||
description: AlienBumperAGame.description,
|
|
||||||
gameBuilder: (_) => AlienBumperAGame(),
|
|
||||||
)
|
|
||||||
..addGame(
|
|
||||||
title: 'Alien Bumper B',
|
|
||||||
description: AlienBumperBGame.description,
|
|
||||||
gameBuilder: (_) => AlienBumperBGame(),
|
|
||||||
)
|
|
||||||
..addGame(
|
|
||||||
title: 'Spaceship',
|
|
||||||
description: SpaceshipGame.description,
|
|
||||||
gameBuilder: (_) => SpaceshipGame(),
|
|
||||||
)
|
|
||||||
..addGame(
|
|
||||||
title: 'Spaceship Rail',
|
|
||||||
description: SpaceshipRailGame.description,
|
|
||||||
gameBuilder: (_) => SpaceshipRailGame(),
|
|
||||||
)
|
|
||||||
..addGame(
|
|
||||||
title: 'Spaceship Ramp',
|
|
||||||
description: SpaceshipRampGame.description,
|
|
||||||
gameBuilder: (_) => SpaceshipRampGame(),
|
|
||||||
);
|
|
||||||
}
|
|
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:dashbook/dashbook.dart';
|
||||||
|
import 'package:sandbox/common/common.dart';
|
||||||
|
import 'package:sandbox/stories/android_acres/android_bumper_a_game.dart';
|
||||||
|
import 'package:sandbox/stories/android_acres/android_bumper_b_game.dart';
|
||||||
|
import 'package:sandbox/stories/android_acres/spaceship_game.dart';
|
||||||
|
import 'package:sandbox/stories/android_acres/spaceship_rail_game.dart';
|
||||||
|
import 'package:sandbox/stories/android_acres/spaceship_ramp_game.dart';
|
||||||
|
|
||||||
|
void addAndroidAcresStories(Dashbook dashbook) {
|
||||||
|
dashbook.storiesOf('Android Acres')
|
||||||
|
..addGame(
|
||||||
|
title: 'Android Bumper A',
|
||||||
|
description: AndroidBumperAGame.description,
|
||||||
|
gameBuilder: (_) => AndroidBumperAGame(),
|
||||||
|
)
|
||||||
|
..addGame(
|
||||||
|
title: 'Android Bumper B',
|
||||||
|
description: AndroidBumperBGame.description,
|
||||||
|
gameBuilder: (_) => AndroidBumperBGame(),
|
||||||
|
)
|
||||||
|
..addGame(
|
||||||
|
title: 'Spaceship',
|
||||||
|
description: SpaceshipGame.description,
|
||||||
|
gameBuilder: (_) => SpaceshipGame(),
|
||||||
|
)
|
||||||
|
..addGame(
|
||||||
|
title: 'Spaceship Rail',
|
||||||
|
description: SpaceshipRailGame.description,
|
||||||
|
gameBuilder: (_) => SpaceshipRailGame(),
|
||||||
|
)
|
||||||
|
..addGame(
|
||||||
|
title: 'Spaceship Ramp',
|
||||||
|
description: SpaceshipRampGame.description,
|
||||||
|
gameBuilder: (_) => SpaceshipRampGame(),
|
||||||
|
);
|
||||||
|
}
|
@ -1,24 +0,0 @@
|
|||||||
import 'package:bloc_test/bloc_test.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:pinball_components/pinball_components.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
group(
|
|
||||||
'AlienBumperCubit',
|
|
||||||
() {
|
|
||||||
blocTest<AlienBumperCubit, AlienBumperState>(
|
|
||||||
'onBallContacted emits inactive',
|
|
||||||
build: AlienBumperCubit.new,
|
|
||||||
act: (bloc) => bloc.onBallContacted(),
|
|
||||||
expect: () => [AlienBumperState.inactive],
|
|
||||||
);
|
|
||||||
|
|
||||||
blocTest<AlienBumperCubit, AlienBumperState>(
|
|
||||||
'onBlinked emits active',
|
|
||||||
build: AlienBumperCubit.new,
|
|
||||||
act: (bloc) => bloc.onBlinked(),
|
|
||||||
expect: () => [AlienBumperState.active],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
@ -0,0 +1,24 @@
|
|||||||
|
import 'package:bloc_test/bloc_test.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pinball_components/pinball_components.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group(
|
||||||
|
'AndroidBumperCubit',
|
||||||
|
() {
|
||||||
|
blocTest<AndroidBumperCubit, AndroidBumperState>(
|
||||||
|
'onBallContacted emits dimmed',
|
||||||
|
build: AndroidBumperCubit.new,
|
||||||
|
act: (bloc) => bloc.onBallContacted(),
|
||||||
|
expect: () => [AndroidBumperState.dimmed],
|
||||||
|
);
|
||||||
|
|
||||||
|
blocTest<AndroidBumperCubit, AndroidBumperState>(
|
||||||
|
'onBlinked emits lit',
|
||||||
|
build: AndroidBumperCubit.new,
|
||||||
|
act: (bloc) => bloc.onBlinked(),
|
||||||
|
expect: () => [AndroidBumperState.lit],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
@ -1,48 +0,0 @@
|
|||||||
// ignore_for_file: cascade_invocations
|
|
||||||
|
|
||||||
import 'package:flame_test/flame_test.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:pinball/game/game.dart';
|
|
||||||
import 'package:pinball_components/pinball_components.dart';
|
|
||||||
import 'package:pinball_flame/pinball_flame.dart';
|
|
||||||
|
|
||||||
import '../../helpers/helpers.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
TestWidgetsFlutterBinding.ensureInitialized();
|
|
||||||
final assets = [
|
|
||||||
Assets.images.alienBumper.a.active.keyName,
|
|
||||||
Assets.images.alienBumper.a.inactive.keyName,
|
|
||||||
Assets.images.alienBumper.b.active.keyName,
|
|
||||||
Assets.images.alienBumper.b.inactive.keyName,
|
|
||||||
];
|
|
||||||
final flameTester = FlameTester(
|
|
||||||
() => EmptyPinballTestGame(assets: assets),
|
|
||||||
);
|
|
||||||
|
|
||||||
group('AlienZone', () {
|
|
||||||
flameTester.test(
|
|
||||||
'loads correctly',
|
|
||||||
(game) async {
|
|
||||||
await game.addFromBlueprint(AlienZone());
|
|
||||||
await game.ready();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
group('loads', () {
|
|
||||||
flameTester.test(
|
|
||||||
'two AlienBumper',
|
|
||||||
(game) async {
|
|
||||||
final alienZone = AlienZone();
|
|
||||||
await game.addFromBlueprint(alienZone);
|
|
||||||
await game.ready();
|
|
||||||
|
|
||||||
expect(
|
|
||||||
game.descendants().whereType<AlienBumper>().length,
|
|
||||||
equals(2),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
@ -0,0 +1,88 @@
|
|||||||
|
// ignore_for_file: cascade_invocations
|
||||||
|
|
||||||
|
import 'package:flame_test/flame_test.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pinball/game/game.dart';
|
||||||
|
import 'package:pinball_components/pinball_components.dart';
|
||||||
|
import 'package:pinball_flame/pinball_flame.dart';
|
||||||
|
|
||||||
|
import '../../helpers/helpers.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
final assets = [
|
||||||
|
Assets.images.spaceship.ramp.boardOpening.keyName,
|
||||||
|
Assets.images.spaceship.ramp.railingForeground.keyName,
|
||||||
|
Assets.images.spaceship.ramp.railingBackground.keyName,
|
||||||
|
Assets.images.spaceship.ramp.main.keyName,
|
||||||
|
Assets.images.spaceship.ramp.arrow.inactive.keyName,
|
||||||
|
Assets.images.spaceship.ramp.arrow.active1.keyName,
|
||||||
|
Assets.images.spaceship.ramp.arrow.active2.keyName,
|
||||||
|
Assets.images.spaceship.ramp.arrow.active3.keyName,
|
||||||
|
Assets.images.spaceship.ramp.arrow.active4.keyName,
|
||||||
|
Assets.images.spaceship.ramp.arrow.active5.keyName,
|
||||||
|
Assets.images.androidBumper.a.lit.keyName,
|
||||||
|
Assets.images.androidBumper.a.dimmed.keyName,
|
||||||
|
Assets.images.androidBumper.b.lit.keyName,
|
||||||
|
Assets.images.androidBumper.b.dimmed.keyName,
|
||||||
|
];
|
||||||
|
final flameTester = FlameTester(
|
||||||
|
() => EmptyPinballTestGame(assets: assets),
|
||||||
|
);
|
||||||
|
|
||||||
|
group('AndroidAcres', () {
|
||||||
|
flameTester.test(
|
||||||
|
'loads correctly',
|
||||||
|
(game) async {
|
||||||
|
await game.addFromBlueprint(AndroidAcres());
|
||||||
|
await game.ready();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
group('loads', () {
|
||||||
|
flameTester.test(
|
||||||
|
'a Spaceship',
|
||||||
|
(game) async {
|
||||||
|
expect(
|
||||||
|
AndroidAcres().blueprints.whereType<Spaceship>().single,
|
||||||
|
isNotNull,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
flameTester.test(
|
||||||
|
'a SpaceshipRamp',
|
||||||
|
(game) async {
|
||||||
|
expect(
|
||||||
|
AndroidAcres().blueprints.whereType<SpaceshipRamp>().single,
|
||||||
|
isNotNull,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
flameTester.test(
|
||||||
|
'a SpaceshipRail',
|
||||||
|
(game) async {
|
||||||
|
expect(
|
||||||
|
AndroidAcres().blueprints.whereType<SpaceshipRail>().single,
|
||||||
|
isNotNull,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
flameTester.test(
|
||||||
|
'two AndroidBumper',
|
||||||
|
(game) async {
|
||||||
|
final androidZone = AndroidAcres();
|
||||||
|
await game.addFromBlueprint(androidZone);
|
||||||
|
await game.ready();
|
||||||
|
|
||||||
|
expect(
|
||||||
|
game.descendants().whereType<AndroidBumper>().length,
|
||||||
|
equals(2),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|