示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
            }
        }