From a310274c6d5acea8f5f83f2feb8699e7b312f8e3 Mon Sep 17 00:00:00 2001 From: Mike White Date: Fri, 27 Aug 2021 20:46:18 -0400 Subject: Highlighted possible moves when a piece is clicked --- model/src/coordinates.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'model/src/coordinates.rs') diff --git a/model/src/coordinates.rs b/model/src/coordinates.rs index a055f46..7aea88b 100644 --- a/model/src/coordinates.rs +++ b/model/src/coordinates.rs @@ -7,7 +7,7 @@ pub struct SquareCoordinate { } impl SquareCoordinate { - pub(crate) fn new(rank: u8, file: u8) -> Self { + pub fn new(rank: u8, file: u8) -> Self { if rank > 32 { panic!("A Square cannot have a rank greater than 32. Got {}", rank) } else if file > 32 { @@ -56,6 +56,14 @@ impl SquareCoordinate { VALUE_COORDINATE_MAP[value] } + pub fn rank(self) -> u8 { + self.rank + } + + pub fn file(self) -> u8 { + self.file + } + pub fn to_value(self) -> Option { if self.rank % 2 == 0 { if self.file % 2 == 0 { -- cgit v1.2.3