private bool FinishItem(PgPowerTier item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, string parsedFile, string parsedKey)
        {
            bool Result = true;

            foreach (KeyValuePair <string, object> Entry in contentTable)
            {
                string Key   = Entry.Key;
                object Value = Entry.Value;

                switch (Key)
                {
                case "EffectDescs":
                    Result = ParseEffectDescriptionList(item.EffectList, Value, parsedFile, parsedKey);
                    break;

                case "SkillLevelPrereq":
                    Result = SetIntProperty((int valueInt) => item.RawSkillLevelPrereq = valueInt, Value);
                    break;

                case "MinLevel":
                    Result = SetIntProperty((int valueInt) => item.RawMinLevel = valueInt, Value);
                    break;

                case "MaxLevel":
                    Result = SetIntProperty((int valueInt) => item.RawMaxLevel = valueInt, Value);
                    break;

                case "MinRarity":
                    Result = ParseKeywordAsMinRarity(item, Value, parsedFile, parsedKey);
                    break;

                default:
                    Result = Program.ReportFailure(parsedFile, parsedKey, $"Key '{Key}' not handled");
                    break;
                }

                if (!Result)
                {
                    break;
                }
            }

            if (Result)
            {
                if (!item.RawSkillLevelPrereq.HasValue)
                {
                    Result = Program.ReportFailure(parsedFile, parsedKey, $"Power has no skill level requirement");
                }
            }

            return(Result);
        }
 private static int SortByLevel(PgPowerTier tier1, PgPowerTier tier2)
 {
     if (tier1.Level < tier2.Level)
     {
         return(-1);
     }
     else if (tier1.Level > tier2.Level)
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
Example #3
0
        private static void UpdateIconFromPowerTiers(PgPower power, ref int iconId)
        {
            Debug.Assert(power.TierList.Count > 0);

            PgPowerTier PowerTier = power.TierList[power.TierList.Count - 1];

            if (PowerTier.EffectList.Count > 0)
            {
                foreach (PgPowerEffect PowerEffect in PowerTier.EffectList)
                {
                    List <int> IconIdList = new List <int>();

                    if (PowerEffect is PgPowerEffectSimple AsSimple)
                    {
                        IconIdList = AsSimple.IconIdList;
                    }
                    else if (PowerEffect is PgPowerEffectAttribute AsAttribute && AsAttribute.AttributeRef != null)
                    {
                        IconIdList = AsAttribute.AttributeRef.IconIdList;
                    }

                    foreach (int Id in IconIdList)
                    {
                        if (Id > 0)
                        {
                            iconId = Id;
                            break;
                        }
                    }

                    if (iconId > 0)
                    {
                        break;
                    }
                }
            }
        }