Beispiel #1
0
        /// <summary>
        /// 移动棋子到目标位置,若目标位置存在棋子,则移除
        /// </summary>
        /// <param name="chessman">棋子</param>
        /// <param name="target">目标位置</param>
        /// <exception cref="MoveException">无法将棋子移动到己方棋子上</exception>
        private void MoveChessman(Chessman chessman, ChessboardPosition target)
        {
            var tar = GetChessmanByPos(target);

            if (tar != null)
            {
                if (chessman.Camp == tar.Camp)
                {
                    throw new MoveException("无法将棋子移动到己方棋子上");
                }

                AlivingChessman.Remove(tar);
            }
            chessman.Position = target;
            OnChessmanMoved(chessman, tar);
        }
Beispiel #2
0
 public static ChessMove Move(Chessboard chessboard, ChessCamp camp, ChessboardPosition start, ChessboardPosition end)
 {
     throw new NotImplementedException();
 }
Beispiel #3
0
 public Chessman GetChessmanByPos(ChessboardPosition position)
 => AlivingChessman.FirstOrDefault(c => c.Position == position);