Exemplo n.º 1
0
        public CaptureResult CapturePiece(IPlayer player, IPiece capturer, PublicDataType.IntegerVector2 targetPosition)
        {
            IPiece targetPiece = pieces.Read(targetPosition);

            if (targetPiece == null)
            {
                return(new CaptureResult(true, capturer, null, null, targetPosition));
            }

            if (!IsCapturable(player, capturer, targetPiece) || !targetPiece.CaptureFromBoard())
            {
                return(new CaptureResult(false, capturer, null, null, targetPosition));
            }

            IPlayer formerOwner = targetPiece.Owner;

            targetPiece.SetOwner(player);
            pieces.Write(targetPosition, null);
            return(new CaptureResult(true, capturer, targetPiece, formerOwner, targetPosition));
        }