Пример #1
0
 /// <summary>
 /// Removes illigal moves due to putting ones own king in check.
 /// </summary>
 public void RemoveSelfCheckingMoves()
 {
     for (int i = 0; i < m_moves.Count; i++)
     {
         Move move = m_moves[i];
         if (move.Execute())
         {
             move.UnExecute();
         }
         else
         {
             m_moves.RemoveAt(i--);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Undo the last move played.
        /// </summary>
        /// <returns>The move that has been undone. If undo is impossible null is returned.</returns>
        public Move Undo()
        {
            if (m_undoMoveHistory.Count > 0)
            {
                m_clock.Undo();

                Move move = m_undoMoveHistory.Pop();
                move.UnExecute(m_board);
                m_redoMoveHistory.Push(move);

                HandleGameHasChanged();
                return(move);
            }

            return(null);
        }
Пример #3
0
 /// <summary>
 /// Removes illigal moves due to putting ones own king in check.
 /// </summary>
 public void RemoveSelfCheckingMoves(Board board)
 {
     for (int i = 0; i < m_moves.Count; ++i)
     {
         Move move = m_moves[i];
         if (move != null)
         {
             if (move.Execute(board))
             {
                 move.UnExecute(board);
             }
             else
             {
                 m_moves.RemoveAt(i--);
             }
         }
     }
 }