private void PopulateRegimens(string Type, TableLayoutPanel TLP, List <RegimenInfo> list) { // Get a list of all Regimen Attregutes in the PKM var RegimenNames = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), Type); list.AddRange(from RegimenName in RegimenNames let RegimenValue = ReflectUtil.GetValue(pkm, RegimenName) where RegimenValue is bool select new RegimenInfo(RegimenName, (bool)RegimenValue)); TLP.ColumnCount = 1; TLP.RowCount = 0; // Add Regimens foreach (var reg in list) { AddRegimenChoice(reg, TLP); } // Force auto-size foreach (RowStyle style in TLP.RowStyles) { style.SizeType = SizeType.AutoSize; } foreach (ColumnStyle style in TLP.ColumnStyles) { style.SizeType = SizeType.AutoSize; } }
/// <summary> /// Fix invalid and missing ribbons. (V600 and V601) /// </summary> /// <param name="pk">PKM whose ribbons need to be fixed</param> public static void FixRibbons(PKM pk) { string Report = new LegalityAnalysis(pk).Report(); if (Report.Contains(String.Format(V600, ""))) { string[] ribbonList = Report.Split(new string[] { String.Format(V600, "") }, StringSplitOptions.None)[1].Split(new string[] { "\r\n" }, StringSplitOptions.None)[0].Split(new string[] { ", " }, StringSplitOptions.None); var RibbonNames = ReflectUtil.GetPropertiesStartWithPrefix(pk.GetType(), "Ribbon").Distinct(); List <string> missingRibbons = new List <string>(); foreach (var RibbonName in RibbonNames) { string v = RibbonStrings.GetName(RibbonName).Replace("Ribbon", ""); if (ribbonList.Contains(v)) { missingRibbons.Add(RibbonName); } } foreach (string missing in missingRibbons) { if (missing == "RibbonCountMemoryBattle" || missing == "RibbonCountMemoryContest") { ReflectUtil.SetValue(pk, missing, 0); } else { ReflectUtil.SetValue(pk, missing, -1); } } } if (Report.Contains(String.Format(V601, ""))) { string[] ribbonList = Report.Split(new string[] { String.Format(V601, "") }, StringSplitOptions.None)[1].Split(new string[] { "\r\n" }, StringSplitOptions.None)[0].Split(new string[] { ", " }, StringSplitOptions.None); var RibbonNames = ReflectUtil.GetPropertiesStartWithPrefix(pk.GetType(), "Ribbon").Distinct(); List <string> invalidRibbons = new List <string>(); foreach (var RibbonName in RibbonNames) { string v = RibbonStrings.GetName(RibbonName).Replace("Ribbon", ""); if (ribbonList.Contains(v)) { invalidRibbons.Add(RibbonName); } } foreach (string invalid in invalidRibbons) { if (invalid == "RibbonCountMemoryBattle" || invalid == "RibbonCountMemoryContest") { ReflectUtil.SetValue(pk, invalid, 0); } else { ReflectUtil.SetValue(pk, invalid, false); } } } }
private static IEnumerable <RegimenInfo> GetBooleanRegimenNames(ISuperTrain pkm, string propertyPrefix) { var names = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), propertyPrefix); foreach (var name in names) { var value = ReflectUtil.GetValue(pkm, name); if (value is bool state) { yield return(new RegimenInfo(name, state)); } } }
public IEnumerable <FlagPairG1Detail> GetFlagPairs() { var pz = ReflectUtil.GetPropertiesStartWithPrefix(GetType(), FlagPropertyPrefix); foreach (var pair in pz) { if (ReflectUtil.GetValue(this, pair) is not FlagPairG1 p) { continue; } yield return(new FlagPairG1Detail(p, pair, EventFlags, SpawnFlags)); } }
private void PopulateRibbons() { // Get a list of all Ribbon Attributes in the PKM var RibbonNames = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), "Ribbon").Distinct(); foreach (var RibbonName in RibbonNames) { object RibbonValue = ReflectUtil.GetValue(pkm, RibbonName); if (RibbonValue is int x) { riblist.Add(new RibbonInfo(RibbonName, x)); } if (RibbonValue is bool b) { riblist.Add(new RibbonInfo(RibbonName, b)); } } TLP_Ribbons.ColumnCount = 2; TLP_Ribbons.RowCount = 0; // Add Ribbons foreach (var rib in riblist) { AddRibbonSprite(rib); } foreach (var rib in riblist.OrderBy(z => RibbonStrings.GetName(z.Name))) { AddRibbonChoice(rib); } // Force auto-size foreach (RowStyle style in TLP_Ribbons.RowStyles) { style.SizeType = SizeType.AutoSize; } foreach (ColumnStyle style in TLP_Ribbons.ColumnStyles) { style.SizeType = SizeType.AutoSize; } }
/// <summary> /// Colosseum/XD pokemon need to be fixed. Fix Gender further in logic using <see cref="FixGender(PKM)"/> /// </summary> /// <param name="pkm">PKM to apply the fix to</param> public static void ColosseumFixes(PKM pkm) { if (pkm.Version == 15) { var RibbonNames = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), "Ribbon").Distinct(); foreach (var RibbonName in RibbonNames) { if (RibbonName == "RibbonCountMemoryBattle" || RibbonName == "RibbonCountMemoryContest") { ReflectUtil.SetValue(pkm, RibbonName, 0); } else { ReflectUtil.SetValue(pkm, RibbonName, false); } } ReflectUtil.SetValue(pkm, "RibbonNational", true); pkm.Ball = 4; pkm.FatefulEncounter = true; pkm.OT_Gender = 0; } }
private static bool GetIncorrectRibbonsEgg(PKM pk, IEncounterTemplate enc) { var names = ReflectUtil.GetPropertiesStartWithPrefix(pk.GetType(), RibbonInfo.PropertyPrefix); if (enc is IRibbonSetEvent3 event3) { names = names.Except(event3.RibbonNames()); } if (enc is IRibbonSetEvent4 event4) { names = names.Except(event4.RibbonNames()); } foreach (var value in names.Select(name => ReflectUtil.GetValue(pk, name))) { if (value is null) { continue; } if (HasFlag(value) || HasCount(value)) { return(true); }
/// <summary> /// Get ribbon names of a pkm /// </summary> /// <param name="pk">pokemon</param> /// <returns></returns> private static IEnumerable <string> GetRibbonNames(PKM pk) => ReflectUtil.GetPropertiesStartWithPrefix(pk.GetType(), "Ribbon").Distinct();
private static IEnumerable <string> DumpStrings(Type t) { var props = ReflectUtil.GetPropertiesStartWithPrefix(t, string.Empty); return(props.Select(p => $"{p}{TranslationSplitter}{ReflectUtil.GetValue(t, p)}")); }