public abstract Pawn GetMovedToPos(Dot pos);
protected abstract List <PawnMove> GetNoneCaptureList(Dot pawnPos, BoardState boardState);
protected abstract List <PawnMove> GetCaptureList(Dot pos, BoardState bState, Dot dir, PawnMove pMove);
public Pawn(Dot pawnPos, PawnColor pawnColor) { this.pawnPos = pawnPos; this.pawnColor = pawnColor; }
protected abstract bool CanCapture(Dot pawnPos, BoardState boardState, Dot dir);
public override Pawn GetMovedToPos(Dot pos) { return(new DamePawn(pos, pawnColor)); }
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)); }
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); }
public DamePawn(Dot pos, PawnColor pawnColor) : base(pos, pawnColor) { }
protected override bool CanCapture(Dot pos, BoardState boardState, Dot dir) { return(GetCapturedPawn(pos, boardState, dir) != null); }
public override Pawn GetMovedToPos(Dot pos) { return(new PiecePawn(pos, pawnColor, moveDir)); }
public PiecePawn(Dot pos, PawnColor pawnColor, int moveDir) : base(pos, pawnColor) { this.moveDir = moveDir; }
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)); }
protected PawnMove GetNoneCaptureMove(Dot pos, BoardState boardState) { return(new PawnMove(pos, this, IsDameLanePos(pos, boardState))); }