private bool ParseKeyword(PgNpcPreference item, string valueKeyword, string parsedFile, string parsedKey)
 {
     if (valueKeyword.StartsWith("MinValue:"))
     {
         return(ParseKeywordAsMinValue(item, valueKeyword.Substring(9), parsedFile, parsedKey));
     }
     else if (valueKeyword.StartsWith("SkillPrereq:"))
     {
         return(ParseKeywordAsSkillRequirement(item, valueKeyword.Substring(12), parsedFile, parsedKey));
     }
     else if (valueKeyword.StartsWith("EquipmentSlot:"))
     {
         return(ParseKeywordAsEquipmentSlot(item, valueKeyword.Substring(14), parsedFile, parsedKey));
     }
     else if (valueKeyword.StartsWith("MinRarity:"))
     {
         return(ParseKeywordAsMinRarity(item, valueKeyword.Substring(10), parsedFile, parsedKey));
     }
     else if (valueKeyword.StartsWith("Rarity:"))
     {
         return(ParseKeywordAsRarity(item, valueKeyword.Substring(7), parsedFile, parsedKey));
     }
     else if (StringToEnumConversion <ItemKeyword> .TryParse(valueKeyword, out ItemKeyword ParsedItemKeyword))
     {
         item.ItemKeywordList.Add(ParsedItemKeyword);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
        private bool FinishItem(PgStorageFavorLevel 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 (!StringToEnumConversion <Favor> .TryParse(Key, out Favor Favor))
                {
                    return(Program.ReportFailure(parsedFile, parsedKey, $"Unknown favor level '{Key}'"));
                }

                if (!(Value is int SlotCount))
                {
                    return(Program.ReportFailure($"Value {Value} was expected to be an int"));
                }

                item.LevelTable.Add(new PgFavorSlotPair()
                {
                    Favor = Favor, SlotCount = SlotCount
                });
            }

            item.LevelTable.Sort((PgFavorSlotPair p1, PgFavorSlotPair p2) => p1.SlotCount - p2.SlotCount);

            return(true);
        }
        private bool FinishItem(PgSpecialValue 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 "Label":
                    Result = SetStringProperty((string valueString) => item.Label = valueString, Value);
                    break;

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

                case "Value":
                    Result = SetFloatProperty((float valueFloat) => item.RawValue = valueFloat, Value);
                    break;

                case "AttributesThatDelta":
                    Result = Inserter <PgAttribute> .AddPgObjectArrayByKey <PgAttribute>(item.AttributesThatDeltaList, Value);

                    break;

                case "AttributesThatMod":
                    Result = Inserter <PgAttribute> .AddPgObjectArrayByKey <PgAttribute>(item.AttributesThatModList, Value);

                    break;

                case "AttributesThatModBase":
                    Result = Inserter <PgAttribute> .AddPgObjectArrayByKey <PgAttribute>(item.AttributesThatModBaseList, Value);

                    break;

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

                    break;

                case "SkipIfZero":
                    Result = SetBoolProperty((bool valueBool) => item.RawSkipIfZero = valueBool, Value);
                    break;

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

                if (!Result)
                {
                    break;
                }
            }

            return(Result);
        }
Esempio n. 4
0
        private bool FinishItem(PgAbilityAmmo 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 "ItemKeyword":
                    Result = StringToEnumConversion <ItemKeyword> .SetEnum((ItemKeyword valueEnum) => item.ItemKeyword = valueEnum, Value);

                    break;

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

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

                if (!Result)
                {
                    break;
                }
            }

            return(Result);
        }
