/// <summary> /// Returns a deep-copy list of filtered kaomojis from flags. /// </summary> public static List <Kaomoji> GetKaomojis(RegistryFilter filter, KaomojiFlags flags) { //Load data if not already loaded. if (!KaomojiDataHandler.IsLoaded) { KaomojiDataHandler.Load(); } List <Kaomoji> filterCopy = new List <Kaomoji>(); foreach (Kaomoji kaomoji in Registry) { if (filter == RegistryFilter.AllowOnly) { if (!kaomoji.Flags.ContainsFlag(flags)) { continue; } } //if(filter == RegistryFilter.Exclude) //TODO change this if more filters are added! else { if (kaomoji.Flags.ContainsFlag(flags)) { continue; } } filterCopy.Add((Kaomoji)kaomoji.Clone()); } return(filterCopy); }
/// <summary> /// Checks to see if both KaomojiFlags share a flag. /// </summary> /// <param name="flags">Flags to compare to.</param> /// <returns>A flag is found to be true in both KaomojiFlags.</returns> public bool ContainsFlag(KaomojiFlags flags) { for (int i = 0; i < bits.Length; i++) { if (bits.Get(i) && flags.bits.Get(i)) { return(true); } } return(false); }
/// <summary> /// Finds a random Kaomoji with the specified filter parameters. /// </summary> public static Kaomoji GetRandom(RegistryFilter filter, KaomojiFlags flags) { Kaomoji kaomoji = GetRandom(false); if (filter == RegistryFilter.AllowOnly) { while (!kaomoji.Flags.ContainsFlag(flags)) { kaomoji = GetRandom(false); } } //if(filter == RegistryFilter.Exclude) //TODO change this if more filters are added! else { while (kaomoji.Flags.ContainsFlag(flags)) { kaomoji = GetRandom(false); } } return((Kaomoji)kaomoji.Clone()); }
public Kaomoji(string emoticon, KaomojiFlags flags) { Emoticon = emoticon; Flags = flags; }