[][src]Struct shogi::piece::Piece

pub struct Piece {
    pub piece_type: PieceType,
    pub color: Color,
}

Represents a piece on the game board.

Fields

piece_type: PieceTypecolor: Color

Methods

impl Piece
[src]

pub fn from_sfen(c: char) -> Option<Piece>
[src]

Creates a new instance of Piece from SFEN formatted string.

pub fn promote(&self) -> Option<Piece>
[src]

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());

pub fn unpromote(&self) -> Option<Piece>
[src]

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());

pub fn flip(&self) -> Piece
[src]

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());

pub fn is_placeable_at(&self, sq: Square) -> bool
[src]

Tests if it is legal to place this piece at the given square.

Trait Implementations

impl PartialEq<Piece> for Piece
[src]

impl Eq for Piece
[src]

impl Clone for Piece
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for Piece
[src]

impl Display for Piece
[src]

impl Debug for Piece
[src]

Auto Trait Implementations

impl Send for Piece

impl Sync for Piece

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]