예제 #1
0
 public override void PerformMove(PawnMove pawnMove)
 {
     if (moveList.Contains(pawnMove) == false)
     {
         throw new ArgumentException("Invalid move");
     }
     UpdateBoard(pawnMove);
     moveCount++;
     SwapPawnColor();
 }
예제 #2
0
        protected List <PawnMove> GetCaptureList(Dot pos, BoardState boardState, PawnMove pawnMove)
        {
            var result = new List <PawnMove>();

            result.Add(pawnMove);
            result.AddRange(GetCaptureList(pos, boardState, new Dot(1, 1), pawnMove));
            result.AddRange(GetCaptureList(pos, boardState, new Dot(-1, -1), pawnMove));
            result.AddRange(GetCaptureList(pos, boardState, new Dot(-1, 1), pawnMove));
            result.AddRange(GetCaptureList(pos, boardState, new Dot(1, -1), pawnMove));
            return(result);
        }
예제 #3
0
        protected void UpdateBoard(PawnMove pawnMove)
        {
            foreach (var pawn in pawnMove.GetCapturedList())
            {
                pawnList.Remove(pawn);
            }
            pawnList.Remove(pawnMove.MovedPawn);
            var movedPos = pawnMove.GetPosList().Last();

            if (pawnMove.TurnDame)
            {
                pawnList.Add(new DamePawn(movedPos, pawnMove.MovedPawn.GetPawnColor()));
            }
            else
            {
                pawnList.Add(pawnMove.MovedPawn.GetMovedToPos(movedPos));
            }
        }
예제 #4
0
 abstract public void PerformMove(PawnMove pawnMove);
예제 #5
0
 protected abstract List <PawnMove> GetCaptureList(Dot pos, BoardState bState, Dot dir, PawnMove pMove);
예제 #6
0
        protected override List <PawnMove> GetCaptureList(Dot pos, BoardState bState, Dot dir, PawnMove pMove)
        {
            var capPawn = GetCapturedPawn(pos, bState, dir);

            if (capPawn == null)
            {
                return(new List <PawnMove>());
            }
            pos = capPawn.GetPosition();
            if (pMove.GetCapturedList().Contains(capPawn))
            {
                return(GetCaptureList(pos, bState, dir, pMove));
            }
            pos = pos.GetMoved(dir);
            var result = new List <PawnMove>();

            while (bState.IsOnBoard(pos) && bState.GetColor(pos) == PawnColor.NONE)
            {
                var destMove = pMove.CreateIncrMove(pos, capPawn, false);
                result.AddRange(GetCaptureList(pos, bState, destMove));
                pos = pos.GetMoved(dir);
            }
            return(result);
        }
예제 #7
0
        protected override List <PawnMove> GetCaptureList(Dot pos, BoardState bState, Dot dir, PawnMove pMove)
        {
            if (CanCapture(pos, bState, dir) == false)
            {
                return(new List <PawnMove>());
            }
            var capPawn = bState.GetPawn(pos.GetMoved(dir));

            if (pMove.GetCapturedList().Contains(capPawn))
            {
                return(new List <PawnMove>());
            }
            var  destPos   = pos.GetMoved(dir.X * 2, dir.Y * 2);
            bool isDamePos = IsDameLanePos(destPos, bState);
            var  destMove  = pMove.CreateIncrMove(destPos, capPawn, isDamePos);

            return(GetCaptureList(destPos, bState, destMove));
        }