public void DoMove(IMove move) { //Board.MakeMove(move); if (move.IsPassMove) { return; } if (move.Player.PlayerKind == Logic.Common.PlayerKind.Black) { BoardOfCellViewModel[move.MovePosition.Item1, move.MovePosition.Item2].CellState = Logic.Common.CellState.Black; foreach (var convertedPoint in move.ConvertedPoints) { BoardOfCellViewModel[convertedPoint.Item1, convertedPoint.Item2].CellState = Logic.Common.CellState.Black; } } else { BoardOfCellViewModel[move.MovePosition.Item1, move.MovePosition.Item2].CellState = Logic.Common.CellState.White; foreach (var convertedPoint in move.ConvertedPoints) { BoardOfCellViewModel[convertedPoint.Item1, convertedPoint.Item2].CellState = Logic.Common.CellState.White; } } if (LastMove != null) { LastMove.IsLastMove = false; } LastMove = BoardOfCellViewModel[move.MovePosition.Item1, move.MovePosition.Item2]; LastMove.IsLastMove = true; }
public void FlipCellManually(CellViewModel cell) { if (cell != null && cell.CellState != CellState.Empty) { Board.FlipCellManually(cell.X, cell.Y); cell.CellState = cell.CellState == CellState.White ? CellState.Black : CellState.White; } }
private void ExecuteHummanMoveCommand(CellViewModel cell) { if (!IsManualFlipEnabled) { if (IsAHummanPlayer && cell != null) { (PlayerThatPlayNow as HummanPlayer).HummanPositionToMove = new MyTuple <int, int>(cell.X, cell.Y); } } else { Board.FlipCellManually(cell); WhiteCount = Board.Board.WhitePoints.Count; BlackCount = Board.Board.BlackPoints.Count; MainWindow.UpdateScore(WhiteCount, BlackCount); } }
private bool CanExecuteHummanMoveCommand(CellViewModel cell) { if (!IsManualFlipEnabled) { IEnumerable <IMove> possibleMoves = Board.Board.GetPlausibleMoves(PlayerThatPlayNow); foreach (Move move in possibleMoves) { if (move.MovePosition.Item1 == cell.X && move.MovePosition.Item2 == cell.Y) { return(true); } } } else if (Board.CanFlipCellManualy(cell)) { return(true); } MessageBox.Show("Illegal Move"); return(false); }
public void InitializeBoard(bool emptyBoard) { Board.ConfigureNewGame(emptyBoard); var cellList = new ObservableCollection <CellViewModel>(); Cells = cellList; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { var cell = new CellViewModel { CellState = Board.Positions[i, j], X = i, Y = j }; cellList.Add(cell); BoardOfCellViewModel[i, j] = cell; } } if (LastMove != null) { LastMove.IsLastMove = false; } LastMove = null; }
public bool CanFlipCellManualy(CellViewModel cell) { return(cell != null && cell.CellState != CellState.Empty); }