コード例 #1
0
ファイル: MoveOrganizer.cs プロジェクト: prezz/Firoz-Chess
 /// <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
ファイル: Game.cs プロジェクト: prezz/Firoz-Chess
        /// <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--);
             }
         }
     }
 }