public void MoveStarted(SquareVM startingSquare) { _availableSquares = new List <SquareVM>(); _startingSquare = startingSquare; startingSquare.MovingPiece = true; var availableSquares = startingSquare.Piece.GetAvailableMoves(); foreach (var square in availableSquares) { var cellVM = Cells.Single(c => c.Position == square); cellVM.PlayableMoveForPlayer = true; _availableSquares.Add(cellVM); } }
public BoardCellControl(SquareVM vm, IImagesFactory imagesFactory) { _vm = vm; _board = vm.Board; DataContext = vm; _imageFactory = imagesFactory; Position = vm.Position; Background = GetColorFromVM(vm.Color); BorderBrush = System.Windows.Media.Brushes.Black; SetGridCoordinate(); InitializeComponent(); vm.WhenAny(x => x.Piece, x => x.Value) .Subscribe(SetImage); }
private BoardCellControl GetCellFromVM(SquareVM vm) { return(new BoardCellControl(vm, _piecesImageFactory)); }
private bool HasRightColorPiece(SquareVM squareVM) { return(squareVM.Piece != null && squareVM.Piece.Color == squareVM.Board.NextMoveTurn); }
public void OnMoveMade(SquareVM startingCell, SquareVM endingCell) { _board.TryPlayMove(startingCell.Square, endingCell.Square); }