Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        private bool ParseSourceHangOut(ref object?item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, string parsedFile, string parsedKey)
        {
            bool            Result    = true;
            PgSourceHangOut NewSource = new PgSourceHangOut();

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

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

                case "Npc":
                    Result = Inserter <PgSource> .SetNpc((PgNpcLocation location) => NewSource.Npc = location, Value, parsedFile, parsedKey);

                    break;

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

                if (!Result)
                {
                    break;
                }
            }

            if (Result)
            {
                item = NewSource;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        private bool FinishItem(PgStorageVault 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.RawId = valueInt, Value);
                    break;

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

                case "Area":
                    Result = ParseArea((MapAreaName valueEnum) => item.Area = valueEnum, Value, parsedFile, parsedKey);
                    break;

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

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

                case "Levels":
                    Result = Inserter <PgStorageFavorLevel> .SetItemProperty((PgStorageFavorLevel valueStorageFavorLevel) => item.Levels = valueStorageFavorLevel, Value);

                    break;

                case "Requirements":
                    Result = Inserter <PgStorageRequirement> .SetItemProperty((PgStorageRequirement valueStorageRequirement) => item.Requirement = valueStorageRequirement, Value);

                    break;

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

                case "Grouping":
                    Result = ParseArea((MapAreaName valueEnum) => item.Grouping = valueEnum, Value, parsedFile, parsedKey);
                    break;

                case "RequiredItemKeywords":
                    Result = StringToEnumConversion <ItemKeyword> .TryParseList(Value, item.RequiredItemKeywordList);

                    break;

                case "SlotAttribute":
                    Result = Inserter <PgAttribute> .SetItemByKey((PgAttribute valueAttribute) => item.SlotAttribute_Key = valueAttribute.Key, Value);

                    break;

                case "EventLevels":
                    Result = Inserter <PgStorageEventList> .SetItemProperty((PgStorageEventList valueStorageEventLevel) => item.EventLevels = valueStorageEventLevel, Value);

                    break;

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

                if (!Result)
                {
                    break;
                }
            }

            if (Result)
            {
                if (!item.RawHasAssociatedNpc.HasValue || item.HasAssociatedNpc)
                {
                    Inserter <PgQuest> .SetNpc((PgNpcLocation npcLocation) => item.AssociatedNpc = npcLocation, item.Key, parsedFile, parsedKey, ErrorControl.IgnoreIfNotFound);
                }
            }

            return(Result);
        }
