refactor: changed all ocurrences of scoretext to use score enum as value

pull/276/head
RuiAlonso 3 years ago
parent 4940afe62b
commit 9d8d5421fc

@ -16,17 +16,17 @@ class AndroidAcres extends Blueprint {
components: [
AndroidBumper.a(
children: [
ScoringBehavior(points: 20000),
ScoringBehavior(points: Score.points_20k),
],
)..initialPosition = Vector2(-25, 1.3),
AndroidBumper.b(
children: [
ScoringBehavior(points: 20000),
ScoringBehavior(points: Score.points_20k),
],
)..initialPosition = Vector2(-32.8, -9.2),
AndroidBumper.cow(
children: [
ScoringBehavior(points: 20),
ScoringBehavior(points: Score.points_20k),
],
)..initialPosition = Vector2(-20.5, -13.8),
],

@ -49,7 +49,7 @@ class _BottomGroupSide extends Component {
final kicker = Kicker(
side: _side,
children: [
ScoringBehavior(points: 5000),
ScoringBehavior(points: Score.points_5k),
],
)..initialPosition = Vector2(
(22.4 * direction) + centerXAdjustment,

@ -18,22 +18,22 @@ class FlutterForest extends Component {
children: [
Signpost(
children: [
ScoringBehavior(points: 20),
ScoringBehavior(points: Score.points_5k),
],
)..initialPosition = Vector2(8.35, -58.3),
DashNestBumper.main(
children: [
ScoringBehavior(points: 200000),
ScoringBehavior(points: Score.points_200k),
],
)..initialPosition = Vector2(18.55, -59.35),
DashNestBumper.a(
children: [
ScoringBehavior(points: 20000),
ScoringBehavior(points: Score.points_20k),
],
)..initialPosition = Vector2(8.95, -51.95),
DashNestBumper.b(
children: [
ScoringBehavior(points: 20000),
ScoringBehavior(points: Score.points_20k),
],
)..initialPosition = Vector2(23.3, -46.75),
DashAnimatronic()..position = Vector2(20, -66),

@ -15,27 +15,27 @@ class GoogleWord extends Component {
children: [
GoogleLetter(
0,
children: [ScoringBehavior(points: 5000)],
children: [ScoringBehavior(points: Score.points_5k)],
)..initialPosition = position + Vector2(-12.92, 1.82),
GoogleLetter(
1,
children: [ScoringBehavior(points: 5000)],
children: [ScoringBehavior(points: Score.points_5k)],
)..initialPosition = position + Vector2(-8.33, -0.65),
GoogleLetter(
2,
children: [ScoringBehavior(points: 5000)],
children: [ScoringBehavior(points: Score.points_5k)],
)..initialPosition = position + Vector2(-2.88, -1.75),
GoogleLetter(
3,
children: [ScoringBehavior(points: 5000)],
children: [ScoringBehavior(points: Score.points_5k)],
)..initialPosition = position + Vector2(2.88, -1.75),
GoogleLetter(
4,
children: [ScoringBehavior(points: 5000)],
children: [ScoringBehavior(points: Score.points_5k)],
)..initialPosition = position + Vector2(8.33, -0.65),
GoogleLetter(
5,
children: [ScoringBehavior(points: 5000)],
children: [ScoringBehavior(points: Score.points_5k)],
)..initialPosition = position + Vector2(12.92, 1.82),
GoogleWordBonusBehavior(),
],

@ -12,21 +12,21 @@ import 'package:pinball_flame/pinball_flame.dart';
class ScoringBehavior extends ContactBehavior with HasGameRef<PinballGame> {
/// {@macro scoring_behavior}
ScoringBehavior({
required int points,
required Score points,
}) : _points = points;
final int _points;
final Score _points;
@override
void beginContact(Object other, Contact contact) {
super.beginContact(other, contact);
if (other is! Ball) return;
gameRef.read<GameBloc>().add(Scored(points: _points));
gameRef.read<GameBloc>().add(Scored(points: _points.value));
gameRef.audio.score();
gameRef.add(
ScoreText(
text: _points.toString(),
score: _points,
position: other.body.position,
),
);

@ -18,17 +18,17 @@ class SparkyFireZone extends Blueprint {
components: [
SparkyBumper.a(
children: [
ScoringBehavior(points: 20000),
ScoringBehavior(points: Score.points_20k),
],
)..initialPosition = Vector2(-22.9, -41.65),
SparkyBumper.b(
children: [
ScoringBehavior(points: 20000),
ScoringBehavior(points: Score.points_20k),
],
)..initialPosition = Vector2(-21.25, -57.9),
SparkyBumper.c(
children: [
ScoringBehavior(points: 20000),
ScoringBehavior(points: Score.points_20k),
],
)..initialPosition = Vector2(-3.3, -52.55),
SparkyComputerSensor()..initialPosition = Vector2(-13, -49.8),
@ -51,7 +51,7 @@ class SparkyComputerSensor extends BodyComponent
: super(
renderBody: false,
children: [
ScoringBehavior(points: 200000),
ScoringBehavior(points: Score.points_20k),
],
);

@ -42,9 +42,10 @@ class BackboardGameOverGame extends AssetsGame
onSubmit: (initials) {
add(
ScoreText(
text: 'User $initials made $score',
score: Score.points_6m,
//text: 'User $initials made $score',
position: Vector2(0, 50),
color: Colors.pink,
//color: Colors.pink,
),
);
},

@ -21,10 +21,12 @@ class ScoreTextGame extends AssetsGame with TapDetector {
@override
void onTapUp(TapUpInfo info) {
final index = random.nextInt(Score.values.length);
final score = Score.values[index];
add(
ScoreText(
text: random.nextInt(100000).toString(),
color: Colors.white,
score: score,
position: info.eventPosition.game..multiply(Vector2(1, -1)),
),
);

@ -19,9 +19,8 @@ void main() {
game.camera.followVector2(Vector2.zero());
await game.ensureAdd(
ScoreText(
text: '123',
score: Score.points_6m,
position: Vector2.zero(),
color: Colors.white,
),
);
},
@ -37,9 +36,8 @@ void main() {
game.camera.followVector2(Vector2.zero());
await game.ensureAdd(
ScoreText(
text: '123',
score: Score.points_6m,
position: Vector2.zero(),
color: Colors.white,
),
);
@ -58,9 +56,8 @@ void main() {
game.camera.followVector2(Vector2.zero());
await game.ensureAdd(
ScoreText(
text: '123',
score: Score.points_6m,
position: Vector2.zero(),
color: Colors.white,
),
);

@ -56,7 +56,7 @@ void main() {
'emits Scored event with points',
setUp: (game, tester) async {
const points = 20;
final scoringBehavior = ScoringBehavior(points: points);
final scoringBehavior = ScoringBehavior(points: Score.points_6m);
await parent.add(scoringBehavior);
await game.ensureAdd(parent);
@ -74,7 +74,7 @@ void main() {
'plays score sound',
setUp: (game, tester) async {
const points = 20;
final scoringBehavior = ScoringBehavior(points: points);
final scoringBehavior = ScoringBehavior(points: Score.points_6m);
await parent.add(scoringBehavior);
await game.ensureAdd(parent);
@ -87,8 +87,7 @@ void main() {
flameBlocTester.testGameWidget(
"adds a ScoreText component at Ball's position with points",
setUp: (game, tester) async {
const points = 20;
final scoringBehavior = ScoringBehavior(points: points);
final scoringBehavior = ScoringBehavior(points: Score.points_6m);
await parent.add(scoringBehavior);
await game.ensureAdd(parent);
@ -98,8 +97,8 @@ void main() {
final scoreText = game.descendants().whereType<ScoreText>();
expect(scoreText.length, equals(1));
expect(
scoreText.first.text,
equals(points.toString()),
scoreText.first.score,
equals(Score.points_6m),
);
expect(
scoreText.first.position,

Loading…
Cancel
Save