List <string> GenerateInput() { /** * Todo: * if state is empty, then select a random number among 1-6 * if the number 'n' is less than 6 then select another number between 1 to 6-n * keep repeating till the numbers do not total 6 * now for each number, open the json and select a random word containing the equal amount of parts as the number * Convert the unicode value to Bijoy * Put it into input box */ // if(stateEmpty) //{ // var x = 0; // for debugging purpose Debug.Log("GenerateInput() was called"); var random = new System.Random(); var total = 0; string words = ""; List <string> dividedWords = new List <string>(); //Debug.Log($"Still working {++x}"); Dictionary <string, List <string> > elist = JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(File.ReadAllText(dictfile)); //Debug.Log($"Still working {++x}"); List <int> wordPartsNumber = new List <int>(); //Debug.Log($"Still working {++x}"); var u2b = new UniToBijoy(); //Debug.Log($"Still working {++x}"); while (total < 6) { var currentNumber = random.Next(1, 6 - total); wordPartsNumber.Add(currentNumber); total += currentNumber; } foreach (var item in wordPartsNumber) { int rand = random.Next(elist[item.ToString()].Count); words += elist[item.ToString()][rand]; } // Divide the words into parts if parts is greater than one dividedWords = BanglaHandler.DividedWords(words); foreach (var part in dividedWords) { Debug.Log(part); } //Convert them to Bijoy for (int i = 0; i < dividedWords.Count; i++) { dividedWords[i] = u2b.Convert(dividedWords[i]); } foreach (var part in dividedWords) { Debug.Log(part); } return(dividedWords); }
List <string> GenerateInput() { var random = new System.Random(); string words = ""; List <string> dividedWords = new List <string>(); var currentNumber = random.Next(1, 6); Dictionary <string, List <string> > elist = JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(File.ReadAllText(dictfile)); int rand = random.Next(elist[currentNumber.ToString()].Count); words += elist[currentNumber.ToString()][rand]; dividedWords = BanglaHandler.DividedWords(words); var u2b = new UniToBijoy(); for (int i = 0; i < dividedWords.Count; i++) { dividedWords[i] = u2b.Convert(dividedWords[i]); } currentWord = words; return(dividedWords); }