Esempio n. 5
0
        public static bool SetNpcNoZone(Action <PgNpcLocation> setter, MapAreaName areaName, string npcId, string parsedFile, string parsedKey, ErrorControl errorControl)
        {
            PgNpc      ParsedNpc = null !;
            SpecialNpc NpcEnum   = SpecialNpc.Internal_None;
            string     NpcName   = string.Empty;

            PgNpcLocation NpcLocation = new PgNpcLocation();

            NpcLocation.NpcId = npcId;

            if (Inserter <PgNpc> .SetItemByKey((PgNpc valueNpc) => ParsedNpc = valueNpc, npcId, ErrorControl.IgnoreIfNotFound))
            {
                NpcLocation.Npc_Key = ParsedNpc.Key;
            }
            else if (StringToEnumConversion <SpecialNpc> .TryParse(npcId, out NpcEnum, ErrorControl.IgnoreIfNotFound))
            {
                NpcLocation.NpcEnum = NpcEnum;
            }
            else if (npcId.ToUpper().StartsWith("NPC_"))
            {
                NpcLocation.NpcName = npcId.Substring(4);
            }
            else
            {
                return(Program.ReportFailure(parsedFile, parsedKey, $"'{npcId}' unknown NPC name", errorControl));
            }

            ParsingContext.AddSuplementaryObject(NpcLocation);

            Debug.Assert(!string.IsNullOrEmpty(NpcLocation.NpcId));
            Debug.Assert(NpcLocation.Npc_Key != null || NpcLocation.NpcEnum != SpecialNpc.Internal_None || NpcLocation.NpcName.Length > 0);

            setter(NpcLocation);
            return(true);
        }
Esempio n. 6
0
        private bool FinishItem(PgQuestRewardCurrency item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, string parsedFile, string parsedKey)
        {
            if (contentTable.Count != 1)
            {
                return(Program.ReportFailure(parsedFile, parsedKey, "Invalid currency reward object"));
            }

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

                if (!StringToEnumConversion <Currency> .TryParse(CurrencyKey, out Currency Currency))
                {
                    return(false);
                }

                if (!(Value is int Amount))
                {
                    return(Program.ReportFailure($"Value '{Value}' was expected to be an int"));
                }

                item.Currency  = Currency;
                item.RawAmount = Amount;
            }

            return(true);
        }
        private bool ParseArea(Action <MapAreaName> setter, object value, string parsedFile, string parsedKey)
        {
            if (!(value is string ValueString))
            {
                return(Program.ReportFailure($"Value {value} was expected to be a string"));
            }

            MapAreaName Area;

            if (ValueString == "*")
            {
                Area = MapAreaName.Any;
                StringToEnumConversion <MapAreaName> .SetCustomParsedEnum(Area);
            }
            else if (ValueString.StartsWith("Area"))
            {
                string AreaString = ValueString.Substring(4);
                if (!StringToEnumConversion <MapAreaName> .TryParse(AreaString, out Area))
                {
                    return(false);
                }
            }
            else
            {
                return(Program.ReportFailure($"Invalid area name {ValueString}"));
            }

            setter(Area);
            return(true);
        }
Esempio n. 8
0
        private bool ParseDroppedAppearance(PgItem item, object value, string parsedFile, string parsedKey)
        {
            if (!(value is string ValueString))
            {
                return(Program.ReportFailure(parsedFile, parsedKey, $"Value '{value}' was expected to be a string"));
            }

            string AppearanceString;

            int index = ValueString.IndexOf('(');

            if (index > 0)
            {
                if (index >= ValueString.Length - 2 || !ValueString.EndsWith(")"))
                {
                    return(Program.ReportFailure(parsedFile, parsedKey, $"'{value}' is an invalid dropped appareance"));
                }

                AppearanceString = ValueString.Substring(0, index);

                string[] Details = ValueString.Substring(index + 1, ValueString.Length - index - 2).Split(';');
                if (!ParseDroppedAppearanceDetails(item, Details, parsedFile, parsedKey))
                {
                    return(false);
                }
            }
            else
            {
                AppearanceString = ValueString;
            }

            return(StringToEnumConversion <ItemDroppedAppearance> .SetEnum((ItemDroppedAppearance valueEnum) => item.DroppedAppearance = valueEnum, AppearanceString));
        }
