Exemple #1
0
 public abstract Pawn GetMovedToPos(Dot pos);
Exemple #2
0
 protected abstract List <PawnMove> GetNoneCaptureList(Dot pawnPos, BoardState boardState);
Exemple #3
0
 protected abstract List <PawnMove> GetCaptureList(Dot pos, BoardState bState, Dot dir, PawnMove pMove);
Exemple #4
0
 public Pawn(Dot pawnPos, PawnColor pawnColor)
 {
     this.pawnPos   = pawnPos;
     this.pawnColor = pawnColor;
 }
Exemple #5
0
 protected abstract bool CanCapture(Dot pawnPos, BoardState boardState, Dot dir);
Exemple #6
0
 public override Pawn GetMovedToPos(Dot pos)
 {
     return(new DamePawn(pos, pawnColor));
 }
Exemple #7
0
        protected bool CanCapture(Dot pos, BoardState boardState)
        {
            Func <int, int, bool> capFunc = ((x, y) => CanCapture(pos, boardState, new Dot(x, y)));

            return(capFunc(1, 1) || capFunc(-1, -1) || capFunc(1, -1) || capFunc(-1, 1));
        }
Exemple #8
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);
        }
Exemple #9
0
 public DamePawn(Dot pos, PawnColor pawnColor) : base(pos, pawnColor)
 {
 }
Exemple #10
0
 protected override bool CanCapture(Dot pos, BoardState boardState, Dot dir)
 {
     return(GetCapturedPawn(pos, boardState, dir) != null);
 }
Exemple #11
0
 public override Pawn GetMovedToPos(Dot pos)
 {
     return(new PiecePawn(pos, pawnColor, moveDir));
 }
Exemple #12
0
 public PiecePawn(Dot pos, PawnColor pawnColor, int moveDir) : base(pos, pawnColor)
 {
     this.moveDir = moveDir;
 }
Exemple #13
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));
        }
Exemple #14
0
 protected PawnMove GetNoneCaptureMove(Dot pos, BoardState boardState)
 {
     return(new PawnMove(pos, this, IsDameLanePos(pos, boardState)));
 }