Struct shogi::Piece [] [src]

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

Represents a piece on the game board.

Fields

Methods

impl Piece
[src]

Creates a new instance of Piece from SFEN formatted string.

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

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

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

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

Trait Implementations

impl Debug for Piece
[src]

Formats the value using the given formatter.

impl PartialEq for Piece
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Piece
[src]

impl Clone for Piece
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for Piece
[src]

impl Display for Piece
[src]

Formats the value using the given formatter.