public IField GetPreviousCrossField(IField fieldOld, IField fieldNew) { int heigh = fieldNew.Heigh - StandardMoveRules.IsMoveUp(fieldOld, fieldNew); int width = fieldNew.Width - StandardMoveRules.IsMoveRight(fieldOld, fieldNew); return(board.FieldList.FirstOrDefault(f => f.Heigh == heigh && f.Width == width)); }
public IEnumerable <IField> NormalMove(IField field) { bool goUp = standardMoveRules.DirectionMove(field) == 1; return(StandardMoveRules.MoveCross(field, board, true, goUp, 1) .Concat(StandardMoveRules.MoveCross(field, board, false, goUp, 1)) .Where(w => w.Pawn == null)); }
public IEnumerable <IField> WhereCanMove(IField field) { List <IField> fieldList = new List <IField>(); fieldList.AddRange(StandardMoveRules.MoveHorizontalVertical(field, board, board.MaxHeight)); fieldList.AddRange(StandardMoveRules.MoveAllCross(field, board, board.MaxHeight)); return(fieldList); }
public IEnumerable <IField> NormalMove(IField position) { List <IField> fieldList = new List <IField>(); fieldList.AddRange(StandardMoveRules.MoveHorizontalVertical(position, board, 1)); fieldList.AddRange(StandardMoveRules.MoveAllCross(position, board, 1)); return(fieldList); }
private void AddToList(IField position, IList <IField> fieldList, int goWidth, int goHeight) { var field = StandardMoveRules.Move(position, board, goWidth, goHeight); bool isEmpty = field == null; bool isMyPawn = !isEmpty && field.Pawn != null && field.Pawn.Color == position.Pawn.Color; if (isEmpty || isMyPawn) { return; } fieldList.Add(field); }
public IEnumerable <IField> BeatMove(IField field) { List <IField> fieldList = new List <IField>(); var moveLeft = StandardMoveRules.Move(field, board, -1, 1 * directionMove(field.Pawn.Color)); if (moveLeft != null) { fieldList.Add(moveLeft); } var moveRight = StandardMoveRules.Move(field, board, 1, 1 * directionMove(field.Pawn.Color)); if (moveRight != null) { fieldList.Add(moveRight); } return(fieldList.Where(f => f != null && f.Pawn != null && f.Pawn.Color != field.Pawn.Color)); }
public IEnumerable <IField> BeatingInPassingMove(IField field) { List <IField> fieldList = new List <IField>(); if (pawnHistoriesList.Count == 0) { return(fieldList); } bool isDarkBeatingInPassing = isBeatingInPassing(PawColors.Black, field, 4, 2); bool isWhiteBeatingInPassing = isBeatingInPassing(PawColors.White, field, 5, 7); if (isDarkBeatingInPassing || isWhiteBeatingInPassing) { var newLast = board.FieldList.First(f => f.ID == pawnHistoriesList.Last().CurrentFiledID); bool isGoLeft = field.Width > newLast.Width; bool isGoUp = directionMove(field.Pawn.Color) > 0; fieldList.AddRange(StandardMoveRules.MoveCross(field, board, isGoLeft, isGoUp, 1)); } return(fieldList); }
public IEnumerable <IField> NormalMove(IField field) { List <IField> fieldList = new List <IField>(); var firstMove = StandardMoveRules.Move(field, board, 0, 1 * directionMove(field.Pawn.Color)); bool canDoFirstMove = canMove(firstMove); if (canDoFirstMove) { fieldList.Add(firstMove); } if (!PawDoMove(field.Pawn)) { var secendMove = StandardMoveRules.Move(field, board, 0, 2 * directionMove(field.Pawn.Color)); bool canDoSecendMove = canDoFirstMove && canMove(secendMove); if (canDoSecendMove) { fieldList.Add(secendMove); } } return(fieldList); }
public IEnumerable <IField> BeatMove(IField field) { IEnumerable <IField> enemyModelList = StandardMoveRules.MoveAllCross(field, board, board.MaxHeight).Where(w => w.Pawn != null); return(standardMoveRules.BeatMove(field, enemyModelList)); }
public IEnumerable <IField> NormalMove(IField field) { return(StandardMoveRules.MoveAllCross(field, board, board.MaxHeight).Where(w => w.Pawn == null)); }
public IEnumerable <IField> WhereCanMove(IField field) { return(StandardMoveRules.MoveAllCross(field, board, board.MaxHeight)); }