Ejemplo n.º 1
0
        /// <summary>
        /// Returns list of moves that can be done with a specific hand
        /// </summary>
        /// <param name="board">string array of letters on the board for that</param>
        /// <param name="hand">List of length 1 strings in the player's hand</param>
        /// <param name="rowOrCol">Position</param>
        /// <param name="col">True if it runs up/down</param>
        /// <returns>List of moves, formed in an array [string word, int[1,1] position, bool NorthSouth]</returns>
        public List <Move> GetMovesInArray(ScrabbleBoard board, List <string> hand, string[] rowOrCol, bool col, int pos)
        {
            List <Move>   moves        = new List <Move>();
            List <string> boardLetters = new List <string>();
            Move          possibleMove;

            int[] position = new int[2];
            foreach (string letter in rowOrCol)
            {
                if (letter != null)
                {
                    boardLetters.Add(letter);
                }
            }
            foreach (string word in GetPossibleWordsForRow(hand, boardLetters))
            {
                for (int c = 0; c + word.Length < (col ? board.GetCol(pos).Length : board.GetRow(pos).Length); c++)
                {
                    position[0]  = (col ? pos : c);
                    position[1]  = (col ? board.GetRow(pos).Length - 1 - c : pos);
                    possibleMove = new Move(word, position, col);
                    if (board.CheckIfValidMove(word, position, col, hand))
                    {
                        moves.Add(possibleMove.Clone());
                    }
                }
            }
            return(moves);
        }