Exemple #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));
        }
        public ChessBoardBulider SetAllPawnInHeigh(PawChess pawnType, int height, PawColors color)
        {
            for (int i = 1; i <= maxWidth; i++)
            {
                SetPawn(pawnType, height, i, color);
            }

            return(this);
        }
Exemple #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);
        }
Exemple #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);
        }
        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);
        }
        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);
        }
Exemple #7
0
 public QueenModel(PawColors color) : base(color)
 {
     Type = PawType.QueenCheckers;
 }
Exemple #8
0
 public PlayerModel(string name, PawColors color)
 {
     Name  = name;
     Color = color;
 }
Exemple #9
0
 //Test
 public bool IsColorHaveCheck(PawColors color, IField kingPosition)
 {
     return(WhereEnemyCanMove(color).InThisSamePosition(kingPosition) != null);
 }
Exemple #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));
        }
Exemple #11
0
 private int directionMove(PawColors color) => color == PawColors.Black ? -1 : 1;
Exemple #12
0
 public PawChess(PawType pawType, PawColors pawColors)
 {
     this.Type  = pawType;
     this.Color = pawColors;
     this.Name  = pawType.ToString();
 }
Exemple #13
0
 public PawnModel(PawColors color) : base(color)
 {
     Type = PawType.PawnCheckers;
 }
Exemple #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);
        }