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); }
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); }
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); }
public QueenModel(PawColors color) : base(color) { Type = PawType.QueenCheckers; }
public PlayerModel(string name, PawColors color) { Name = name; Color = color; }
//Test public bool IsColorHaveCheck(PawColors color, IField kingPosition) { return(WhereEnemyCanMove(color).InThisSamePosition(kingPosition) != null); }
public bool IsColorHaveCheck(PawColors color) { IField kingPosition = board.FieldList.First(f => f.Pawn?.Color == color && f.Pawn?.Type == PawType.KingChess); return(IsColorHaveCheck(color, kingPosition)); }
private int directionMove(PawColors color) => color == PawColors.Black ? -1 : 1;
public PawChess(PawType pawType, PawColors pawColors) { this.Type = pawType; this.Color = pawColors; this.Name = pawType.ToString(); }
public PawnModel(PawColors color) : base(color) { Type = PawType.PawnCheckers; }
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); }