예제 #1
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));
        }
        /// <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));
        }
예제 #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));
        }
예제 #4
0
        /// <summary>
        /// Indents a text value
        /// </summary>
        /// <param name="context">Template context</param>
        /// <param name="callerContext">Caller context</param>
        /// <param name="arguments">Arguments to render the list with</param>
        /// <returns>Indented text value</returns>
        private ValueTask <object> IndentValue(TemplateContext context, ScriptNode callerContext, ScriptArray arguments)
        {
            if (arguments.Count != 1 || arguments[0] == null)
            {
                return(new ValueTask <object>("<<NO VALID INDENTATION TEXT PROVIDED>>"));
            }

            string indentCode = arguments[0].ToString();

            return(new ValueTask <object>(ScribanOutputUtil.IndentMultilineCode(context, indentCode)));
        }
예제 #5
0
        /// <summary>
        /// Renders an state machine function
        /// </summary>
        /// <param name="context">Template context</param>
        /// <param name="callerContext">Caller context</param>
        /// <param name="arguments">Arguments to render the function with</param>
        /// <returns>Rendered state machine function</returns>
        private async ValueTask <object> RenderStateMachineFunction(TemplateContext context, ScriptNode callerContext, ScriptArray arguments)
        {
            if (arguments.Count != 1 || !(arguments[0] is ScribanExportStateFunction))
            {
                _errorCollection.AddInvalidParameter(ScribanErrorUtil.FormatScribanSpan(callerContext.Span));
                return("<<DID NOT PROVIDE VALID STATE MACHINE FUNCTION>>");
            }
            ScribanExportStateFunction exportFunction = (ScribanExportStateFunction)arguments[0];

            GoNorthProject curProject = await _exportCachedDbAccess.GetUserProject();

            ExportTemplate eventFunctionTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(curProject.Id, TemplateType.ObjectStateFunction);

            ExportObjectData objectData = new ExportObjectData();

            objectData.ExportData.Add(ExportConstants.ExportDataObject, exportFunction.ToStateFunction());

            ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectStateFunction, eventFunctionTemplate.Code, objectData, eventFunctionTemplate.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));
        }