/// Adds a term to the main list, and to the provided set. public void AddNewTerm(Term term, StudySet set) { allTermsD.Add(term.myGuid, term); allTermsL.Add(term); term.mySet = set; // set ref to set. set.AddTerm(term.myGuid); }
public void MoveTermToSet(Term term, StudySet newSet) { // Swap its set. StudySet prevSet = term.mySet; prevSet.RemoveTerm(term.myGuid); newSet.AddTerm(term.myGuid); // If it's not a main set, then also attempt to remove from the remix sets. if (!newSet.canIncludeMeInRemixes) { library.RemoveTermFromRemixSets(term.myGuid); } // Save! SaveStudySetLibrary(); }
// ---------------------------------------------------------------- // Sourdough Handling // ---------------------------------------------------------------- public void RefillSourdoughSet() { // FIRST, update the terms in the sourdough set! StudySet setSD = library.setSourdough; List <string> termsLeave = new List <string>(); List <string> termsStay = new List <string>(); foreach (string termG in setSD.allTermGs) { if (setSD.pileNoG.Contains(termG) || setSD.pileQueueG.Contains(termG)) { termsStay.Add(termG); } else { termsLeave.Add(termG); } } foreach (string termG in termsLeave) { library.GetTerm(termG).nSDLeaves++; } foreach (string termG in termsStay) { library.GetTerm(termG).nSDStays++; } // Remove the yes-ed terms entirely from the set! for (int i = 0; i < termsLeave.Count; i++) { setSD.RemoveTerm(termsLeave[i]); } // Refill the holes! int numToAdd = SourdoughMaxTerms - setSD.allTermGs.Count; // Make a safe copy-list of all terms! List <Term> allTerms = library.GetOnlyMainTerms(); // Remove terms that are gonna STAY in Sourdough from the all-terms list, so we don't accidentally add the same ones again. for (int i = 0; i < termsStay.Count; i++) { Term term = library.GetTerm(termsStay[i]); allTerms.Remove(term); } // Shuffle them all, then sort them by sourdough wins. GameUtils.Shuffle(allTerms); //allTerms = allTerms.OrderBy(c => c.yToNPlusRatio).ToList(); // TEST! Put the hard ones in first. allTerms = allTerms.OrderBy(c => c.nSDLeaves).ToList(); // Add the right amount to the set. for (int i = 0; i < numToAdd && i < allTerms.Count; i++) { setSD.AddTerm(allTerms[i].myGuid); } setSD.ShuffleAndRestartDeck(); // Save library SaveStudySetLibrary(); // Finally, save WHEN we last refilled (now)! SaveStorage.SetDateTime(SaveKeys.SourdoughTimeLastRefilled, DateTime.Now); }