/// <summary>
        /// Renders an daily routine event list
        /// </summary>
        /// <param name="context">Template context</param>
        /// <param name="callerContext">Caller context</param>
        /// <param name="arguments">Arguments to render the list with</param>
        /// <returns>Rendered daily routine event list</returns>
        private async ValueTask <object> RenderDailyRoutineEventList(TemplateContext context, ScriptNode callerContext, ScriptArray arguments)
        {
            List <ScribanExportDailyRoutineEvent> eventList = ScribanParsingUtil.GetArrayFromScribanArgument <ScribanExportDailyRoutineEvent>(arguments, 0);

            if (eventList == null)
            {
                _errorCollection.AddInvalidParameter(ScribanErrorUtil.FormatScribanSpan(callerContext.Span));
                return("<<DID NOT PROVIDE VALID EVENT LIST>>");
            }

            GoNorthProject curProject = await _exportCachedDbAccess.GetUserProject();

            ExportTemplate eventListTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(curProject.Id, TemplateType.ObjectDailyRoutineEventList);

            ExportObjectData objectData = _exportObjectData.Clone();

            if (objectData.ExportData.ContainsKey(ExportConstants.ExportDataObject) && objectData.ExportData[ExportConstants.ExportDataObject] is KortistoNpc)
            {
                ((KortistoNpc)objectData.ExportData[ExportConstants.ExportDataObject]).DailyRoutine = eventList.Select(e => e.OriginalEvent).ToList();
            }

            ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectDailyRoutineEventList, eventListTemplate.Code, objectData, eventListTemplate.RenderingEngine);

            _errorCollection.Merge(fillResult.Errors);

            return(ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code));
        }
示例#2
0
        /// <summary>
        /// Renders an skill List
        /// </summary>
        /// <param name="context">Template context</param>
        /// <param name="callerContext">Caller context</param>
        /// <param name="arguments">Arguments to render the list with</param>
        /// <returns>Rendered skill list</returns>
        private async ValueTask <object> RenderSkillList(TemplateContext context, ScriptNode callerContext, ScriptArray arguments)
        {
            if (!_exportObjectData.ExportData.ContainsKey(ExportConstants.ExportDataObject) || !(_exportObjectData.ExportData[ExportConstants.ExportDataObject] is KortistoNpc))
            {
                _errorCollection.AddInvalidParameter(ScribanErrorUtil.FormatScribanSpan(callerContext.Span));
                return("<<NO VALID NPC CONTEXT>>");
            }

            List <ScribanExportSkill> skillList = ScribanParsingUtil.GetArrayFromScribanArgument <ScribanExportSkill>(arguments, 0);

            if (skillList == null)
            {
                _errorCollection.AddInvalidParameter(ScribanErrorUtil.FormatScribanSpan(callerContext.Span));
                return("<<DID NOT PROVIDE VALID SKILL LIST>>");
            }

            GoNorthProject curProject = await _exportCachedDbAccess.GetUserProject();

            ExportTemplate skillListTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(curProject.Id, TemplateType.ObjectSkillList);

            ExportObjectData objectData = _exportObjectData.Clone();

            ((KortistoNpc)objectData.ExportData[ExportConstants.ExportDataObject]).Skills = ConvertSkillsToKortistoNpcSkill(skillList);

            ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectSkillList, skillListTemplate.Code, objectData, skillListTemplate.RenderingEngine);

            _errorCollection.Merge(fillResult.Errors);

            return(ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code));
        }
示例#3
0
        /// <summary>
        /// Renders an attribute List
        /// </summary>
        /// <param name="context">Template context</param>
        /// <param name="callerContext">Caller context</param>
        /// <param name="arguments">Arguments to render the list with</param>
        /// <returns>Rendered attribute list</returns>
        private async ValueTask <object> RenderAttributeList(TemplateContext context, ScriptNode callerContext, ScriptArray arguments)
        {
            List <ScribanFlexFieldField> fieldList = ScribanParsingUtil.GetArrayFromScribanArgument <ScribanFlexFieldField>(arguments, 0);

            if (fieldList == null)
            {
                _errorCollection.AddInvalidParameter(ScribanErrorUtil.FormatScribanSpan(callerContext.Span));
                return("<<DID NOT PROVIDE VALID ATTRIBUTE LIST>>");
            }

            GoNorthProject curProject = await _exportCachedDbAccess.GetUserProject();

            ExportTemplate attributeListTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(curProject.Id, TemplateType.ObjectAttributeList);

            ExportObjectData objectData = _exportObjectData.Clone();

            if (objectData.ExportData.ContainsKey(ExportConstants.ExportDataObject) && objectData.ExportData[ExportConstants.ExportDataObject] is IFlexFieldExportable)
            {
                ((IFlexFieldExportable)objectData.ExportData[ExportConstants.ExportDataObject]).Fields = ConvertListToFlexFieldList(fieldList);
            }

            ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectAttributeList, attributeListTemplate.Code, objectData, attributeListTemplate.RenderingEngine);

            _errorCollection.Merge(fillResult.Errors);

            return(ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code));
        }
        /// <summary>
        /// Renders an attribute list
        /// </summary>
        /// <param name="project">Current project</param>
        /// <param name="fields">Fields to render</param>
        /// <param name="data">Export data</param>
        /// <param name="indent">Indentation</param>
        /// <returns>Rendered attribute list</returns>
        private async Task <string> RenderAttributeList(GoNorthProject project, List <FlexField> fields, ExportObjectData data, string indent)
        {
            ExportTemplate attributeListTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.ObjectAttributeList);

            ExportObjectData objectData = data.Clone();

            if (objectData.ExportData.ContainsKey(ExportConstants.ExportDataObject) && objectData.ExportData[ExportConstants.ExportDataObject] is IFlexFieldExportable)
            {
                ((IFlexFieldExportable)objectData.ExportData[ExportConstants.ExportDataObject]).Fields = fields;
            }

            ExportPlaceholderFillResult fillResult = await _placeholderResolver.FillPlaceholders(TemplateType.ObjectAttributeList, attributeListTemplate.Code, objectData, attributeListTemplate.RenderingEngine);

            _errorCollection.Merge(fillResult.Errors);

            return(ExportUtil.IndentListTemplate(fillResult.Code, indent));
        }