Esempio n. 9
0
        private static bool FinishItemPetCount(ref object?item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, List <string> knownFieldList, List <string> usedFieldList, string parsedFile, string parsedKey)
        {
            PgQuestObjectiveRequirementPetCount NewItem = new PgQuestObjectiveRequirementPetCount();

            bool Result = true;

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

                if (!knownFieldList.Contains(Key))
                {
                    Result = Program.ReportFailure($"Unknown field {Key}");
                }
                else
                {
                    usedFieldList.Add(Key);

                    switch (Key)
                    {
                    case "T":
                        break;

                    case "MinCount":
                        Result = SetIntProperty((int valueInt) => NewItem.MinCount = valueInt, Value);
                        break;

                    case "MaxCount":
                        Result = SetIntProperty((int valueInt) => NewItem.MaxCount = valueInt, Value);
                        break;

                    case "PetTypeTag":
                        Result = StringToEnumConversion <RecipeKeyword> .SetEnum((RecipeKeyword valueEnum) => NewItem.PetTypeTag = valueEnum, Value);

                        break;

                    default:
                        Result = Program.ReportFailure("Unexpected failure");
                        break;
                    }
                }

                if (!Result)
                {
                    break;
                }
            }

            if (Result)
            {
                item = NewItem;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 10
0
        private static bool FinishItemMinFavorLevel(ref object?item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, List <string> knownFieldList, List <string> usedFieldList, string parsedFile, string parsedKey)
        {
            PgQuestRequirementMinFavorLevel NewItem = new PgQuestRequirementMinFavorLevel();

            bool Result = true;

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

                if (!knownFieldList.Contains(Key))
                {
                    Result = Program.ReportFailure($"Unknown field {Key}");
                }
                else
                {
                    usedFieldList.Add(Key);

                    switch (Key)
                    {
                    case "T":
                        break;

                    case "Npc":
                        Result = Inserter <PgQuest> .SetNpc((PgNpcLocation npcLocation) => NewItem.FavorNpc = npcLocation, Value, parsedFile, parsedKey);

                        break;

                    case "Level":
                        Result = StringToEnumConversion <Favor> .SetEnum((Favor valueEnum) => NewItem.FavorLevel = valueEnum, Value);

                        break;

                    /*case "Quest":
                     *  Result = Inserter<PgQuest>.SetItemByInternalName((PgQuest valueQuest) => NewItem.QuestList.Add(valueQuest), Value);
                     *  break;*/
                    default:
                        Result = Program.ReportFailure("Unexpected failure");
                        break;
                    }
                }

                if (!Result)
                {
                    break;
                }
            }

            if (Result)
            {
                item = NewItem;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 11
0
        private bool FinishItem(PgRewardList 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;

                string[] Split = Key.Split('_');

                string EntryLevelString = Split[0];
                if (!int.TryParse(EntryLevelString, out int EntryLevel))
                {
                    return(Program.ReportFailure($"Invalid skill reward level '{EntryLevelString}'"));
                }

                List <Race> EntryRaceList = new List <Race>();
                for (int i = 1; i < Split.Length; i++)
                {
                    string EntryRaceString = Split[i];
                    if (!StringToEnumConversion <Race> .TryParse(EntryRaceString, out Race EntryRace))
                    {
                        return(Program.ReportFailure($"Invalid skill reward race '{EntryRaceString}'"));
                    }

                    EntryRaceList.Add(EntryRace);
                }

                foreach (PgReward Reward in item.List)
                {
                    bool IsFound = false;
                    foreach (Race Race in EntryRaceList)
                    {
                        IsFound |= Reward.RaceRestrictionList.Contains(Race);
                    }

                    if (IsFound && Reward.RewardLevel == EntryLevel)
                    {
                        return(Program.ReportFailure($"Level {EntryLevel} already added"));
                    }
                }

                if (!(Value is ParsingContext Context))
                {
                    return(Program.ReportFailure($"Value '{Value}' was expected to be a context"));
                }

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

                AsReward.RawRewardLevel = EntryLevel;
                AsReward.RaceRestrictionList.AddRange(EntryRaceList);

                item.List.Add(AsReward);
            }

            return(true);
        }
Esempio n. 12
0
        private bool FinishItem(PgLoreBook 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 "Title":
                    Result = SetStringProperty((string valueString) => item.Title = valueString, Value);
                    break;

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

                case "Category":
                    Result = ParserLoreBookInfoCategory(item, Value, parsedFile, parsedKey);
                    break;

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

                    break;

                case "IsClientLocal":
                    Result = SetBoolProperty((bool valueBool) => item.RawIsClientLocal = valueBool, Value);
                    break;

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

                    break;

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

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

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

                if (!Result)
                {
                    break;
                }
            }

            return(Result);
        }
