Struct shogi::Piece
[−]
[src]
pub struct Piece {
pub piece_type: PieceType,
pub color: Color,
}Represents a piece on the game board.
Fields
piece_type: PieceType
color: Color
Methods
impl Piece[src]
fn from_sfen(c: char) -> Option<Piece>
Creates a new instance of Piece from SFEN formatted string.
fn promote(&self) -> Option<Piece>
Returns an instance of Piece after promotion.
Examples
use shogi::{Color, PieceType, Piece}; let pc1 = Piece{piece_type: PieceType::Pawn, color: Color::Black}; let pc2 = Piece{piece_type: PieceType::ProPawn, color: Color::Black}; assert_eq!(Some(pc2), pc1.promote()); assert_eq!(None, pc2.promote());
fn unpromote(&self) -> Option<Piece>
Returns an instance of Piece before promotion.
Examples
use shogi::{Color, PieceType, Piece}; let pc1 = Piece{piece_type: PieceType::Pawn, color: Color::Black}; let pc2 = Piece{piece_type: PieceType::ProPawn, color: Color::Black}; assert_eq!(Some(pc1), pc2.unpromote()); assert_eq!(None, pc1.unpromote());
fn flip(&self) -> Piece
Returns an instance of Piece with the reversed color.
Examples
use shogi::{Color, PieceType, Piece}; let pc1 = Piece{piece_type: PieceType::Pawn, color: Color::Black}; let pc2 = Piece{piece_type: PieceType::Pawn, color: Color::White}; assert_eq!(pc2, pc1.flip()); assert_eq!(pc1, pc2.flip());
fn is_placeable_at(&self, sq: Square) -> bool
Tests if it is legal to place this piece at the given square.
Trait Implementations
impl Debug for Piece[src]
impl PartialEq for Piece[src]
fn eq(&self, __arg_0: &Piece) -> bool
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &Piece) -> bool
This method tests for !=.
impl Eq for Piece[src]
impl Clone for Piece[src]
fn clone(&self) -> Piece
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more