public bool IsCanPlay(Board board, Bar gameBar, Dice dice) { if (gameBar.NumOfReds != 0) { if (!IsCanGetOutFromBar(board, dice)) { dice.FinishedAll(); return(false); } } if (dice.DiceDouble) { IsMyTurn = GetOptionalsMoves(board, gameBar, dice.FirstCube).Count != 0 || GetOptionalsMoves(board, gameBar, dice.SecondCube).Count != 0 || GetOptionalsMoves(board, gameBar, dice.ThirdCube).Count != 0 || GetOptionalsMoves(board, gameBar, dice.ForthCube).Count != 0; } //else { IsMyTurn = GetOptionalsMoves(board, gameBar, dice.FirstCube).Count != 0 || GetOptionalsMoves(board, gameBar, dice.SecondCube).Count != 0;; } if (!IsMyTurn) { dice.FinishedAll(); } return(IsMyTurn); }
public void moveTo(Dice dice, int cubeNumber, Board board, Bar gameBar, int fromChoice, int toChoice) { int diceNumber = GetDiceNumber(cubeNumber, dice); //check if is in the bar if (gameBar.NumOfReds > 0) { if (IsCanGetOutFromBar(board, dice)) { if (board.Cells[diceNumber].CheckersColor == CheckerColor.Red || board.Cells[diceNumber].NumOfCheckers <= 1) { board.AddCheckerToBoard(diceNumber, CheckerColor.Red); gameBar.RemoveRedFromBar(); SetCubeState(cubeNumber, dice); } } else { if (!IsCanGetOutFromBar(board, dice)) { dice.FinishedAll(); } } } else { if (IsCanGetOutFromBoard(board) && toChoice == 25) { //if user chose to exit-25 check if can if (isMovesAppropriateToCubeWhenCanGetOut(diceNumber, fromChoice, toChoice) && CheckIfCanGetOutThisCell(board, diceNumber, fromChoice, toChoice)) { board.RemoveCheckerFromBoard(fromChoice, CheckerColor.Red); SetCubeState(cubeNumber, dice); } } else { if ((board.Cells[fromChoice].CheckersColor == CheckerColor.Red) && (board.Cells[toChoice].CheckersColor == CheckerColor.Red || (board.Cells[toChoice].NumOfCheckers <= 1)) && isMovesAppropriateToCube(diceNumber, fromChoice, toChoice)) { board.AddCheckerToBoard(toChoice, CheckerColor.Red); board.RemoveCheckerFromBoard(fromChoice, CheckerColor.Red); SetCubeState(cubeNumber, dice); } } } }