Ejemplo n.º 1
0
        private bool FinishItem(PgAdvancement 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;

                PgAttribute ParsedAttribute = null !;
                float       ParsedValue     = 0;

                if (Key == "MENTAL_DEFENSE_RATING")
                {
                    continue;
                }

                Result = Inserter <PgAttribute> .SetItemByKey((PgAttribute valueAttribute) => ParsedAttribute = valueAttribute, Key);

                if (Result)
                {
                    if (Value is float FloatValue)
                    {
                        ParsedValue = FloatValue;
                    }
                    else if (Value is int IntValue)
                    {
                        ParsedValue = IntValue;
                    }
                    else
                    {
                        Result = Program.ReportFailure(parsedFile, parsedKey, $"Unknown attribute value '{Value}'");
                    }
                }

                if (Result)
                {
                    PgAdvancementEffectAttribute NewAdvancementEffectAttribute = new PgAdvancementEffectAttribute()
                    {
                        Attribute_Key = ParsedAttribute.Key, RawValue = ParsedValue
                    };

                    ParsingContext.AddSuplementaryObject(NewAdvancementEffectAttribute);
                    item.EffectAttributeList.Add(NewAdvancementEffectAttribute);
                }
            }

            return(Result);
        }
Ejemplo n.º 2
0
        private bool ParseAdvancementTable(PgSkill item, object value, string parsedFile, string parsedKey)
        {
            if (value == null)
            {
                return(true);
            }

            if (!(value is string TableString))
            {
                return(Program.ReportFailure($"Value '{value}' was expected to be a string"));
            }

            Dictionary <string, ParsingContext> Table = ParsingContext.ObjectKeyTable[typeof(PgAdvancementTable)];

            foreach (KeyValuePair <string, ParsingContext> Entry in Table)
            {
                ParsingContext Context = Entry.Value;

                if (!(Context.Item is PgAdvancementTable AsAdvancementTable))
                {
                    return(Program.ReportFailure($"Object '{Context.Item}' was unexpected"));
                }

                if (AsAdvancementTable.InternalName == TableString)
                {
                    foreach (KeyValuePair <int, PgAdvancement> AdvancementEntry in AsAdvancementTable.LevelTable)
                    {
                        int           Level       = AdvancementEntry.Key;
                        PgAdvancement Advancement = AdvancementEntry.Value;

                        foreach (PgAdvancementEffectAttribute EffectAttribute in Advancement.EffectAttributeList)
                        {
                            PgSkillAdvancement NewSkillAdvancement = new PgSkillAdvancementRewardAdvancement()
                            {
                                RawLevel = Level, EffectAttribute = EffectAttribute
                            };

                            ParsingContext.AddSuplementaryObject(NewSkillAdvancement);
                            item.SkillAdvancementList.Add(NewSkillAdvancement);
                        }
                    }

                    return(true);
                }
            }

            return(Program.ReportFailure($"Advancement table '{TableString}' not found"));
        }