From 47877c97cdbffb48bbd00c1384b925333b638b38 Mon Sep 17 00:00:00 2001 From: alestiago Date: Tue, 15 Mar 2022 08:54:27 +0000 Subject: [PATCH] feat: implemented BoardSide.direction --- lib/game/components/board_side.dart | 5 +++++ test/game/components/board_side_test.dart | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/lib/game/components/board_side.dart b/lib/game/components/board_side.dart index 611f70b8..2ec5a03e 100644 --- a/lib/game/components/board_side.dart +++ b/lib/game/components/board_side.dart @@ -19,4 +19,9 @@ extension BoardSideX on BoardSide { /// Whether this side is [BoardSide.right]. bool get isRight => this == BoardSide.right; + + /// Direction of the [BoardSide]. + /// + /// Represents the line along the [BoardSide] moves. + int get direction => isLeft ? -1 : 1; } diff --git a/test/game/components/board_side_test.dart b/test/game/components/board_side_test.dart index 3d6d3fa1..ba201065 100644 --- a/test/game/components/board_side_test.dart +++ b/test/game/components/board_side_test.dart @@ -23,5 +23,12 @@ void main() { expect(side.isLeft, isFalse); expect(side.isRight, isTrue); }); + + test('direction is correct', () { + const side = BoardSide.left; + expect(side.direction, equals(-1)); + const side2 = BoardSide.right; + expect(side2.direction, equals(1)); + }); }); }