Beispiel #1
0
 public List <Position> GetHint(int x, int y)
 {
     try
     {
         Piece.Piece currentPiece = this.Pieces.First(p => p.CurrentPosition.X == x && p.CurrentPosition.Y == y && p.Colour == this.CurrenTurn);
         return(currentPiece.ValidMoves());
     }
     catch (Exception)
     {
     }
     return(new List <Position>());
 }
Beispiel #2
0
        internal bool MakeMove(int x1, int y1, int x2, int y2)
        {
            Piece.Piece currentPiece = this.Pieces.First(p => p.CurrentPosition.X == x1 && p.CurrentPosition.Y == y1 && p.Colour == this.CurrenTurn);
            var         validMoves   = currentPiece.ValidMoves().Where(p => p.X == x2 && p.Y == y2);

            if (!validMoves.Any())
            {
                return(false);
            }

            #region Make the move
            this.Pieces.RemoveAll(p => p.CurrentPosition.X == x2 && p.CurrentPosition.Y == y2);
            currentPiece.MakeMove(x2, y2);
            int t = (int)Convert.ChangeType(CurrenTurn, CurrenTurn.GetTypeCode());
            CurrenTurn = (Enum.Colour)((t + 1) % 2);
            #endregion
            return(true);
        }