예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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));
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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));
        }
예제 #10
0
 public IEnumerable <IField> NormalMove(IField field)
 {
     return(StandardMoveRules.MoveAllCross(field, board, board.MaxHeight).Where(w => w.Pawn == null));
 }
예제 #11
0
 public IEnumerable <IField> WhereCanMove(IField field)
 {
     return(StandardMoveRules.MoveAllCross(field, board, board.MaxHeight));
 }