summaryrefslogtreecommitdiff
path: root/model/src/coordinates.rs
diff options
context:
space:
mode:
authorMike White <botahamec@outlook.com>2021-08-27 20:46:18 -0400
committerMike White <botahamec@outlook.com>2021-08-27 20:46:18 -0400
commita310274c6d5acea8f5f83f2feb8699e7b312f8e3 (patch)
tree9424e380512df43e64a50ad0824375d7f23b3c25 /model/src/coordinates.rs
parent68014734561c3a8d8712916bdfa58b8347131501 (diff)
Highlighted possible moves when a piece is clicked
Diffstat (limited to 'model/src/coordinates.rs')
-rw-r--r--model/src/coordinates.rs10
1 files changed, 9 insertions, 1 deletions
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<usize> {
if self.rank % 2 == 0 {
if self.file % 2 == 0 {