Exemplo n.º 4
0
        private bool FinishItem(PgQuest item, Dictionary <string, object> contentTable, Dictionary <string, Json.Token> contentTypeTable, List <object> itemCollection, Json.Token lastItemType, string parsedFile, string parsedKey)
        {
            bool Result       = true;
            int? RawTSysLevel = null;

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

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

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

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

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

                case "RequirementsToSustain":
                    Result = Inserter <PgQuestRequirement> .AddKeylessArray(item.QuestRequirementToSustainList, Value);

                    break;

                case "ReuseTime_Minutes":
                    Result = SetTimeProperty(() => item.RawReuseTime, (TimeSpan valueTime) => item.RawReuseTime = valueTime, 1, Value);
                    break;

                case "ReuseTime_Hours":
                    Result = SetTimeProperty(() => item.RawReuseTime, (TimeSpan valueTime) => item.RawReuseTime = valueTime, 60, Value);
                    break;

                case "ReuseTime_Days":
                    Result = SetTimeProperty(() => item.RawReuseTime, (TimeSpan valueTime) => item.RawReuseTime = valueTime, 60 * 24, Value);
                    break;

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

                case "Objectives":
                    Result = Inserter <PgQuestObjective> .AddKeylessArray(item.QuestObjectiveList, Value);

                    break;

/*                    case "Rewards_XP":
 *                      Result = Inserter<PgQuestReward>.AddKeylessArray(item.QuestRewardList, Value);
 *                      break;*/
/*                    case "Rewards_Currency":
 *                      Result = Inserter<PgQuestReward>.AddKeylessArray(item.QuestRewardList, Value);
 *                      break;*/
                case "Rewards_Items":
                    Result = Inserter <PgQuestReward> .AddKeylessArray(item.QuestRewardList, Value);

                    break;

                case "Reward_CombatXP":
                    Result = ParseRewardCombatXp(item, Value, parsedFile, parsedKey);
                    break;

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

                    break;

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

                    break;

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

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

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

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

                    break;

                case "Rewards_Favor":
                    Result = ParseRewardFavor(item, Value, parsedFile, parsedKey);
                    break;

/*                    case "Rewards_Recipes":
 *                      Result = ParseRewardRecipes(item, Value, parsedFile, parsedKey);
 *                      break;*/
/*                    case "Rewards_Ability":
 *                      Result = ParseRewardAbility(item, Value, parsedFile, parsedKey);
 *                      break;*/
                case "Requirements":
                    Result = Inserter <PgQuestRequirement> .AddKeylessArray(item.QuestRequirementList, Value);

                    break;

                case "Reward_Favor":
                    Result = ParseRewardFavor(item, Value, parsedFile, parsedKey);
                    break;

                case "Rewards":
                    Result = Inserter <PgQuestReward> .AddKeylessArray(item.QuestRewardList, Value);

                    break;

                case "PreGiveItems":
                    Result = Inserter <PgQuestReward> .AddKeylessArray(item.PreGiveItemList, Value);

                    break;

                case "TSysLevel":
                    Result = SetIntProperty((int valueInt) => RawTSysLevel = valueInt, Value);
                    break;

                /*case "Reward_Gold":
                 *  Result = ParseRewardCurrency(item, Value, parsedFile, parsedKey);
                 *  break;*/
                case "Rewards_NamedLootProfile":
                    Result = ParseRewardNamedLootProfile(item, Value, parsedFile, parsedKey);
                    break;

                case "PreGiveRecipes":
                    Result = Inserter <PgRecipe> .AddPgObjectArrayByInternalName <PgRecipe>(item.PreGiveRecipeList, Value);

                    break;

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

                    break;

                case "Rewards_Effects":
                    Result = ParseRewardEffects(item, Value, parsedFile, parsedKey);
                    break;

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

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

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

                    break;

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

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

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

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

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

                    break;

                case "FollowUpQuests":
                    Result = ParseFollowUpQuests(item, Value, parsedFile, parsedKey);
                    break;

                case "PreGiveEffects":
                    Result = ParsePreGiveEffects(item, Value, parsedFile, parsedKey);
                    break;

                case "MidwayGiveItems":
                    Result = Inserter <PgQuestReward> .AddKeylessArray(item.QuestMidwayGiveItemList, Value);

                    break;

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

                if (!Result)
                {
                    break;
                }
            }

            if (Result)
            {
                if (item.RawLevel.HasValue && RawTSysLevel.HasValue)
                {
                    return(Program.ReportFailure(parsedFile, parsedKey, "Both levels set"));
                }

                if (RawTSysLevel.HasValue)
                {
                    Debug.Assert(!item.RawLevel.HasValue);
                    item.RawLevel = RawTSysLevel;
                }
            }

            return(Result);
        }
Exemplo n.º 5
0
        private bool ParseHints(string hint, string parsedFile, string parsedKey, out PgNpcLocationCollection npcList)
        {
            npcList = new PgNpcLocationCollection();

            if (hint.EndsWith("learn a new dance move."))
            {
                return(true);
            }

            hint = hint.Replace(" during a Full Moon,", string.Empty);

            string Pattern;
            int    StartIndex;

            Pattern    = "gain favor with ";
            StartIndex = hint.IndexOf(Pattern);

            if (StartIndex < 0)
            {
                Pattern    = "speak with ";
                StartIndex = hint.IndexOf(Pattern);
            }

            if (StartIndex < 0)
            {
                Pattern    = "seek out ";
                StartIndex = hint.IndexOf(Pattern);
            }

            if (StartIndex < 0)
            {
                if (hint.Contains(" equip "))
                {
                    return(true);
                }

                return(Program.ReportFailure($"Advancement trigger not found in: {hint}"));
            }

            StartIndex += Pattern.Length;

            int EndIndex;

            EndIndex = hint.IndexOf(" in ", StartIndex);
            if (EndIndex < 0)
            {
                EndIndex = hint.IndexOf(" outside of ", StartIndex);
            }
            if (EndIndex <= StartIndex)
            {
                return(Program.ReportFailure($"Bad advancement hint: {hint}"));
            }

            string NpcNameString = hint.Substring(StartIndex, EndIndex - StartIndex);

            string[] NpcNames = NpcNameString.Split(new string[] { " or " }, StringSplitOptions.None);

            foreach (string NpcName in NpcNames)
            {
                PgNpcLocation ParsedNpc = null !;
                if (!Inserter <PgSkill> .SetNpc((PgNpcLocation npcLocation) => ParsedNpc = npcLocation, $"NPC_{NpcName}", parsedFile, parsedKey))
                {
                    return(false);
                }

                npcList.Add(ParsedNpc);
            }

            if (npcList.Count == 0)
            {
                return(Program.ReportFailure($"No NPC name in advancement hint: {hint}"));
            }

            return(true);
        }