Exemplo n.º 1
0
        public static string ToLongAlgebraic(MoveDesc move, string language)
        {
            Debug.Assert(move != null && move.Piece != Pieces.NoPiece);
            // TODO - use language somehow
            // TODO - en passant?
            // TODO - promotions
            if (move.IsShortCastle)
            {
                return SHORT_CASTLE;
            }

            if (move.IsLongCastle)
            {
                return LONG_CASTLE;
            }

            // TODO - checkmate, check
            var s = new StringBuilder(10);
            s.Append(GetPieceString(move.Piece, language));
            s.Append(move.From);
            s.Append(move.IsCapture ? ':' : '-');
            s.Append(move.To);
            if (move.IsCheckmate)
            {
                s.Append(CHAR_CHECKMATE);
            }
            else if (move.IsCheck)
            {
                s.Append(CHAR_CHECK);
            }
            return s.ToString();
        }
Exemplo n.º 2
0
 public CommandPlayMove(MoveDesc move)
 {
     if (move == null)
     {
         throw new ArgumentNullException();
     }
     m_move = move;
 }
Exemplo n.º 3
0
 public void PlayMove(MoveDesc move)
 {
     // TODO - check a lot of conditions here
     m_analyzer.PlayMove(move);
 }
Exemplo n.º 4
0
 public bool IsSame(MoveDesc other)
 {
     // TODO
     return Piece == other.Piece
         && From.IsSame(other.From)
         && To.IsSame(other.To)
         && PromoteTo == other.PromoteTo
         && IsPromotion == other.IsPromotion
         && IsCapture == other.IsCapture
         && IsCheck == other.IsCheck
         && IsCheckmate == other.IsCheckmate;
 }
Exemplo n.º 5
0
 public ErrorCodes PlayMove(MoveDesc move)
 {
     var is_ok = m_tree.MakeChildNewRoot(move.From, move.To, move.PromoteTo);
     if (is_ok)
     {
         CurrentGame.m_moves.Add(move);
     }
     else
     {
         // TODO - should we reset the game, or should we ignore move command?
         InitNewGame();
     }
     return is_ok ? ErrorCodes.Success : ErrorCodes.InvalidMove;
 }
Exemplo n.º 6
0
 public static string ToCoordinateNotation(MoveDesc move)
 {
     return move.From.ToString() + move.To.ToString() +
         (move.IsPromotion ? GetPieceString(move.PromoteTo).ToLower()
         : string.Empty);
 }