Apply suggestions from code review

Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
pull/35/head
Erick 4 years ago committed by GitHub
parent 3787a12bb0
commit 6889a47e59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -50,7 +50,7 @@ class GameState extends Equatable {
bool get isLastBall => balls == 1;
/// Shortcut method to check if the given [i]
/// is activated on the state
/// is activated.
bool isLetterActivated(int i) =>
activatedBonusLetters.contains(i);

@ -8,9 +8,8 @@ import 'package:flutter/material.dart';
import 'package:pinball/game/game.dart';
/// {@template bonus_letter}
/// A pass through, [BodyType.static] component, part of
/// a word bonus, which will active its letter once a ball
/// pass through it
/// [BodyType.static] sensor component, part of a word bonus,
/// which will activate its letter after contact with a [Ball].
/// {@endtemplate}
class BonusLetter extends BodyComponent<PinballGame>
with BlocComponent<GameBloc, GameState> {
@ -25,7 +24,7 @@ class BonusLetter extends BodyComponent<PinballGame>
paint = Paint()..color = _disableColor;
}
/// The area size of this bonus letter
/// The area size of this [BonusLetter].
static final areaSize = Vector2.all(4);
static const _activeColor = Colors.green;
@ -76,18 +75,16 @@ class BonusLetter extends BodyComponent<PinballGame>
void onNewState(GameState state) {
final isActive = state.isLetterActivated(_index);
final color = isActive ? _activeColor : _disableColor;
add(
ColorEffect(
color,
isActive ? _activeColor : _disableColor,
const Offset(0, 1),
EffectController(duration: 0.25),
),
);
}
/// When called, will activate this letter, if still not activated
/// Activates this [BonusLetter], if it's not already activated.
void activate() {
final isActive = state?.isLetterActivated(_index) ?? false;
if (!isActive) {
@ -96,8 +93,8 @@ class BonusLetter extends BodyComponent<PinballGame>
}
}
/// Handles contact for [Ball] and [BonusLetter], which trigger [BonusLetter]
/// activate method.
/// Triggers [activate] method when a [BonusLetter] and a [Ball] come in
/// contact.
class BonusLetterBallContactCallback
extends ContactCallback<Ball, BonusLetter> {
@override

@ -136,7 +136,7 @@ void main() {
);
tester.widgetTest(
"don't add BonusLetterActivated to GameBloc when is already activated",
"doesn't add BonusLetterActivated to GameBloc when already activated",
(game, tester) async {
const state = GameState(
score: 0,
@ -159,7 +159,7 @@ void main() {
);
tester.widgetTest(
'adds a ColorEffect when it gets activated',
'adds a ColorEffect',
(game, tester) async {
await game.ready();
await tester.pump();
@ -184,7 +184,7 @@ void main() {
);
tester.widgetTest(
'only listen when there an change on the letter status',
'only listens when there is a change on the letter status',
(game, tester) async {
await game.ready();
await tester.pump();

Loading…
Cancel
Save