Esempio n. 1
0
        private bool isBeatingInPassing(PawColors color, IField field, int heighPosition, int heightOldPosition)
        {
            IPawnHistory lastMove = pawnHistoriesList.LastOrDefault();

            if (lastMove == null)
            {
                return(false);
            }

            var pawn                 = board.FieldList.First(f => f.Pawn?.ID == lastMove.PawID).Pawn;
            var fieldOldPosition     = board.FieldList.First(f => f.ID == lastMove.PreviusFiledID);
            var fieldCurrentPosition = board.FieldList.First(f => f.ID == lastMove.CurrentFiledID);

            return(field.Pawn.Color == color &&
                   field.Heigh == heighPosition &&
                   pawn != null &&
                   pawn.Color != field.Pawn.Color &&
                   pawn.Type == field.Pawn.Type &&
                   fieldOldPosition.Heigh == heightOldPosition &&
                   (fieldOldPosition.Width == field.Width - 1 ||
                    fieldOldPosition.Width == field.Width + 1) &&
                   fieldCurrentPosition.Heigh == heighPosition &&
                   (fieldCurrentPosition.Width == field.Width - 1 ||
                    fieldCurrentPosition.Width == field.Width + 1));
        }
Esempio n. 2
0
        public ChessBoardBulider SetAllPawnInHeigh(PawChess pawnType, int height, PawColors color)
        {
            for (int i = 1; i <= maxWidth; i++)
            {
                SetPawn(pawnType, height, i, color);
            }

            return(this);
        }
Esempio n. 3
0
        public IEnumerable <IField> WhereEnemyCanMove(PawColors youColor)
        {
            var enemyPawsList = board.FieldList.Where(w => w.Pawn != null && w.Pawn.Color != youColor);

            List <IField> whereEnenymCanMoveList = enemyPawsList
                                                   .SelectMany(WhereCanBeat)
                                                   .Distinct()
                                                   .ToList();

            return(whereEnenymCanMoveList);
        }
Esempio n. 4
0
        public IEnumerable <IField> PawHaveToBeat(PawColors color)
        {
            List <IField>        fieldList = new List <IField>();
            IEnumerable <IField> paws      = board.FieldList.Where(w => w.Pawn?.Color == color);

            foreach (IField field in paws)
            {
                if (BeatMove(field).Any())
                {
                    fieldList.Add(field);
                }
            }

            return(fieldList);
        }
Esempio n. 5
0
        public ChessBoardBulider SetPawn(PawChess pawnType, int height, int width, PawColors color)
        {
            //Przydała by się walidacja
            var pawn = KernelInstance.Get <IPawn>();

            pawn.Color = color;
            pawn.ID    = pawId;
            pawn.Type  = (PawType)pawnType;

            IField field = KernelInstance.Get <IField>();

            field.Heigh = height;
            field.Width = width;
            field.Pawn  = pawn;

            fieldList.Add(field);

            pawId++;

            return(this);
        }
Esempio n. 6
0
        public ChessBoardBulider SetPawnInTwoCorner(PawChess pawnType, int height, int firstWidth, PawColors color)
        {
            int secendWidth = maxWidth - firstWidth + 1;

            SetPawn(pawnType, height, firstWidth, color);
            SetPawn(pawnType, height, secendWidth, color);
            return(this);
        }
Esempio n. 7
0
 public QueenModel(PawColors color) : base(color)
 {
     Type = PawType.QueenCheckers;
 }
Esempio n. 8
0
 public PlayerModel(string name, PawColors color)
 {
     Name  = name;
     Color = color;
 }
Esempio n. 9
0
 //Test
 public bool IsColorHaveCheck(PawColors color, IField kingPosition)
 {
     return(WhereEnemyCanMove(color).InThisSamePosition(kingPosition) != null);
 }
Esempio n. 10
0
        public bool IsColorHaveCheck(PawColors color)
        {
            IField kingPosition = board.FieldList.First(f => f.Pawn?.Color == color && f.Pawn?.Type == PawType.KingChess);

            return(IsColorHaveCheck(color, kingPosition));
        }
Esempio n. 11
0
 private int directionMove(PawColors color) => color == PawColors.Black ? -1 : 1;
Esempio n. 12
0
 public PawChess(PawType pawType, PawColors pawColors)
 {
     this.Type  = pawType;
     this.Color = pawColors;
     this.Name  = pawType.ToString();
 }
Esempio n. 13
0
 public PawnModel(PawColors color) : base(color)
 {
     Type = PawType.PawnCheckers;
 }
Esempio n. 14
0
        public bool IsColorHaveCheck(PawColors color)
        {
            IField kingPosition = board.FieldList.First(f => f.Pawn?.Color == color && f.Pawn?.Type == PawType.KingChess);

            return(MoveRules.WhereEnemyCanMove(color).InThisSamePosition(kingPosition) != null);
        }