public void BuildMove(List <ChessMove> storage, ChessMoveFlag result, ChessColor color, ChessPieceType type, ChessPieceCoord from, ChessPieceCoord to) { var fromPiece = GetPiece(from); var toPiece = GetPiece(to); // AC's Chess implementation doesn't support underpromotion var promotion = ChessPieceType.Empty; if (fromPiece.Type == ChessPieceType.Pawn && (to.Rank == 1 || to.Rank == 8)) { promotion = ChessPieceType.Queen; result |= ChessMoveFlag.Promotion; } var captured = ChessPieceType.Empty; if (toPiece != null) { captured = toPiece.Type; } else if (result.HasFlag(ChessMoveFlag.EnPassantCapture)) { captured = ChessPieceType.Pawn; var enPassantCoord = new ChessPieceCoord(to); enPassantCoord.MoveOffset(0, color == ChessColor.Black ? 1 : -1); toPiece = GetPiece(enPassantCoord); } storage.Add(new ChessMove(result, color, type, from, to, promotion, captured, Move, HalfMove, Castling, EnPassantCoord, fromPiece.Guid, captured != ChessPieceType.Empty ? toPiece.Guid : new ObjectGuid(0))); }
public ChessMove(ChessMoveFlag flags, ChessColor color, ChessPieceType type, ChessPieceCoord from, ChessPieceCoord to, ChessPieceType promotion, ChessPieceType captured, uint move, uint halfMove, List <ChessMoveFlag> castling, ChessPieceCoord enPassantCoord, ObjectGuid guid, ObjectGuid capturedGuid) { Flags = flags; Color = color; Type = type; From = new ChessPieceCoord(from); To = new ChessPieceCoord(to); Promotion = promotion; Captured = captured; Move = move; HalfMove = halfMove; Castling = castling; EnPassantCoord = enPassantCoord; Guid = guid; CapturedGuid = capturedGuid; }
public RookCastleFlag(Vector2 vector, ChessMoveFlag flag) { Vector = vector; Flag = flag; }