private bool IsCheckerMoved(CheckerElementViewModel newSelectedChecker, PlayerViewModel player) { var moveValidationManager = new MoveValidationManager(_selectedChecker , newSelectedChecker , NextMoveSide , player , this); MoveValidationResult validationResult = moveValidationManager.GetMoveValidationResult(); if (validationResult.Status == MoveValidationStatus.NewItemSelected) { if (_selectedChecker != null) { _selectedChecker.IsSelected = false; _selectedChecker.DeSelectPossibleMovement(); } _selectedChecker = newSelectedChecker; _selectedChecker.IsSelected = true; _selectedChecker.SelectPossibleMovement(); return(false); } if (validationResult.Status == MoveValidationStatus.DeselectChecker) { _selectedChecker.IsSelected = false; _selectedChecker.DeSelectPossibleMovement(); _selectedChecker = null; return(false); } if (validationResult.Status == MoveValidationStatus.Error) { ShowNotificationMessage(validationResult.ErrorMessage); return(false); } MoveCheckerToNewPlace(_selectedChecker, newSelectedChecker, player); _selectedChecker.IsSelected = false; _selectedChecker = null; return(true); }
private void MoveCheckerToNewPlace(CheckerElementViewModel currentPositionElementViewModel, CheckerElementViewModel emptyPosition, PlayerViewModel playerViewModel) { _game.ResetHistoryIfNeeded(CurrentHistoryPosition); CurrentHistoryPosition++; playerViewModel.MoveCheckerToNewPlace(currentPositionElementViewModel); _game.MoveChecker(currentPositionElementViewModel.CheckerModel, emptyPosition.CheckerModel); _playerOne.ReSetPossibleMovements(_emptyCellsPlayerViewModel.PlayerPositions.ToList()); _playerTwo.ReSetPossibleMovements(_emptyCellsPlayerViewModel.PlayerPositions.ToList()); }