Esempio n. 13
0
        private bool FinishItem(PgItemBehavior 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 "UseVerb":
                    Result = StringToEnumConversion <ItemUseVerb> .SetEnum((ItemUseVerb valueEnum) => item.UseVerb = valueEnum, Value);

                    break;

                case "UseRequirements":
                    Result = StringToEnumConversion <ItemUseRequirement> .TryParseList(Value, item.UseRequirementList);

                    break;

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

                    break;

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

                    break;

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

                case "UseDelay":
                    Result = SetFloatProperty((float valueFloat) => item.RawUseDelay = valueFloat, Value);
                    break;

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

                if (!Result)
                {
                    break;
                }
            }

            if (!contentTable.ContainsKey("UseVerb"))
            {
                Result = Program.ReportFailure(parsedFile, parsedKey, "Behavior has no verb");
            }

            return(Result);
        }
Esempio n. 14
0
        public override bool FinishItem(ref object?item, string objectKey, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, string parsedFile, string parsedKey)
        {
            if (item != null)
            {
                return(Program.ReportFailure("Unexpected failure"));
            }

            if (!contentTable.ContainsKey("T"))
            {
                return(Program.ReportFailure(parsedFile, parsedKey, $"Quest reward is missing a Type qualifier"));
            }

            object TypeValue = contentTable["T"];

            if (!(TypeValue is string AsTypeString))
            {
                return(Program.ReportFailure(parsedFile, parsedKey, $"Value {TypeValue} was expected to be a string"));
            }

            if (!StringToEnumConversion <QuestRewardType> .TryParse(AsTypeString, out QuestRewardType rewardType))
            {
                return(false);
            }

            if (!HandlerTable.ContainsKey(rewardType))
            {
                return(Program.ReportFailure(parsedFile, parsedKey, $"Reward {rewardType} has no handler"));
            }

            Debug.Assert(KnownFieldTable.ContainsKey(rewardType));

            VariadicObjectHandler Handler        = HandlerTable[rewardType];
            List <string>         KnownFieldList = KnownFieldTable[rewardType];
            List <string>         UsedFieldList  = new List <string>();

            if (!Handler(ref item, contentTable, contentTypeTable, itemCollection, lastItemType, KnownFieldList, UsedFieldList, parsedFile, parsedKey))
            {
                return(false);
            }

            if (!HandledTable.ContainsKey(rewardType))
            {
                HandledTable.Add(rewardType, new List <string>());
            }

            List <string> ReportedFieldList = HandledTable[rewardType];

            foreach (string FieldName in UsedFieldList)
            {
                if (!ReportedFieldList.Contains(FieldName))
                {
                    ReportedFieldList.Add(FieldName);
                }
            }

            return(true);
        }
Esempio n. 15
0
        private bool FinishItem(PgDirectedGoal 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 "Id":
                    Result = SetIntProperty((int valueInt) => item.Key = valueInt.ToString(), Value);
                    break;

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

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

                case "IsCategoryGate":
                    Result = ParseIsCategoryGate(contentTable, parsedFile, parsedKey);
                    break;

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

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

                case "CategoryGateId":
                    Result = ParseCategoryGateId(item, Value, contentTable, parsedFile, parsedKey);
                    break;

                case "ForRaces":
                    Result = StringToEnumConversion <Race> .TryParseList(Value, item.ForRaceList);

                    break;

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

                if (!Result)
                {
                    break;
                }
            }

            return(Result);
        }
