示例#1
0
        private bool ParseDuration(PgEffect item, object value, string parsedFile, string parsedKey)
        {
            int ValueInt;

            if (value is int AsIntDirect)
            {
                ValueInt = AsIntDirect;
            }
            else if (value is string AsString && int.TryParse(AsString, out int AsInt))
            {
                ValueInt = AsInt;
            }
示例#2
0
        private bool ParseSourceEffect(ref object?item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, string parsedFile, string parsedKey)
        {
            if (!contentTable.ContainsKey("EffectName"))
            {
                return(Program.ReportFailure(parsedFile, parsedKey, "Source has no effect name"));
            }

            if (!(contentTable["EffectName"] is string EffectNameString))
            {
                return(Program.ReportFailure("Source effect name was expected to be a string"));
            }

            if (EffectNameString == "Learn Ability")
            {
                item = new PgSourceLearnAbility();
                return(true);
            }

            PgRecipe ParsedRecipe = null !;

            if (Inserter <PgRecipe> .SetItemByInternalName((PgRecipe valueRecipe) => ParsedRecipe = valueRecipe, EffectNameString, ErrorControl.IgnoreIfNotFound))
            {
                item = new PgSourceRecipe()
                {
                    Recipe_Key = ParsedRecipe.Key
                };
                return(true);
            }

            if (Inserter <PgRecipe> .SetItemByName((PgRecipe valueRecipe) => ParsedRecipe = valueRecipe, EffectNameString, ErrorControl.IgnoreIfNotFound))
            {
                item = new PgSourceRecipe()
                {
                    Recipe_Key = ParsedRecipe.Key
                };
                return(true);
            }

            PgEffect ParsedEffect = null !;

            if (Inserter <PgEffect> .SetItemByName((PgEffect valueEffect) => ParsedEffect = valueEffect, EffectNameString, ErrorControl.IgnoreIfNotFound))
            {
                item = new PgSourceEffect()
                {
                    Effect_Key = ParsedEffect.Key
                };
                return(true);
            }

            if (!contentTable.ContainsKey("EffectTypeId"))
            {
                return(Program.ReportFailure($"Unknown effect name {EffectNameString}"));
            }

            if (!(contentTable["EffectTypeId"] is string ValueString))
            {
                return(Program.ReportFailure($"Effect type id was expected to be a string"));
            }

            string EffectKey = $"effect_{ValueString}";

            if (Inserter <PgEffect> .SetItemByKey((PgEffect valueEffect) => ParsedEffect = valueEffect, EffectKey, ErrorControl.IgnoreIfNotFound))
            {
                item = new PgSourceEffect()
                {
                    Effect_Key = ParsedEffect.Key
                };
                return(true);
            }

            return(Program.ReportFailure($"Unknown effect name {EffectNameString}"));
        }
示例#3
0
        private bool FinishItem(PgEffect 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 "Name":
                    Result = SetStringProperty((string valueString) => item.Name = valueString, Value);
                    break;

                case "Desc":
                    Result = SetStringProperty((string valueString) => item.Description = valueString, Value);
                    break;

                case "IconId":
                    Result = SetIconIdProperty((int valueInt) => item.RawIconId = valueInt, Value);
                    break;

                case "DisplayMode":
                    Result = StringToEnumConversion <EffectDisplayMode> .SetEnum((EffectDisplayMode valueEnum) => item.DisplayMode = valueEnum, Value);

                    break;

                case "SpewText":
                    Result = SetStringProperty((string valueString) => item.SpewText = valueString, Value);
                    break;

                case "Particle":
                    Result = StringToEnumConversion <EffectParticle> .SetEnum((EffectParticle valueEnum) => item.Particle = valueEnum, Value);

                    break;

                case "StackingType":
                    Result = StringToEnumConversion <EffectStackingType> .SetEnum((EffectStackingType valueEnum) => item.StackingType = valueEnum, Value);

                    break;

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

                case "Duration":
                    ParseDuration(item, Value, parsedFile, parsedKey);
                    break;

                case "Keywords":
                    Result = StringToEnumConversion <EffectKeyword> .TryParseList(Value, item.KeywordList);

                    break;

                case "AbilityKeywords":
                    Result = StringToEnumConversion <AbilityKeyword> .TryParseList(Value, item.AbilityKeywordList);

                    break;

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

                if (!Result)
                {
                    break;
                }
            }

            return(Result);
        }