/// <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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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 daily routine function 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 function list</returns>
        private async ValueTask <object> RenderDailyRoutineFunctionList(TemplateContext context, ScriptNode callerContext, ScriptArray arguments)
        {
            List <ScribanExportDailyRoutineFunction> functionList = ScribanParsingUtil.GetArrayFromScribanArgument <ScribanExportDailyRoutineFunction>(arguments, 0);

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

            GoNorthProject curProject = await _exportCachedDbAccess.GetUserProject();

            ExportTemplate functionListTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(curProject.Id, TemplateType.ObjectDailyRoutineFunctionList);

            ExportObjectData objectData = new ExportObjectData();

            objectData.ExportData.Add(ExportConstants.ExportDataObject, functionList.Select(f => f.ToDailyRoutineFunction()).ToList());

            ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectDailyRoutineFunctionList, functionListTemplate.Code, objectData, functionListTemplate.RenderingEngine);

            _errorCollection.Merge(fillResult.Errors);

            return(ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code));
        }