Beispiel #1
0
        public override object Clone(ChessPlayingField curPlField)
        {
            object cloneFigure = base.Clone(curPlField);

            (cloneFigure as ChessNotPawnFigure).isWhite = isWhite;
            return(cloneFigure);
        }
Beispiel #2
0
        public override object Clone(ChessPlayingField curPlField)
        {
            object cloneFigure = base.Clone(curPlField);

            (cloneFigure as ChessKing).IsChecked    = IsChecked;
            (cloneFigure as ChessKing).IsCheckmated = IsCheckmated;
            return(cloneFigure);
        }
Beispiel #3
0
        public virtual object Clone(ChessPlayingField curPlField)
        {
            object cloneFigure = Activator.CreateInstance(GetType());

            (cloneFigure as ChessFigure).CurPlField     = curPlField;
            (cloneFigure as ChessFigure).AvailableMoves = AvailableMoves.ToList <ChessMove>();
            return(cloneFigure);
        }
Beispiel #4
0
 protected bool CanMoveAndCapture(int X, int Y)
 {
     if (!ChessPlayingField.CheckRanges(X, Y))
     {
         return(false);
     }
     return(CurPlField.CheckEmpty(Y, X) || !IsSameColourAs(CurPlField[Y, X]));
 }
Beispiel #5
0
        private GameLogic()
        {
            plField = new ChessPlayingField();

            whiteKingX = 3;
            whiteKingY = 0;
            blackKingX = 3;
            blackKingY = 7;

            IsWhitesTurn = true;

            CalculateAvailableMoves();
        }
Beispiel #6
0
        public object Clone()
        {
            var plField = new ChessPlayingField();

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (CheckEmpty(i, j))
                    {
                        plField[i, j] = null;
                    }
                    else
                    {
                        plField[i, j] = field[i, j].Clone(plField) as ChessFigure;
                    }
                }
            }
            return(plField);
        }
Beispiel #7
0
        public void CheckAvailableMoves()
        {
            ChessPlayingField tempPlField = plField.Clone() as ChessPlayingField;
            int tempWhiteKingX = whiteKingX, tempWhiteKingY = whiteKingY;
            int tempBlackKingX = blackKingX, tempBlackKingY = blackKingY;

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (!plField.CheckEmpty(i, j))
                    {
                        foreach (var move in plField[i, j].AvailableMoves)
                        {
                            if (plField.CheckEmpty(move.EndY, move.EndX) || !plField[move.EndY, move.EndX].IsKing())
                            {
                                ChessFigure capturedFigure = plField[move.EndY, move.EndX];

                                MakeOrCancelAMove(move);

                                Console.WriteLine("----------------------------------------");

                                if (OppositeKing.IsChecked)
                                {
                                    tempPlField[i, j].AvailableMoves.Remove(move);
                                }

                                MakeOrCancelAMove(move.Reverse(), capturedFigure);
                            }
                        }
                    }
                }
            }
            plField    = tempPlField;
            whiteKingX = tempWhiteKingX;
            whiteKingY = tempWhiteKingY;
            blackKingX = tempBlackKingX;
            blackKingY = tempBlackKingY;
        }
Beispiel #8
0
 public ChessWhitePawn(ChessPlayingField curPlField) : base(curPlField)
 {
 }
Beispiel #9
0
 protected bool CanCapture(int Y, int X)
 {
     return(ChessPlayingField.CheckRanges(Y, X) &&
            !CurPlField.CheckEmpty(Y, X) && !IsSameColourAs(CurPlField[Y, X]));
 }
Beispiel #10
0
 protected bool CanMove(int X, int Y)
 {
     return(ChessPlayingField.CheckRanges(Y, X) && CurPlField.CheckEmpty(Y, X));
 }
Beispiel #11
0
 public ChessKing(ChessPlayingField curPlField, bool isWhite) : base(curPlField, isWhite)
 {
 }
Beispiel #12
0
 public ChessFigure(ChessPlayingField curPlField)
 {
     this.CurPlField = curPlField;
 }
Beispiel #13
0
 public ChessNotLinearMovingFigure(ChessPlayingField curPlField, bool isWhite) : base(curPlField, isWhite)
 {
 }
Beispiel #14
0
 public ChessNotPawnFigure(ChessPlayingField curPlField, bool isWhite) : base(curPlField)
 {
     this.isWhite = isWhite;
 }
Beispiel #15
0
 public ChessBlackPawn(ChessPlayingField curPlField) : base(curPlField)
 {
 }