예제 #1
0
        public List <GameBoardPosition> CheckValidMove(Player player, Piece piece)
        {
            List <GameBoardPosition> positions = new List <GameBoardPosition>();

            bool flag      = true;
            int  diceValue = Dice.DiceValue;

            if (piece.GameBoardPosition.Ghor.Position != 18)
            {
                // From Home, only 6 can make him move to Start Star
                if (piece.GameBoardPosition.Ghor.GhorType == GhorType.Home)
                {
                    if (Dice.DiceValue == 6)
                    {
                        diceValue = 1;
                    }
                    else
                    {
                        flag = false;
                    }
                }

                if (flag)
                {
                    GameBoardPosition currentPiecePosition =
                        new GameBoardPosition(piece.GameBoardPosition.Quadrant, piece.GameBoardPosition.Ghor);
                    positions =
                        GameBoardForm.GetNthGhorPosition(currentPiecePosition, diceValue, player, positions);
                }
            }

            return(positions);
        }
예제 #2
0
        public List <GameBoardPosition> GetNthGhorPosition(
            GameBoardPosition gameBoardPosition, int count, Player player, List <GameBoardPosition> positions)
        {
            bool flag = false;

            if (count >= 1 && count <= 6)
            {
                for (int i = 0; i < count; i++)
                {
                    gameBoardPosition = this.GetNextGhor(gameBoardPosition, player);
                    if (gameBoardPosition == null)
                    {
                        flag = true;
                        break;
                    }
                    positions.Add(gameBoardPosition);
                }
            }
            if (flag)
            {
                positions.Clear();
            }

            return(positions);
        }
예제 #3
0
        public GameBoardPosition GetNextGhor(GameBoardPosition gameBoardPosition, Player player)
        {
            if (gameBoardPosition != null)
            {
                Ghor     ghor     = gameBoardPosition.Ghor;
                Quadrant quadrant = gameBoardPosition.Quadrant;

                if (ghor != null && ghor.Position == 18)
                {
                    return(null);
                }
                else if (ghor.GhorType == GhorType.Home)
                {
                    // Move to Home Star
                    gameBoardPosition.Ghor = quadrant.GhorPath[1];
                }
                else if (ghor.Position == 11)
                {
                    //Move to Next Quadrant
                    gameBoardPosition.Quadrant = this.GetNextQuadrant(quadrant);
                    gameBoardPosition.Ghor     = gameBoardPosition.Quadrant.GhorPath[12];
                }
                else if (ghor.Position == 12)
                {
                    if (gameBoardPosition.Quadrant.Color == player.Color)
                    {
                        // Move to Final Line
                        gameBoardPosition.Ghor = gameBoardPosition.Quadrant.GhorPath[13];
                    }
                    else
                    {
                        gameBoardPosition.Ghor = gameBoardPosition.Quadrant.GhorPath[0];
                    }
                }
                else if (ghor == quadrant.GetLastGhor())
                {
                    // Matured
                    gameBoardPosition.Ghor = new Ghor(18);
                }
                else
                {
                    // Proceed One ghor
                    gameBoardPosition.Ghor = quadrant.GhorPath[ghor.Position + 1];
                }

                return(gameBoardPosition);
            }
            else
            {
                return(null);
            }
        }