Esempio n. 16
0
        public static bool ParseAreaEvent(object value, string parsedFile, string parsedKey, out MapAreaName areaName)
        {
            areaName = MapAreaName.Internal_None;

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

            if (AreaString == "Daytime")
            {
                areaName = MapAreaName.Daytime;
                StringToEnumConversion <MapAreaName> .SetCustomParsedEnum(areaName);

                return(true);
            }

            if (AreaString == "PovusNightlyQuest")
            {
                areaName = MapAreaName.PovusNightlyQuest;
                StringToEnumConversion <MapAreaName> .SetCustomParsedEnum(areaName);

                return(true);
            }

            int AreaIndex = AreaString.LastIndexOf('_');

            if (AreaIndex > 0)
            {
                int KeyIndex = AreaString.LastIndexOf('_', AreaIndex - 1);
                if (KeyIndex > 0)
                {
                    string AreaName  = AreaString.Substring(AreaIndex + 1);
                    string KeyName   = AreaString.Substring(KeyIndex + 1, AreaIndex - KeyIndex - 1);
                    string QuestName = AreaString.Substring(0, KeyIndex);

                    if (AreaName == "Ilmari")
                    {
                        AreaName = "Desert1";
                    }
                    else if (AreaName == "Kur")
                    {
                        AreaName = "KurMountains";
                    }

                    MapAreaName ParsedAreaName = MapAreaName.Internal_None;
                    bool        Result         = StringToEnumConversion <MapAreaName> .SetEnum((MapAreaName valueEnum) => ParsedAreaName = valueEnum, AreaName);

                    areaName = ParsedAreaName;
                    return(Result);
                }
            }

            return(Program.ReportFailure(parsedFile, parsedKey, $"Unknown area '{AreaString}'"));
        }
Esempio n. 17
0
        private static bool FinishItemWorkOrderCurrency(ref object?item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, List <string> knownFieldList, List <string> usedFieldList, string parsedFile, string parsedKey)
        {
            PgQuestRewardWorkOrderCurrency NewItem = new PgQuestRewardWorkOrderCurrency();

            bool Result = true;

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

                if (!knownFieldList.Contains(Key))
                {
                    Result = Program.ReportFailure($"Unknown field {Key}");
                }
                else
                {
                    usedFieldList.Add(Key);

                    switch (Key)
                    {
                    case "T":
                        break;

                    case "Currency":
                        Result = StringToEnumConversion <Currency> .SetEnum((Currency valueEnum) => NewItem.Currency = valueEnum, Value);

                        break;

                    case "Amount":
                        Result = SetIntProperty((int valueInt) => NewItem.RawAmount = valueInt, Value);
                        break;

                    default:
                        Result = Program.ReportFailure("Unexpected failure");
                        break;
                    }
                }

                if (!Result)
                {
                    break;
                }
            }

            if (Result)
            {
                item = NewItem;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 18
0
        private bool FinishItem(PgAttribute 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 "Label":
                    Result = SetStringProperty((string valueString) => item.Label = valueString, Value);
                    break;

                case "IconIds":
                    Result = ParseIcondIds(item, Value, parsedFile, parsedKey);
                    break;

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

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

                    break;

                case "IsHidden":
                    Result = SetBoolProperty((bool valueBool) => item.RawIsHidden = valueBool, Value);
                    break;

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

                    break;

                case "DefaultValue":
                    Result = SetFloatProperty((float valueFloat) => item.RawDefaultValue = valueFloat, Value);
                    break;

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

                if (!Result)
                {
                    break;
                }
            }

            return(Result);
        }
Esempio n. 19
0
        public Sentence(string format, List <CombatKeyword> combatKeywordList, SignInterpretation signInterpretation)
        {
            Format = format;
            AssociatedKeywordList = combatKeywordList;
            SignInterpretation    = signInterpretation;

            foreach (CombatKeyword Keyword in AssociatedKeywordList)
            {
                StringToEnumConversion <CombatKeyword> .SetCustomParsedEnum(Keyword);
            }
        }
