public object Clone() { var newCellViewModel = new CellViewModel(CurrentChessPiece, Board); newCellViewModel.CanEatHere.AddRange(CanEatHere.Select(path => path.ClonePath())); newCellViewModel.CanMoveHere.AddRange(CanEatHere.Select(path => path.ClonePath())); newCellViewModel.Bgc = Bgc; newCellViewModel.Name = Name; newCellViewModel.CurrentChessPiece = CurrentChessPiece?.CloneChessPiece(); return(newCellViewModel); }
private async Task MarkEatTo(Path.Path path, bool ignoreValidateMovement) { if (CurrentChessPiece != null) { if (CurrentChessPiece.IsWhite() != path.StartCell.CurrentChessPiece?.IsWhite() && (ignoreValidateMovement || await Board.ValidateMovement(path.StartCell, this))) { CanEatHere.Add(path); } return; } if (Movements[path.GetNextStep()] != null) { await Movements[path.GetStep()].MarkEatTo(path, ignoreValidateMovement); } }
private async Task CheckJumpEatTo(Path.Path path, bool ignoreValidateMovement) { if (path.GetNextStep() == Movement.Direction.Final) { if (CurrentChessPiece == null && (ignoreValidateMovement || await Board.ValidateMovement(path.StartCell, this))) { CanMoveHere.Add(path); } else if (CurrentChessPiece?.IsWhite() != path.StartCell.CurrentChessPiece?.IsWhite() && (ignoreValidateMovement || await Board.ValidateMovement(path.StartCell, this))) { CanEatHere.Add(path); } return; } if (Movements[path.GetStep()] != null) { await Movements[path.GetStep()].CheckJumpEatTo(path, ignoreValidateMovement); } }