1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Enum that represents the two different possible stone colors available on a standard Othello board.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub enum Stone {
Black,
White,
}
impl Stone {
/// Returns the opposite side of a standard Othello stone.
///
/// # Examples
/// ```rust
/// use magpie::othello::Stone;
///
/// assert_eq!(Stone::White, Stone::Black.flip());
/// ```
#[must_use]
pub fn flip(&self) -> Self {
match &self {
Self::Black => Self::White,
Self::White => Self::Black,
}
}
}