Esempio n. 1
0
        public static List <OneStep> giveAllTheSteps(Board board, Color.color currentColor, List <int> currentRoll)
        {
            List <OneStep> stepList = new List <OneStep>();
            bool           isWhite  = currentColor == Color.color.white;

            int goToFactor = isWhite ? -1 : 1;

            for (int i = 0; i < 24; i++)
            {
                if (board.SpotsOnBoard[i].color == currentColor)
                {
                    foreach (var cube in currentRoll)
                    {
                        if ((isWhite)?(i - cube > -1) : (i + cube < 24))
                        {
                            if ((board.SpotsOnBoard[i + cube * goToFactor].color != Color.returnOpposite(currentColor) || board.SpotsOnBoard[i + cube * goToFactor].numberOfTiles == 1))
                            {
                                stepList.Add(new OneStep(i, i + cube * goToFactor));
                            }
                        }
                    }
                }
            }

            return(stepList);
        }
Esempio n. 2
0
 public Game()
 {
     player1        = new Player(Color.color.white);
     player2        = new Player(Color.color.black);
     board          = new Board();
     color          = new Color();
     isThereAWinner = Color.color.empty;
 }
Esempio n. 3
0
 public void subJailNumber(Color.color color)
 {
     if (color == Color.color.black)
     {
         NumberOfBlackTilesInJail--;
     }
     else
     {
         NumberOfWhiteTilesInJail--;
     }
 }
Esempio n. 4
0
 private static List <OneStep> returnPossabilities(Board board, Color.color currentColor, Player currentPlayer)
 {
     if (Jail.checkIfThereIsSomeOneInJail(currentColor, board))
     {
         return(Jail.giveAllTheSteps(board, currentColor, Turn.currentRoll));
     }
     if (currentPlayer.isInTheLastZone)
     {
         return(LastZone.giveAllTheSteps(board, currentColor, Turn.currentRoll));
     }
     return(RegularZone.giveAllTheSteps(board, currentColor, Turn.currentRoll));
 }
Esempio n. 5
0
        public static List <OneStep> giveAllTheSteps(Board board, Color.color currentColor, List <int> roll)
        {
            List <OneStep> jailStep     = new List <OneStep>();
            bool           colorIsWhite = (currentColor == Color.color.white);


            foreach (int cube in roll)
            {
                int whichSpotFromJail = colorIsWhite ? (24 - cube) : cube - 1;
                if (board.SpotsOnBoard[whichSpotFromJail].color != ((colorIsWhite)?Color.color.black : Color.color.white) || board.SpotsOnBoard[whichSpotFromJail].numberOfTiles == 1)
                {
                    jailStep.Add(new OneStep(colorIsWhite? 25 : 24, whichSpotFromJail));
                }
            }
            return(jailStep);
        }
Esempio n. 6
0
 public int getNumberOfTiles(Color.color color)
 {
     return((color == Color.color.white) ? NumberOfWhiteTilesInJail : NumberOfBlackTilesInJail);
 }
Esempio n. 7
0
 public Player(Color.color color)
 {
     this.color      = color;
     isInTheLastZone = false;
 }
Esempio n. 8
0
        public static List <OneStep> giveAllTheSteps(Board board, Color.color currentColor, List <int> currentRoll)
        {
            int[]          arr        = currentRoll.ToArray();
            bool           colorWhite = currentColor == Color.color.white;
            int            boardSpot  = colorWhite ? 5 : 18;
            int            colorStep  = colorWhite ? -1 : 1;
            List <OneStep> resultList = new List <OneStep>();

            Array.Sort(arr);
            Array.Reverse(arr);
            int boardSpotFinish = colorWhite ? arr[0] - 1 : 24 - arr[0];

            for (; boardSpot + colorStep * (arr[0]) < 24 && boardSpot + colorStep * (arr[0]) >= 0; boardSpot += colorStep)
            {
                if (board.SpotsOnBoard[boardSpot].color == currentColor)
                {
                    for (int i = 0; i < arr.Length; i++)
                    {
                        if (checkIfWillAddToList(board, boardSpot, boardSpot + (arr[i]) * colorStep))
                        {
                            resultList.Add(new OneStep(boardSpot, boardSpot + colorStep * (arr[i])));
                        }
                    }
                }
            }

            if (board.SpotsOnBoard[boardSpot].color == currentColor)
            {
                resultList.Add(new OneStep(boardSpot, 26));
                if (arr.Length > 1 && arr[0] != arr[1])
                {
                    if (checkIfWillAddToList(board, boardSpot, boardSpot + (arr[1]) * colorStep))
                    {
                        resultList.Add(new OneStep(boardSpot, boardSpot + colorStep * (arr[1])));
                    }
                }
            }

            boardSpot += colorStep;

            while (resultList.Count == 0 && boardSpot >= 0 && boardSpot < 24)
            {
                if (board.SpotsOnBoard[boardSpot].color == currentColor)
                {
                    resultList.Add(new OneStep(boardSpot, 26));
                }
                boardSpot += colorStep;
                if (boardSpot > 24 || boardSpot < 0)
                {
                    return(resultList);
                }
            }

            if (arr.Length == 1 || arr[0] == arr[1])
            {
                return(resultList);
            }

            boardSpotFinish = colorWhite ? arr[1] - 1 : 24 - arr[1];

            for (; boardSpot + colorStep * (arr[1]) >= 0 && boardSpot + colorStep * (arr[1]) < 24; boardSpot += colorStep)
            {
                if ((board.SpotsOnBoard[boardSpot].color == currentColor) && (checkIfWillAddToList(board, boardSpot, boardSpot + (arr[1]) * colorStep)))
                {
                    resultList.Add(new OneStep(boardSpot, boardSpot + colorStep * (arr[1])));
                }
            }

            if (boardSpot < 24 && boardSpot > -1 && board.SpotsOnBoard[boardSpot].color == currentColor)
            {
                resultList.Add(new OneStep(boardSpot, 26));
            }

            return(resultList);
        }
Esempio n. 9
0
 public Spot(Color.color player, int numberOfTiles)
 {
     color = player;
     this.numberOfTiles = numberOfTiles;
 }
Esempio n. 10
0
 public Spot()
 {
     color         = Color.color.empty;
     numberOfTiles = 0;
 }
Esempio n. 11
0
 public static bool checkIfThereIsSomeOneInJail(Color.color color, Board board)
 {
     return(board.getNumberOfTiles(color) > 0);
 }