Esempio n. 20
0
        private bool FinishItem(PgAIAbility 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 "minLevel":
                    Result = SetIntProperty((int valueInt) => item.RawMinLevel = valueInt, Value);
                    break;

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

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

                case "minRange":
                    Result = SetFloatProperty((float valueFloat) => item.RawMinRange = valueFloat, Value);
                    break;

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

                case "cue":
                    Result = StringToEnumConversion <AbilityCue> .SetEnum((AbilityCue valueEnum) => item.Cue = valueEnum, Value);

                    break;

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

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

                if (!Result)
                {
                    break;
                }
            }

            return(Result);
        }
Esempio n. 21
0
        private bool ParseInternamName(PgXpTable item, object value, string parsedFile, string parsedKey)
        {
            if (!(value is string ValueString))
            {
                return(Program.ReportFailure($"Value '{value}' was expected to be a string"));
            }

            item.InternalName = ValueString;
            StringToEnumConversion <XpTableEnum> .SetEnum((XpTableEnum valueEnum) => item.AsEnum = valueEnum, value);

            return(true);
        }
Esempio n. 22
0
        private static bool FinishEquipmentSlotEmpty(ref object?item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, List <string> knownFieldList, List <string> usedFieldList, string parsedFile, string parsedKey)
        {
            PgQuestObjectiveRequirementEquipmentSlotEmpty NewItem = new PgQuestObjectiveRequirementEquipmentSlotEmpty();

            bool Result = true;

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

                if (!knownFieldList.Contains(Key))
                {
                    Result = Program.ReportFailure($"Unknown field {Key}");
                }
                else
                {
                    usedFieldList.Add(Key);

                    switch (Key)
                    {
                    case "T":
                        break;

                    case "Slot":
                        Result = StringToEnumConversion <ItemSlot> .SetEnum((ItemSlot valueEnum) => NewItem.Slot = valueEnum, Value);

                        break;

                    default:
                        Result = Program.ReportFailure("Unexpected failure");
                        break;
                    }
                }

                if (!Result)
                {
                    break;
                }
            }

            if (Result)
            {
                item = NewItem;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private static bool FinishItemInteractionFlagSet(ref object?item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, List <string> knownFieldList, List <string> usedFieldList, string parsedFile, string parsedKey)
        {
            PgAbilityRequirementInteractionFlagSet NewItem = new PgAbilityRequirementInteractionFlagSet();

            bool Result = true;

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

                if (!knownFieldList.Contains(Key))
                {
                    Result = Program.ReportFailure($"Unknown field {Key}");
                }
                else
                {
                    usedFieldList.Add(Key);

                    switch (Key)
                    {
                    case "T":
                        break;

                    case "InteractionFlag":
                        Result = StringToEnumConversion <InteractionFlag> .SetEnum((InteractionFlag valueEnum) => NewItem.InteractionFlag = valueEnum, Value);

                        break;

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

                if (!Result)
                {
                    break;
                }
            }

            if (Result)
            {
                item = NewItem;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 24
0
        public Sentence(string format, CombatKeyword associatedKeyword)
        {
            Format = format;
            AssociatedKeywordList = new List <CombatKeyword>()
            {
                associatedKeyword
            };
            SignInterpretation = SignInterpretation.Normal;

            foreach (CombatKeyword Keyword in AssociatedKeywordList)
            {
                StringToEnumConversion <CombatKeyword> .SetCustomParsedEnum(Keyword);
            }
        }
Esempio n. 25
0
        private bool FinishItem(PgPower 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 "Prefix":
                    Result = SetStringProperty((string valueString) => item.Prefix = valueString, Value);
                    break;

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

                case "Tiers":
                    Result = ParseTiers(item, Value, parsedFile, parsedKey);
                    break;

                case "Slots":
                    Result = StringToEnumConversion <ItemSlot> .TryParseList(Value, item.SlotList);

                    break;

                case "Skill":
                    Result = ParserSkill.Parse((PgSkill valueSkill) => item.Skill_Key = valueSkill.Key, Value, parsedFile, parsedKey);
                    break;

                case "IsUnavailable":
                    Result = SetBoolProperty((bool valueBool) => item.RawIsUnavailable = valueBool, Value);
                    break;

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

                if (!Result)
                {
                    break;
                }
            }

            return(Result);
        }
Esempio n. 26
0
        private bool ParseAreaName(PgNpc item, object value, string parsedFile, string parsedKey)
        {
            if (!(value is string ValueKey))
            {
                return(Program.ReportFailure(parsedFile, parsedKey, $"Value '{value}' was expected to be a string"));
            }

            if (!ValueKey.StartsWith("Area"))
            {
                return(Program.ReportFailure(parsedFile, parsedKey, $"Invalid area name '{ValueKey}'"));
            }

            string ValueAreaName = ValueKey.Substring(4);

            return(StringToEnumConversion <MapAreaName> .SetEnum((MapAreaName valueEnum) => item.AreaName = valueEnum, ValueAreaName));
        }
        private static bool FinishItemDisallowedItemKeyword(PgAbilityRequirementDisallowedItemKeyword item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, List <string> knownFieldList, List <string> usedFieldList, string parsedFile, string parsedKey)
        {
            bool Result = true;

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

                if (!knownFieldList.Contains(Key))
                {
                    Result = Program.ReportFailure($"Unknown field {Key}");
                }
                else
                {
                    usedFieldList.Add(Key);

                    switch (Key)
                    {
                    case "T":
                        break;

                    case "MaxCount":
                        Result = ParseEquippedItemKeywordMaxCount(Value, parsedFile, parsedKey);
                        break;

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

                        break;

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

                if (!Result)
                {
                    break;
                }
            }

            return(Result);
        }
Esempio n. 28
0
        public static bool SetNpcWithZone(Action <PgNpcLocation> setter, string rawMapName, string npcId, string parsedFile, string parsedKey, ErrorControl errorControl)
        {
            Debug.Assert(!string.IsNullOrEmpty(npcId));

            if (!rawMapName.StartsWith("Area"))
            {
                return(Program.ReportFailure(parsedFile, parsedKey, $"'{rawMapName}' does not contain an area name", errorControl));
            }

            string AreaName = rawMapName.Substring(4);

            if (!StringToEnumConversion <MapAreaName> .TryParse(AreaName, out MapAreaName ParsedAreaName))
            {
                return(false);
            }

            return(SetNpcNoZone(setter, ParsedAreaName, npcId, parsedFile, parsedKey, errorControl));
        }
        private bool ParseKeywordAsRarity(PgNpcPreference item, string value, string parsedFile, string parsedKey)
        {
            if (value == "Uncommon")
            {
                item.RarityRequirement = RecipeItemKey.Rarity_Uncommon;
            }
            else if (value == "Common")
            {
                item.RarityRequirement = RecipeItemKey.Rarity_Common;
            }
            else
            {
                return(Program.ReportFailure(parsedFile, parsedKey, $"Invalid rarity '{value}'"));
            }

            StringToEnumConversion <RecipeItemKey> .SetCustomParsedEnum(item.RarityRequirement);

            return(true);
        }
Esempio n. 30
0
        private bool FinishItem(PgRecipeCost 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 "Currency":
                    Result = StringToEnumConversion <RecipeCurrency> .SetEnum((RecipeCurrency valueEnum) => item.Currency = valueEnum, Value);

                    break;

                case "Price":
                    Result = SetFloatProperty((float valueFloat) => item.RawPrice = valueFloat, Value);
                    break;

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

                if (!Result)
                {
                    break;
                }
            }

            if (Result)
            {
                if (item.Currency == RecipeCurrency.Internal_None || !item.RawPrice.HasValue)
                {
                    return(Program.ReportFailure(parsedFile, parsedKey, "Missing cost info"));
                }
            }

            return(Result);
        }