Ejemplo n.º 1
0
 public virtual void Clear()
 {
     OriginalEntries = null;
     RandomizableEntries.Clear();
     AssociatedWrappers.Clear();
     OnAfterSelectRandomizableBeforeRandomize = null;
     OnAfterEverything = null;
 }
Ejemplo n.º 2
0
 protected override void AfterSelectRandomizableBeforeRandomize()
 {
     for (int i = OriginalEntries.Count - 1; i > -1; i--)
     {
         TEntry entry = OriginalEntries[i];
         if (IDsToDuplicateAndRandomize.Any((id) => entry.GetName().StartsWith(id)))
         {
             TEntry clone = entry.Clone();
             OriginalEntries.Add(clone);
             RandomizableEntries.Add(clone);
             AssociatedWrappers.Add(clone.GetWrapper <TWrapper, TEntry>());
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns randomized entries, the returned list is a new object rather than <paramref name="entries"/>
        /// </summary>
        public void Randomize(List <TEntry> entries)
        {
            OriginalEntries = entries;
            BeforeEverything();

            RandomizableEntries.AddRange(entries.Where(IsRandomizable));
            AssociatedWrappers.AddRange(RandomizableEntries.Select((entry) => entry.GetWrapper <TWrapper, TEntry>()));

            OnAfterSelectRandomizableBeforeRandomize?.Invoke(OriginalEntries, RandomizableEntries, AssociatedWrappers);
            AfterSelectRandomizableBeforeRandomize();
            if (RandomizableEntries.Count != AssociatedWrappers.Count)
            {
                throw new Exception("Ensure that RandomizableEntries and AssociatedWrappers always have equal counts");
            }

            RandomizableEntries.Shuffle();
            for (int i = 0; i < RandomizableEntries.Count; i++)
            {
                AssociatedWrappers[i].ReadToEntry(RandomizableEntries[i]);
            }

            OnAfterEverything?.Invoke(OriginalEntries, RandomizableEntries, AssociatedWrappers);
        }