Beispiel #1
0
        public void UnapplyMove(Move move)
        {
            Square pawn      = Squares[move.To.X, move.To.Y];
            Color  pawnColor = pawn.Color;

#if DEBUG
            if (pawnColor == Color.None)
            {
                Console.WriteLine("Invalid move");
                return;
            }
#endif
            if (move.IsEpCapture)
            {
                Square to  = move.To;
                int    toX = to.X;
                int    toY = to.Y;
                if (pawnColor == Color.Black)
                {
                    Square tPawn = Squares[toX, toY + 1];
                    tPawn.Color = Color.White;
                    WhitePawns.Add(tPawn);
                    BlackPawns.Remove(pawn);
                    pawn.Color = Color.None;
                }
                else
                {
                    Square tPawn = Squares[toX, toY - 1];
                    tPawn.Color = Color.Black;
                    BlackPawns.Add(tPawn);
                    WhitePawns.Remove(pawn);
                    pawn.Color = Color.None;
                }
            }
            else if (move.IsCapture)
            {
                if (pawnColor == Color.White)
                {
                    pawn.Color = Color.Black;
                    BlackPawns.Add(pawn);
                    WhitePawns.Remove(pawn);
                }
                else
                {
                    pawn.Color = Color.White;
                    WhitePawns.Add(pawn);
                    BlackPawns.Remove(pawn);
                }
            }
            else
            {
                RemovePawn(pawn);
                pawn.Color = Color.None;
            }
            Square from = move.From;
            from.Color = pawnColor;
            AddPawn(from);
        }
Beispiel #2
0
 public void AddPawn(Square pawn)
 {
     if (pawn.Color == Color.White)
     {
         WhitePawns.Add(pawn);
     }
     else
     {
         BlackPawns.Add(pawn);
     }
 }