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
 private void OnChessmanMoved(Chessman chessman, Chessman chessmanKilled)
 => ChessmanMovedEvent?.Invoke(this, new ChessmanMovedEventArgs(chessman, chessmanKilled));
Beispiel #3
0
 public ChessmanMovedEventArgs(Chessman chessman, Chessman chessmanKilled)
 {
     Chessman       = chessman;
     ChessmanKilled = chessmanKilled;
 }