Esempio n. 1
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);
        }