Skip to content

Commit

Permalink
Add file and rank getters to Coord
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Jul 31, 2024
1 parent bbcb028 commit 63f2b2b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/src/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ extension type const Square._(int value) implements int {
];
}

/// Zero-based numeric chessboard coordinate.
/// Zero-based numeric chessboard coordinates.
///
/// For instance a1 is (0, 0), a2 is (0, 1), etc.
extension type const Coord._((int x, int y) value) {
Expand Down Expand Up @@ -436,6 +436,12 @@ extension type const Coord._((int x, int y) value) {
value == (7, 6) ||
value == (7, 7));

/// The file of the coordinates.
File get file => File(value.$1);

/// The rank of the coordinates.
Rank get rank => Rank(value.$2);

/// Gets the square from the coordinates.
Square get square => Square(value.$2 * 8 + value.$1);

Expand Down

0 comments on commit 63f2b2b

Please sign in to comment.