Example #1
0
        public IReadOnlyPiece GetPiece(PublicDataType.IntegerVector2 position)
        {
            if (!IsOnBoard(position))
            {
                return(null);
            }

            return(pieces.Read(position));
        }
Example #2
0
        /// <summary>
        /// 指定された駒を空いたマスに移動する.
        /// </summary>
        /// <param name="movingPiece"></param>
        /// <param name="endWorldPosition"></param>
        /// <param name="isForceMove"></param>
        /// <returns></returns>
        public bool MovePiece(IPiece movingPiece, PublicDataType.IntegerVector2 endWorldPosition, bool isForceMove = false)
        {
            PublicDataType.IntegerVector2 startWorldPosition = movingPiece.Position;

            if (pieceMap.Read(endWorldPosition) != null)
            {
                return(false);
            }

            if (!movingPiece.MoveTo(endWorldPosition, isForceMove))
            {
                return(false);
            }

            //この順で書きまないと現在いる座標と同じ座標をendWorldPositionに指定されたとき盤上から駒の判定がなくなる
            pieceMap.Write(startWorldPosition, null);
            pieceMap.Write(endWorldPosition, movingPiece);
            return(true);
        }
Example #3
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));
        }
Example #4
0
 public bool IsInTammua(PublicDataType.IntegerVector2 position)
 {
     return(columns.Read(position) == FieldEffect.Tammua || columns.Read(position) == FieldEffect.Tanzo);
 }