private bool FinishItem(PgPowerTierList item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, string parsedFile, string parsedKey) { foreach (KeyValuePair <string, object> Entry in contentTable) { string Key = Entry.Key; object Value = Entry.Value; if (!Key.StartsWith("id_") || !int.TryParse(Key.Substring(3), out int Level)) { return(Program.ReportFailure($"Invalid power tier key '{Key}'")); } if (!(Value is ParsingContext Context)) { return(Program.ReportFailure($"Value '{Value}' was expected to be a context")); } if (!(Context.Item is PgPowerTier AsPowerTier)) { return(Program.ReportFailure($"Object '{Value}' was unexpected")); } AsPowerTier.Level = Level; item.TierList.Add(AsPowerTier); } item.TierList.Sort(SortByLevel); return(true); }
private static bool ParseTiers(PgPower item, object value, string parsedFile, string parsedKey) { PgPowerTierList PowerTierList = null !; if (!Inserter <PgPowerTierList> .SetItemProperty((PgPowerTierList valuePowerTierList) => PowerTierList = valuePowerTierList, value)) { return(false); } if (PowerTierList.TierList.Count == 0) { return(Program.ReportFailure(parsedFile, parsedKey, $"Power with no tiers")); } item.TierList = PowerTierList.TierList; return(true); }