using System;
using Server;
namespace Arya.Chess
{
///
/// Describes a piece move
///
public class Move
{
private Point2D m_From;
private Point2D m_To;
private BaseChessPiece m_Piece;
private BaseChessPiece m_Captured;
private bool m_EnPassant = false;
///
/// Gets the initial position of the piece
///
public Point2D From
{
get { return m_From; }
}
///
/// Gets the target destination of the move
///
public Point2D To
{
get { return m_To; }
}
///
/// Gets the chess piece performing this move
///
public BaseChessPiece Piece
{
get { return m_Piece; }
}
///
/// Gets the piece captured by this move
///
public BaseChessPiece CapturedPiece
{
get { return m_Captured; }
}
///
/// Specifies if this move captures a piece
///
public bool Capture
{
get { return m_Captured != null; }
}
///
/// The color of the player making this move
///
public ChessColor Color
{
get { return m_Piece.Color; }
}
///
/// Gets the color of the opponent of the player who made the move
///
public ChessColor EnemyColor
{
get { return m_Piece.EnemyColor; }
}
///
/// Specifies if the capture is made EnPassant
///
public bool EnPassant
{
get { return m_EnPassant; }
set { m_EnPassant = value; }
}
///
/// Creates a new Move object without capturing a piece
///
/// The chess piece performing the move
/// The target location of the move
public Move( BaseChessPiece piece, Point2D target )
{
m_Piece = piece;
m_From = m_Piece.Position;
m_To = target;
m_Captured = m_Piece.GetCaptured( target, ref m_EnPassant );
}
}
}