//================= Toks=============================// public static int SelectionStart() { random = new Random(); MainViewModel.MainViewModel main = new MainViewModel.MainViewModel(); int max = 15; int difficulty = Flow.DifficultyIdentifier(); int gettingID = 0; int ID = 0; string[] splitter = { " ", "/", "...", "-", ";", ":" }; switch (difficulty) { case 1: max = 15; break; case 2: max = 24; break; case 3: max = 28; break; case 4: max = 28; break; } if (Flow.GameTypeSetter().Equals(1))//Selection By Qoute { var QouteList = LocalSelection.SetSelectedQASList(); gettingID = random.Next(0, QouteList.Count + 1); var phrase = QouteList.Where(qoute => qoute.id.Equals(QouteList[gettingID].id)).Select(id => id.id.Equals(QouteList[gettingID].id)).FirstOrDefault(); var numword = QouteList.Where(qoute => qoute.id.Equals(QouteList[gettingID].id)).Select(id => id.primary_text).FirstOrDefault().Split(splitter, StringSplitOptions.RemoveEmptyEntries).Length; ID = QouteList[gettingID].id; while (phrase.Equals(null) || phrase.Equals(" ") || phrase.Equals("") || numword > max || numword <= 1) { gettingID = random.Next(0, QouteList.Count + 1); phrase = QouteList.Where(qoute => qoute.id.Equals(QouteList[gettingID].id)).Select(id => id.id.Equals(QouteList[gettingID].id)).FirstOrDefault(); numword = QouteList.Where(qoute => qoute.id.Equals(QouteList[gettingID].id)).Select(id => id.primary_text).FirstOrDefault().Split(splitter, StringSplitOptions.RemoveEmptyEntries).Length; ID = QouteList[gettingID].id; } } if (Flow.GameTypeSetter().Equals(2))//Selection By Sayings { var SayingList = LocalSelection.SetSelectedQASList(); gettingID = random.Next(1, SayingList.Count + 1); var phrase = SayingList.Where(qoute => qoute.id.Equals(gettingID)).Select(id => id.id.Equals(gettingID)).FirstOrDefault(); var numword = SayingList.Where(qoute => qoute.id.Equals(SayingList[gettingID].id)).Select(id => id.primary_text).FirstOrDefault().Split(splitter, StringSplitOptions.RemoveEmptyEntries).Length; while (phrase.Equals(null) || phrase.Equals(" ") || phrase.Equals("") || numword > max || numword <= 1) { gettingID = random.Next(1, SayingList.Count + 1); phrase = SayingList.Where(qoute => qoute.id.Equals(gettingID)).Select(id => id.id.Equals(gettingID)).FirstOrDefault(); numword = SayingList.Where(qoute => qoute.id.Equals(SayingList[gettingID].id)).Select(id => id.primary_text).FirstOrDefault().Split(splitter, StringSplitOptions.RemoveEmptyEntries).Length; } } return(gettingID); }
public static string ShowSource() { string showsource = ""; if (!Flow.GameInCategory()) { var Listing = LocalSelection.SetSelectedQASList(); showsource = Listing.Where(id => id.id.Equals(LocalSelection.SetIDs()[Flow.CurrentRound()])).Select(s => s.secondary_text).FirstOrDefault(); } else { var Listing = CategoryLoad.SetSelectedQASList(); showsource = Listing.Where(id => id.id.Equals(CategoryLoad.LoadSelectedToks()[Flow.CurrentRound()])).Select(s => s.secondary_text).FirstOrDefault(); } /* if (!CrossConnectivity.Current.IsConnected) * { * MainViewModel.MainViewModel main = new MainViewModel.MainViewModel(); * * if (Flow.GameTypeSetter().Equals(1))//Selection By Qoute * { * showsource = main.Qoutes.Where(id => id.id.Equals(IDGetter())).Select(s => s.QouteSource).FirstOrDefault(); * } * if (Flow.GameTypeSetter().Equals(2))//Selection By Sayings * { * showsource = main.Sayings.Where(id => id.id.Equals(IDGetter())).Select(s => s.SayingSource).FirstOrDefault(); * } * * } * else { * if (Flow.GameTypeSetter().Equals(1))//Selection By Qoute * { * showsource = SetOnlineQoutes().Where(id => id.QouteID.Equals(SetOnlineID())).Select(sources => sources.QoutesSource).FirstOrDefault(); * } * else { * showsource = ""; * } * }*/ return(showsource); }
public static void PhraseSelectionInitiate() { char[] trimmer = new char[] { ' ', '!', ',', '.', '/', '?', '"', ':', ';', '(', ')', '"' }; string[] splitter = { " ", "/", "...", "-", ";", ":", " " }; int selected = SelectionStart(); random = new Random(); MainViewModel.MainViewModel main = new MainViewModel.MainViewModel(); string[] disect = { " " }; var selectedphrase = ""; if (!Flow.GameInCategory()) { var Listing = LocalSelection.SetSelectedQASList(); phraselect = LocalSelection.SetIDs()[Flow.CurrentRound()]; selectedphrase = Listing.Where(qoute => qoute.id.Equals(phraselect)).Select(phrase => phrase.primary_trimmed).FirstOrDefault(); disect = selectedphrase.Split(splitter, StringSplitOptions.RemoveEmptyEntries); AllWords = disect; } else { var Listing = CategoryLoad.SetSelectedQASList(); phraselect = CategoryLoad.LoadSelectedToks()[Flow.CurrentRound()]; selectedphrase = Listing.Where(qoute => qoute.id.Equals(phraselect)).Select(phrase => phrase.primary_trimmed).FirstOrDefault(); disect = selectedphrase.Split(splitter, StringSplitOptions.RemoveEmptyEntries); AllWords = disect; } /* * bool flagcheck = true; * int infichecker = 0; * * int difficutly = Flow.DifficultyIdentifier(); * switch (difficutly) * { * case 1: * while (flagcheck) * { * infichecker++; * if (infichecker.Equals(50)) * { * diditloop = true; * } * else * { * diditloop = false; * } * * for (int i = 0; i < disect.Length; i++) * { * if (disect[i].Trim(trimmer).Length < 5) * { * flagcheck = false; * } * * } * for (int idc = 0; idc < IdBank.Length; idc++) * { * if (IdBank[idc].Equals(phraselect)) * { * flagcheck = true; * break; * } * } * * if (flagcheck) * { * * selected = SelectionStart(); * //phraselect = SelectionStart(); * phraselect = Listing[selected].id; * IDGetter(); * selectedphrase = Listing.Where(qoute => qoute.id.Equals(phraselect)).Select(phrase => phrase.primary_text).FirstOrDefault(); * disect = selectedphrase.Split(splitter, StringSplitOptions.RemoveEmptyEntries); * AllWords = disect; * } * AllWords = disect; * * } * break; * case 2: * while (flagcheck) * { * infichecker++; * if (infichecker.Equals(50)) * { * diditloop = true; * } * else * { * diditloop = false; * } * * for (int i = 0; i < disect.Length; i++) * { * if (disect[i].Trim(trimmer).Length >= 4 && disect[i].Trim(trimmer).Length <= 6) * { * flagcheck = false; * } * * } * for (int idc = 0; idc < IdBank.Length; idc++) * { * if (IdBank[idc].Equals(phraselect)) * { * flagcheck = true; * break; * } * } * if (flagcheck) * { * selected = SelectionStart(); * phraselect = Listing[selected].id; * IDGetter(); * selectedphrase = Listing.Where(qoute => qoute.id.Equals(phraselect)).Select(phrase => phrase.primary_text).FirstOrDefault(); * disect = selectedphrase.Split(splitter, StringSplitOptions.RemoveEmptyEntries); * AllWords = disect; * } * AllWords = disect; * * } * * break; * case 3: * while (flagcheck) * { * infichecker++; * if (infichecker.Equals(50)) * { * diditloop = true; * } * else * { * diditloop = false; * } * * for (int i = 0; i < disect.Length; i++) * { * if (disect[i].Trim(trimmer).Length >= 6 && disect[i].Trim(trimmer).Length <= 8) * { * flagcheck = false; * } * * } * for (int idc = 0; idc < IdBank.Length; idc++) * { * if (IdBank[idc].Equals(phraselect)) * { * flagcheck = true; * break; * } * } * if (flagcheck) * { * selected = SelectionStart(); * phraselect = Listing[selected].id; * IDGetter(); * selectedphrase = Listing.Where(qoute => qoute.id.Equals(phraselect)).Select(phrase => phrase.primary_text).FirstOrDefault(); * disect = selectedphrase.Split(splitter, StringSplitOptions.RemoveEmptyEntries); * AllWords = disect; * } * AllWords = disect; * * } * * break; * case 4: * while (flagcheck) * { * * infichecker++; * if (infichecker.Equals(50)) * { * diditloop = true; * } * else * { * diditloop = false; * } * * for (int i = 0; i < disect.Length; i++) * { * if (disect[i].Trim(trimmer).Length >= 9 && disect[i].Trim(trimmer).Length <= 12) * { * flagcheck = false; * } * * } * for (int idc = 0; idc < IdBank.Length; idc++) * { * if (IdBank[idc].Equals(phraselect)) * { * flagcheck = true; * break; * } * } * if (flagcheck) * { * selected = SelectionStart(); * phraselect = Listing[selected].id; ; * IDGetter(); * selectedphrase = Listing.Where(qoute => qoute.id.Equals(phraselect)).Select(phrase => phrase.primary_text).FirstOrDefault(); * disect = selectedphrase.Split(splitter, StringSplitOptions.RemoveEmptyEntries); * AllWords = disect; * } * AllWords = disect; * * } * * break; * }*/ GetThisPhrase(selectedphrase); IdBank[Flow.CurrentRound()] = phraselect; SelectedPhrase(); IDGetter(); }
public static void LoadCategoryBy(string category) { SelectedIDs = new int[5]; Random rand = new Random(); string group = category; string[] splitter = { " ", "/", "...", "-", ";", ":" }; int[] SelectedToksByID = new int[5]; var result = JsonConvert.DeserializeObject <List <QoutesAndSayings> >(LocalSelection.GetQoutesAndSayings()); List <QoutesAndSayings> list = new List <QoutesAndSayings>(); for (int i = 0; i < result.Count; i++) { if (result[i].category.ToLower() == group.ToLower() && list.Count < 120) { list.Add(new QoutesAndSayings { id = result[i].id, tok_group = result[i].tok_group, category = result[i].category, primary_text = result[i].primary_text, secondary_text = result[i].secondary_text, }); } } TotalToks = list.Count; int randomed = 0; string[] AnsweredToks = { }; string DataValue = string.Empty; string Datas = string.Empty; if (Application.Current.Properties.ContainsKey(category.ToUpper())) { Datas = Application.Current.Properties[category.ToUpper()].ToString(); AnsweredToks = Application.Current.Properties[category.ToUpper()].ToString().TrimEnd('-').Split('-'); Answered = AnsweredToks.Length; } else { Answered = 0; } ToksLeft = TotalToks - AnsweredToks.Length; for (int i = 0; i < 5; i++) { bool clearedSaved = true; bool clearedSelect = true; randomed = rand.Next(0, TotalToks); if (Answered == 0) { clearedSaved = false; } while (clearedSaved || clearedSelect) { for (int j = 0; j < Answered; j++) { if (AnsweredToks[j] != list[randomed].id.ToString()) { clearedSaved = false; } else { randomed = rand.Next(0, TotalToks); clearedSaved = true; break; } } for (int j = 0; j < 5; j++) { if (SelectedToksByID[j] != list[randomed].id) { clearedSelect = false; } else { randomed = rand.Next(0, TotalToks); clearedSelect = true; break; } } } SelectedToksByID[i] = list[randomed].id; DataValue += list[randomed].id + "-"; } GetSaves(Datas, DataValue); SelectedIDs = SelectedToksByID; SetTotalToks(); SetToksLeft(); SetWhatPart(); GetAllQASList(list); LoadSelectedToks(); }
public static void LoadTheCategory(string category) { LocalSelection.ConvertToList(); int NumberOfItems = 0; Random rand = new Random(); string[] splitter = { " ", "/", "...", "-", ";", ":" }; var list = LocalSelection.SetAllSelectedQuoteAndSayingsList(); for (int i = 0; i < list.Count; i++) { if (list[i].category.ToLower() == category.ToLower()) { NumberOfItems++; } } TotalToks = NumberOfItems; int[] IDs = new int[NumberOfItems]; for (int i = 0; i < list.Count; i++) { if (list[i].category.ToLower() == category.ToLower() && IDs.Length < NumberOfItems) { IDs[i] = list[i].id; } } int[] SelectedToksByID = new int[5]; string[] AnsweredToks = { }; string DataValue = string.Empty; if (Application.Current.Properties.ContainsKey(category)) { DataValue += Application.Current.Properties[category].ToString(); AnsweredToks = Application.Current.Properties[category].ToString().Split('-'); } ToksLeft = TotalToks - AnsweredToks.Length; Answered = AnsweredToks.Length; int randomed = rand.Next(0, IDs.Length); for (int i = 0; i < 5; i++) { for (int j = 0; j < AnsweredToks.Length; j++) { if (AnsweredToks[j] == IDs[randomed].ToString()) { randomed = rand.Next(0, IDs.Length); j = 0; } } SelectedToksByID[i] = IDs[randomed]; if (i <= 3) { DataValue += IDs[randomed] + "-"; } else { DataValue += IDs[randomed].ToString(); } randomed = rand.Next(0, IDs.Length); } if (Application.Current.Properties.ContainsKey(category)) { Application.Current.Properties[category] = DataValue; } else { Application.Current.Properties.Add(category, DataValue); } Application.Current.SavePropertiesAsync(); SelectedIDs = SelectedToksByID; SetTotalToks(); SetToksLeft(); SetWhatPart(); LoadSelectedToks(); }