diff --git a/lib/game/components/ball.dart b/lib/game/components/ball.dart index daf5be63..42842f17 100644 --- a/lib/game/components/ball.dart +++ b/lib/game/components/ball.dart @@ -65,6 +65,10 @@ class Ball extends PositionBodyComponent { } } + /// Modifies maskBits of [Ball] for collisions. + /// + /// Changes the [Filter] data for category and maskBits of the [Ball] to + /// collide with other objects of same bits and ignore others. void setMaskBits(int maskBits) { body.fixtures.first ..filterData.categoryBits = maskBits diff --git a/lib/game/components/crossing_ramp.dart b/lib/game/components/crossing_ramp.dart index 83af9b1a..25bed457 100644 --- a/lib/game/components/crossing_ramp.dart +++ b/lib/game/components/crossing_ramp.dart @@ -53,6 +53,7 @@ extension RampTypeX on RampType { /// Collisions with [RampArea] are listened by [RampAreaCallback]. /// {@endtemplate} abstract class RampArea extends BodyComponent { + /// {@macro ramp_area} RampArea({ required Vector2 position, required int categoryBits, @@ -65,8 +66,13 @@ abstract class RampArea extends BodyComponent { final Vector2 _position; final int _categoryBits; + /// Mask of category bits for collision with [RampArea] int get categoryBits => _categoryBits; + + /// The [Shape] of the [RampArea] Shape get shape; + + /// Orientation of the [RampArea] entrance/exit RampOrientation get orientation; @override diff --git a/lib/game/components/jetpack_ramp.dart b/lib/game/components/jetpack_ramp.dart index 78102f8e..c53dc4d2 100644 --- a/lib/game/components/jetpack_ramp.dart +++ b/lib/game/components/jetpack_ramp.dart @@ -11,6 +11,7 @@ import 'package:pinball/game/game.dart'; /// a ball gets into/out of the ramp. /// {@endtemplate} class JetpackRamp extends PositionComponent with HasGameRef { + /// {@macro jetpack_ramp} JetpackRamp({ required Vector2 position, }) : _position = position, @@ -64,6 +65,7 @@ class JetpackRamp extends PositionComponent with HasGameRef { /// inside [JetpackRamp]. /// {@endtemplate} class JetpackRampArea extends RampArea { + /// {@macro jetpack_ramp_area} JetpackRampArea({ required Vector2 position, double rotation = 0, diff --git a/lib/game/components/sparky_ramp.dart b/lib/game/components/sparky_ramp.dart index dfac15fd..19690371 100644 --- a/lib/game/components/sparky_ramp.dart +++ b/lib/game/components/sparky_ramp.dart @@ -1,4 +1,3 @@ -import 'dart:math' as math; import 'package:flame/components.dart'; import 'package:flame/extensions.dart'; import 'package:flame_forge2d/flame_forge2d.dart'; @@ -12,6 +11,7 @@ import 'package:pinball/game/game.dart'; /// a ball gets into/out of the ramp. /// {@endtemplate} class SparkyRamp extends PositionComponent with HasGameRef { + /// {@macro sparky_ramp} SparkyRamp({ required Vector2 position, }) : _position = position, @@ -59,6 +59,7 @@ class SparkyRamp extends PositionComponent with HasGameRef { /// inside [SparkyRamp]. /// {@endtemplate} class SparkyRampArea extends RampArea { + /// {@macro sparky_ramp_area} SparkyRampArea({ required Vector2 position, double rotation = 0, @@ -99,6 +100,7 @@ class SparkyRampArea extends RampArea { /// gets into a [SparkyRampArea]. /// {@endtemplate} class SparkyRampAreaCallback extends RampAreaCallback { + /// {@macro sparky_ramp_area_callback} SparkyRampAreaCallback() : super(); /// Collection of balls inside [SparkyRamp]. diff --git a/tool/coverage.sh b/tool/coverage.sh new file mode 100755 index 00000000..e34b0124 --- /dev/null +++ b/tool/coverage.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# This script can be used to run flutter test for a given directory (defaults to the current directory) +# It will exclude generated code and translations (mimicking the ci) and open the coverage report in a +# new window once it has run successfully. +# +# To run in main project: +# ./tool/coverage.sh +# +# To run in other directory: +# ./tool/coverage.sh ./path/to/other/project + +set -e + +PROJECT_PATH="${1:-.}" +PROJECT_COVERAGE=./coverage/lcov.info + +cd ${PROJECT_PATH} + +rm -rf coverage +if grep -q "flutter:" pubspec.yaml; then + flutter --version + flutter test --no-pub --test-randomize-ordering-seed random --coverage -j 28 +else + dart --version + dart test --coverage=coverage && dart run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.packages --report-on=lib +fi +lcov --remove ${PROJECT_COVERAGE} -o ${PROJECT_COVERAGE} \ + '**/*.g.dart' \ + '**/l10n/*.dart' \ + '**/l10n/**/*.dart' \ + '**/main/bootstrap.dart' \ + '**/*.gen.dart' +genhtml ${PROJECT_COVERAGE} -o coverage | tee ./coverage/output.txt + +COV_LINE=$(tail -2 ./coverage/output.txt | head -1) +SUB='100.0%' + +if [[ "$COV_LINE" == *"$SUB"* ]]; then + echo "The coverage is 100%" +else + echo "Coverage is below 100%! Check the report to see which lines are not covered." + echo $COV_LINE + open ./coverage/index.html +fi