Beispiel #1
0
        /// <summary>
        /// Returns the value object to use for scriban exporting
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="project">Project</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Value Object</returns>
        protected override async Task <ScribanLearnedSkillConditionData> GetExportObject(LearnedSkillConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            KortistoNpc npc = await ConditionRenderingUtil.GetExportNpc(_cachedDbAccess, project, flexFieldObject, errorCollection, _isPlayer);

            if (npc == null)
            {
                errorCollection.AddDialogNpcNotFoundError();
                return(null);
            }

            EvneSkill skill = await _cachedDbAccess.GetSkillById(parsedData.SelectedSkillId);

            if (skill == null)
            {
                errorCollection.AddDialogSkillNotFoundError();
                return(null);
            }

            ScribanLearnedSkillConditionData conditionData = new ScribanLearnedSkillConditionData();
            ScribanExportNpc convertedNpc = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, npc, exportSettings, errorCollection);

            convertedNpc.IsPlayer = npc.IsPlayerNpc;
            conditionData.Npc     = convertedNpc;

            conditionData.SelectedSkill = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportSkill>(null, null, skill, exportSettings, errorCollection);

            return(conditionData);
        }
        /// <summary>
        /// Builds the skills
        /// </summary>
        /// <param name="skillCode">Code for the skills to repeat</param>
        /// <param name="npc">Npc</param>
        /// <returns>Skills of the npc</returns>
        private string BuildSkills(string skillCode, KortistoNpc npc)
        {
            if (npc.Skills == null)
            {
                return(string.Empty);
            }

            int    skillIndex    = 0;
            string skillListCode = string.Empty;

            foreach (KortistoNpcSkill curSkill in npc.Skills)
            {
                string curSkillCode = ExportUtil.BuildPlaceholderRegex(Placeholder_CurSkill_Index).Replace(skillCode, skillIndex.ToString());

                EvneSkill skill = _cachedDbAccess.GetSkillById(curSkill.SkillId).Result;
                if (skill != null)
                {
                    ExportObjectData skillExportData = new ExportObjectData();
                    skillExportData.ExportData.Add(ExportConstants.ExportDataObject, skill);
                    skillExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeSkill);
                    curSkillCode = _skillPlaceholderResolver.FillPlaceholders(curSkillCode, skillExportData).Result;
                }

                skillListCode += curSkillCode;
                ++skillIndex;
            }

            return(skillListCode);
        }
        /// <summary>
        /// Returns the skill to use
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <returns>Value Object</returns>
        private async Task <IFlexFieldExportable> GetSkill(LearnForgetSkillActionRenderer.LearnForgetSkillActionData parsedData, ExportPlaceholderErrorCollection errorCollection)
        {
            EvneSkill skillToUse = await _cachedDbAccess.GetSkillById(parsedData.SkillId);

            if (skillToUse == null)
            {
                errorCollection.AddDialogSkillNotFoundError();
                return(null);
            }

            return(skillToUse);
        }
        /// <summary>
        /// Loads the reference node data
        /// </summary>
        /// <param name="referenceNode">Reference node</param>
        /// <returns>Reference node data</returns>
        private async Task <ReferenceNodeData> GetReferenceNodeData(ReferenceNode referenceNode)
        {
            ReferenceNodeData referenceNodeData = new ReferenceNodeData();

            referenceNodeData.ReferenceText = referenceNode.ReferenceText;
            referenceNodeData.ObjectType    = referenceNode.ReferencedObjects.Any() ? referenceNode.ReferencedObjects[0].ObjectType : ExportConstants.ExportObjectTypeNone;
            switch (referenceNodeData.ObjectType.ToLowerInvariant())
            {
            case ExportConstants.ExportObjectTypeNpc:
                referenceNodeData.Npc = await _exportCachedDbAccess.GetNpcById(referenceNode.ReferencedObjects[0].ObjectId);

                break;

            case ExportConstants.ExportObjectTypeItem:
                referenceNodeData.Item = await _exportCachedDbAccess.GetItemById(referenceNode.ReferencedObjects[0].ObjectId);

                break;

            case ExportConstants.ExportObjectTypeSkill:
                referenceNodeData.Skill = await _exportCachedDbAccess.GetSkillById(referenceNode.ReferencedObjects[0].ObjectId);

                break;

            case ExportConstants.ExportObjectTypeQuest:
                referenceNodeData.Quest = await _exportCachedDbAccess.GetQuestById(referenceNode.ReferencedObjects[0].ObjectId);

                break;

            case ExportConstants.ExportObjectTypeWikiPage:
                referenceNodeData.WikiPage = await _exportCachedDbAccess.GetWikiPageById(referenceNode.ReferencedObjects[0].ObjectId);

                break;

            case ExportConstants.ExportObjectTypeMapMarker:
                referenceNodeData.Marker = await _exportCachedDbAccess.GetMarkerById(referenceNode.ReferencedObjects[1].ObjectId, referenceNode.ReferencedObjects[0].ObjectId);

                break;

            case ExportConstants.ExportObjectTypeDailyRoutineEvent:
                referenceNodeData.Npc = await _exportCachedDbAccess.GetNpcById(referenceNode.ReferencedObjects[1].ObjectId);

                referenceNodeData.DailyRoutineEvent = referenceNodeData.Npc.DailyRoutine != null?referenceNodeData.Npc.DailyRoutine.FirstOrDefault(d => d.EventId == referenceNode.ReferencedObjects[0].ObjectId) : null;

                break;
            }

            return(referenceNodeData);
        }
Beispiel #5
0
        /// <summary>
        /// Builds a condition element from parsed data
        /// </summary>
        /// <param name="template">Export template to use</param>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="project">Project</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Condition string</returns>
        public override async Task <string> BuildConditionElementFromParsedData(ExportTemplate template, LearnedSkillConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            EvneSkill skill = await _cachedDbAccess.GetSkillById(parsedData.SelectedSkillId);

            if (skill == null)
            {
                errorCollection.AddDialogSkillNotFoundError();
                return(string.Empty);
            }

            ExportObjectData skillExportData = new ExportObjectData();

            skillExportData.ExportData.Add(ExportConstants.ExportDataObject, skill);
            skillExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeSkill);

            _skillPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            string conditionCode = await _skillPlaceholderResolver.FillPlaceholders(template.Code, skillExportData);

            return(conditionCode);
        }
        /// <summary>
        /// Builds a condition element from parsed data
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="project">Project</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Condition string</returns>
        public override string BuildConditionElementFromParsedData(LearnedSkillConditionResolver.LearnedSkillConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            ExportTemplate conditionTemplate = _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, GetTemplateType()).Result;

            EvneSkill skill = _cachedDbAccess.GetSkillById(parsedData.SelectedSkillId).Result;

            if (skill == null)
            {
                errorCollection.AddDialogSkillNotFoundError();
                return(string.Empty);
            }

            ExportObjectData skillExportData = new ExportObjectData();

            skillExportData.ExportData.Add(ExportConstants.ExportDataObject, skill);
            skillExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeSkill);

            _skillPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            string conditionCode = _skillPlaceholderResolver.FillPlaceholders(conditionTemplate.Code, skillExportData).Result;

            return(conditionCode);
        }