Beispiel #1
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, DailyRoutineEventStateConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            KortistoNpc eventNpc = await _cachedDbAccess.GetNpcById(parsedData.NpcId);

            if (eventNpc == null)
            {
                return(string.Empty);
            }

            KortistoNpcDailyRoutineEvent exportEvent = null;

            if (eventNpc.DailyRoutine != null)
            {
                exportEvent = eventNpc.DailyRoutine.FirstOrDefault(e => e.EventId == parsedData.EventId);
            }
            if (exportEvent == null)
            {
                errorCollection.AddDialogDailyRoutineEventNotFoundError(eventNpc.Name);
                return(string.Empty);
            }

            MiscProjectConfig projectConfig = await _cachedDbAccess.GetMiscProjectConfig();

            string conditionCode = await _dailyRoutineEventPlaceholderResolver.ResolveDailyRoutineEventPlaceholders(template.Code, eventNpc, exportEvent);

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, eventNpc);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            conditionCode = await _flexFieldPlaceholderResolver.FillPlaceholders(conditionCode, flexFieldExportData);

            return(conditionCode);
        }
Beispiel #2
0
        /// <summary>
        /// Builds an action from parsed data
        /// </summary>
        /// <param name="template">Template to export</param>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="data">Dialog data</param>
        /// <param name="nextStep">Next step in the dialog</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>
        /// <param name="stepRenderer">Action Step renderer</param>
        /// <returns>Action string</returns>
        public override async Task <string> BuildActionFromParsedData(ExportTemplate template, SetGameTimeActionData parsedData, ExportDialogData data, ExportDialogData nextStep, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection,
                                                                      FlexFieldObject flexFieldObject, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            MiscProjectConfig projectConfig = await _cachedDbAccess.GetMiscProjectConfig();

            return(await FillPlaceholders(template, errorCollection, parsedData, projectConfig, flexFieldObject, data, nextStep, exportSettings, stepRenderer));
        }
        /// <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 <ScribanDailyRoutineEventStateConditionData> GetExportObject(DailyRoutineEventStateConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            KortistoNpc eventNpc = await _cachedDbAccess.GetNpcById(parsedData.NpcId);

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

            KortistoNpcDailyRoutineEvent exportEvent = null;

            if (eventNpc.DailyRoutine != null)
            {
                exportEvent = eventNpc.DailyRoutine.FirstOrDefault(e => e.EventId == parsedData.EventId);
            }
            if (exportEvent == null)
            {
                errorCollection.AddDialogDailyRoutineEventNotFoundError(eventNpc.Name);
                return(null);
            }

            MiscProjectConfig projectConfig = await _cachedDbAccess.GetMiscProjectConfig();

            ScribanDailyRoutineEventStateConditionData conditionData = new ScribanDailyRoutineEventStateConditionData();

            conditionData.Npc = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, eventNpc, exportSettings, errorCollection);
            conditionData.DailyRoutineEvent = await ScribanDailyRoutineEventUtil.ConvertDailyRoutineEvent(_dailyRoutineFunctionNameGenerator, eventNpc, exportEvent, project, projectConfig, exportSettings);

            return(conditionData);
        }
Beispiel #4
0
        /// <summary>
        /// Builds an action from parsed data
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="data">Dialog 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>Action string</returns>
        public override async Task <string> BuildActionFromParsedData(SetGameTimeActionRenderer.SetGameTimeActionData parsedData, ExportDialogData data, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            ExportTemplate actionTemplate = await GetExportTemplate(project);

            MiscProjectConfig projectConfig = await _cachedDbAccess.GetMiscProjectConfig();

            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Hours).Replace(actionTemplate.Code, parsedData.Hours.ToString());

            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Minutes).Replace(actionCode, parsedData.Minutes.ToString());
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TotalMinutes).Replace(actionCode, (parsedData.Hours * projectConfig.MinutesPerHour + parsedData.Minutes).ToString());

            return(actionCode);
        }
        /// <summary>
        /// Fills the placeholders
        /// </summary>
        /// <param name="template">Template to use</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="parsedData">Parsed config data</param>
        /// <param name="eventNpc">Npc to which the event belongs</param>
        /// <param name="exportEvent">Event to export</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="curStep">Current step that is rendered</param>
        /// <param name="nextStep">Next step that is being rendered</param>
        /// <param name="project">Project</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <param name="stepRenderer">Action Step renderer</param>
        /// <returns>Filled placeholders</returns>
        protected override async Task <string> FillPlaceholders(ExportTemplate template, ExportPlaceholderErrorCollection errorCollection, SetDailyRoutineEventStateData parsedData, KortistoNpc eventNpc, KortistoNpcDailyRoutineEvent exportEvent,
                                                                FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, GoNorthProject project, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            MiscProjectConfig projectConfig = await _cachedDbAccess.GetMiscProjectConfig();

            ScribanSetDailyRoutineEventStateActionData setDailyRoutineEventStateData = new ScribanSetDailyRoutineEventStateActionData();

            setDailyRoutineEventStateData.Npc               = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, eventNpc, exportSettings, errorCollection);
            setDailyRoutineEventStateData.Npc.IsPlayer      = eventNpc.IsPlayerNpc;
            setDailyRoutineEventStateData.DailyRoutineEvent = await ScribanDailyRoutineEventUtil.ConvertDailyRoutineEvent(_dailyRoutineFunctionNameGenerator, eventNpc, exportEvent, project, projectConfig, exportSettings);

            return(await ScribanActionRenderingUtil.FillPlaceholders(_cachedDbAccess, errorCollection, template.Code, setDailyRoutineEventStateData, flexFieldObject, curStep, nextStep, _scribanLanguageKeyGenerator, stepRenderer));
        }
        /// <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, GameTimeConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            MiscProjectConfig projectConfig = await _cachedDbAccess.GetMiscProjectConfig();

            string conditionCode = ExportUtil.RenderPlaceholderIfTrue(template.Code, Placeholder_Operator_Is_Before_Start, Placeholder_Operator_Is_Before_End, parsedData.Operator == GameTimeConditionData.Operator_Before);

            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_Operator_Is_After_Start, Placeholder_Operator_Is_After_End, parsedData.Operator == GameTimeConditionData.Operator_After);
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Operator).Replace(conditionCode, await ConditionRenderingUtil.GetGameTimeCompareOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection));
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Hours).Replace(conditionCode, parsedData.Hour.ToString());
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Minutes).Replace(conditionCode, parsedData.Minutes.ToString());
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TotalMinutes).Replace(conditionCode, (parsedData.Hour * projectConfig.MinutesPerHour + parsedData.Minutes).ToString());

            return(conditionCode);
        }
Beispiel #7
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 <ScribanGameTimeConditionData> GetExportObject(GameTimeConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            MiscProjectConfig projectConfig = await _cachedDbAccess.GetMiscProjectConfig();

            ScribanGameTimeConditionData conditionData = new ScribanGameTimeConditionData();

            conditionData.Hours        = parsedData.Hour;
            conditionData.Minutes      = parsedData.Minutes;
            conditionData.TotalMinutes = parsedData.Hour * projectConfig.MinutesPerHour + parsedData.Minutes;
            conditionData.Operator     = await ConditionRenderingUtil.GetGameTimeCompareOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection);

            conditionData.OriginalOperator = ConvertGameTimeOperator(parsedData.Operator);

            return(conditionData);
        }
Beispiel #8
0
        /// <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="npc">Npc to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Condition string</returns>
        public override string BuildConditionElementFromParsedData(GameTimeConditionResolver.GameTimeConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, KortistoNpc npc, ExportSettings exportSettings)
        {
            ExportTemplate conditionTemplate = _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.TaleConditionGameTime).Result;

            MiscProjectConfig projectConfig = _cachedDbAccess.GetMiscProjectConfig().Result;

            string conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionTemplate.Code, Placeholder_Operator_Is_Before_Start, Placeholder_Operator_Is_Before_End, parsedData.Operator == Operator_Before);

            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_Operator_Is_After_Start, Placeholder_Operator_Is_After_End, parsedData.Operator == Operator_After);
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Operator).Replace(conditionCode, GetOperatorFromTemplate(project, parsedData.Operator, errorCollection));
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Hours).Replace(conditionCode, parsedData.Hour.ToString());
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Minutes).Replace(conditionCode, parsedData.Minutes.ToString());
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TotalMinutes).Replace(conditionCode, (parsedData.Hour * projectConfig.MinutesPerHour + parsedData.Minutes).ToString());

            return(conditionCode);
        }
Beispiel #9
0
        /// <summary>
        /// Renders a dialog step
        /// </summary>
        /// <param name="template">Export template</param>
        /// <param name="data">Dialog Step Data</param>
        /// <param name="project">Project for which the epxort is running</param>
        /// <param name="referenceNodeData">Reference node data</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <returns>Dialog Step Render Result</returns>
        public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportTemplate template, ExportDialogData data, GoNorthProject project, ReferenceNodeData referenceNodeData, FlexFieldObject flexFieldObject)
        {
            ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult();

            Template parsedTemplate = ScribanParsingUtil.ParseTemplate(template.Code, _errorCollection);

            if (parsedTemplate == null)
            {
                return(renderResult);
            }

            MiscProjectConfig projectConfig = await _exportCachedDbAccess.GetMiscProjectConfig();

            _languageKeyGenerator.SetErrorCollection(_errorCollection);

            ScribanReferenceData referenceData = BuildDialogRenderObject <ScribanReferenceData>(data, data.Children.FirstOrDefault() != null ? data.Children.FirstOrDefault().Child : null, flexFieldObject);

            referenceData.ReferenceText = referenceNodeData.ReferenceText != null ? referenceNodeData.ReferenceText : string.Empty;
            referenceData.ObjectType    = referenceNodeData.ObjectType;
            if (referenceNodeData.Npc != null)
            {
                referenceData.Npc          = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, referenceNodeData.Npc, _exportSettings, _errorCollection);
                referenceData.Npc.IsPlayer = referenceNodeData.Npc.IsPlayerNpc;
            }
            else
            {
                referenceData.Npc = null;
            }
            referenceData.Item = referenceNodeData.Item != null?FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportItem>(null, null, referenceNodeData.Item, _exportSettings, _errorCollection) : null;

            referenceData.Skill = referenceNodeData.Skill != null?FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportSkill>(null, null, referenceNodeData.Skill, _exportSettings, _errorCollection) : null;

            referenceData.Quest = referenceNodeData.Quest != null?FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportQuest>(null, null, referenceNodeData.Quest, _exportSettings, _errorCollection) : null;

            referenceData.WikiPage          = referenceNodeData.WikiPage != null ? new ScribanExportWikiPage(referenceNodeData.WikiPage) : null;
            referenceData.DailyRoutineEvent = referenceNodeData.DailyRoutineEvent != null ? await ScribanDailyRoutineEventUtil.ConvertDailyRoutineEvent(_dailyRoutineFunctionNameGenerator, referenceNodeData.Npc, referenceNodeData.DailyRoutineEvent, project, projectConfig, _exportSettings) : null;

            referenceData.Marker = referenceNodeData.Marker != null ? new ScribanExportMapMarker(referenceNodeData.Marker) : null;

            TemplateContext context = BuildTemplateContext(referenceData);

            renderResult.StepCode = await parsedTemplate.RenderAsync(context);

            return(renderResult);
        }
        /// <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="npc">Npc to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Condition string</returns>
        public override string BuildConditionElementFromParsedData(DailyRoutineEventStateConditionResolver.DailyRoutineEventStateConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, KortistoNpc npc, ExportSettings exportSettings)
        {
            ExportTemplate conditionTemplate = _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, _isDisabled ? TemplateType.TaleConditionDailyRoutineEventDisabled : TemplateType.TaleConditionDailyRoutineEventEnabled).Result;

            KortistoNpc eventNpc = _cachedDbAccess.GetNpcById(parsedData.NpcId).Result;

            if (eventNpc == null)
            {
                return(string.Empty);
            }

            KortistoNpcDailyRoutineEvent exportEvent = null;

            if (eventNpc.DailyRoutine != null)
            {
                exportEvent = eventNpc.DailyRoutine.FirstOrDefault(e => e.EventId == parsedData.EventId);
            }
            if (exportEvent == null)
            {
                errorCollection.AddDialogDailyRoutineEventNotFoundError(eventNpc.Name);
                return(string.Empty);
            }

            MiscProjectConfig projectConfig = _cachedDbAccess.GetMiscProjectConfig().Result;

            string conditionCode = _dailyRoutineEventPlaceholderResolver.ResolveDailyRoutineEventPlaceholders(conditionTemplate.Code, eventNpc, exportEvent).Result;

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, eventNpc);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            conditionCode = _flexFieldPlaceholderResolver.FillPlaceholders(conditionCode, flexFieldExportData).Result;

            return(conditionCode);
        }
        /// <summary>
        /// Resolved the placeholders for a single daily routine event
        /// </summary>
        /// <param name="code">Code to resolve the placeholders in</param>
        /// <param name="npc">Npc to which the event belongs</param>
        /// <param name="dailyRoutineEvent">Daily routine to use for resolving the placeholders</param>
        /// <returns>Code with resolved placeholders</returns>
        public async Task <string> ResolveDailyRoutineEventPlaceholders(string code, KortistoNpc npc, KortistoNpcDailyRoutineEvent dailyRoutineEvent)
        {
            GoNorthProject defaultProject = await _cachedDbAccess.GetDefaultProject();

            MiscProjectConfig projectConfig = await _cachedDbAccess.GetMiscProjectConfig();

            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasMovementTargetStart, Placeholder_HasMovementTargetEnd, dailyRoutineEvent.MovementTarget != null && !string.IsNullOrEmpty(dailyRoutineEvent.MovementTarget.Name));
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasNoMovementTargetStart, Placeholder_HasNoMovementTargetEnd, dailyRoutineEvent.MovementTarget == null || string.IsNullOrEmpty(dailyRoutineEvent.MovementTarget.Name));
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasMovementTargetExportNameStart, Placeholder_HasMovementTargetExportNameEnd, dailyRoutineEvent.MovementTarget != null && !string.IsNullOrEmpty(dailyRoutineEvent.MovementTarget.ExportName));
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasNoMovementTargetExportNameStart, Placeholder_HasNoMovementTargetExportNameEnd, dailyRoutineEvent.MovementTarget == null || string.IsNullOrEmpty(dailyRoutineEvent.MovementTarget.ExportName));
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasNoScriptStart, Placeholder_HasNoScriptEnd, dailyRoutineEvent.ScriptType == ScriptType_None);
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasScriptStart, Placeholder_HasScriptEnd, dailyRoutineEvent.ScriptType != ScriptType_None);
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasNodeGraphScriptStart, Placeholder_HasNodeGraphScriptEnd, dailyRoutineEvent.ScriptType == ScriptType_NodeGraph);
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasCodeScriptStart, Placeholder_HasCodeScriptEnd, dailyRoutineEvent.ScriptType == ScriptType_Code);
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasTargetStateStart, Placeholder_HasTargetStateEnd, !string.IsNullOrEmpty(dailyRoutineEvent.TargetState));
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasNoTargetStateStart, Placeholder_HasNoTargetStateEnd, string.IsNullOrEmpty(dailyRoutineEvent.TargetState));
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_IsEnabledByDefaultStart, Placeholder_IsEnabledByDefaultEnd, dailyRoutineEvent.EnabledByDefault);
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_IsDisabledByDefaultStart, Placeholder_IsDisabledByDefaultEnd, !dailyRoutineEvent.EnabledByDefault);

            code = ExportUtil.BuildPlaceholderRegex(Placeholder_EventId).Replace(code, dailyRoutineEvent.EventId);
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_EarliestTime_Hours).Replace(code, dailyRoutineEvent.EarliestTime != null ? dailyRoutineEvent.EarliestTime.Hours.ToString() : string.Empty);
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_EarliestTime_Minutes).Replace(code, dailyRoutineEvent.EarliestTime != null ? dailyRoutineEvent.EarliestTime.Minutes.ToString() : string.Empty);
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_EarliestTime_TotalMinutes).Replace(code, dailyRoutineEvent.EarliestTime != null ? (dailyRoutineEvent.EarliestTime.Hours * projectConfig.MinutesPerHour + dailyRoutineEvent.EarliestTime.Minutes).ToString() : string.Empty);
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_LatestTime_Hours).Replace(code, dailyRoutineEvent.LatestTime != null ? dailyRoutineEvent.LatestTime.Hours.ToString() : string.Empty);
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_LatestTime_Minutes).Replace(code, dailyRoutineEvent.LatestTime != null ? dailyRoutineEvent.LatestTime.Minutes.ToString() : string.Empty);
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_LatestTime_TotalMinutes).Replace(code, dailyRoutineEvent.LatestTime != null ? (dailyRoutineEvent.LatestTime.Hours * projectConfig.MinutesPerHour + dailyRoutineEvent.LatestTime.Minutes).ToString() : string.Empty);
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_MovementTargetName).Replace(code, dailyRoutineEvent.MovementTarget != null && dailyRoutineEvent.MovementTarget.Name != null ? dailyRoutineEvent.MovementTarget.Name : string.Empty);
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_MovementTargetExportName).Replace(code, dailyRoutineEvent.MovementTarget != null && dailyRoutineEvent.MovementTarget.ExportName != null ? dailyRoutineEvent.MovementTarget.ExportName : string.Empty);
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_MovementTargetExportNameOrName).Replace(code, dailyRoutineEvent.MovementTarget != null && !string.IsNullOrEmpty(dailyRoutineEvent.MovementTarget.ExportName) ? dailyRoutineEvent.MovementTarget.ExportName : (dailyRoutineEvent.MovementTarget != null && dailyRoutineEvent.MovementTarget.Name != null ? dailyRoutineEvent.MovementTarget.Name : string.Empty));
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_ScriptFunctionName).Replace(code, m => {
                return(_dailyRoutineFunctionNameGenerator.GetNewDailyRoutineStepFunction(defaultProject.Id, npc.Id, dailyRoutineEvent.EventId).Result);
            });
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_ScriptName).Replace(code, dailyRoutineEvent.ScriptName != null ? dailyRoutineEvent.ScriptName : string.Empty);
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_TargetState).Replace(code, dailyRoutineEvent.TargetState != null ? dailyRoutineEvent.TargetState : string.Empty);

            return(code);
        }
        /// <summary>
        /// Maps the daily routine data of an npc
        /// </summary>
        /// <param name="cachedDbAccess">Gecachter Datenzugriff</param>
        /// <param name="dailyRoutineFunctionNameGenerator">Daily routine function name generator</param>
        /// <param name="npc">Npc</param>
        /// <param name="dailyRoutine">Daily routine data</param>
        /// <returns>Mapped daily routine events</returns>
        public static async Task <List <ScribanExportDailyRoutineEvent> > MapNpcDailyRoutineEvents(IExportCachedDbAccess cachedDbAccess, IDailyRoutineFunctionNameGenerator dailyRoutineFunctionNameGenerator, KortistoNpc npc, List <KortistoNpcDailyRoutineEvent> dailyRoutine)
        {
            if (dailyRoutine == null || !dailyRoutine.Any())
            {
                return(new List <ScribanExportDailyRoutineEvent>());
            }

            GoNorthProject project = await cachedDbAccess.GetUserProject();

            MiscProjectConfig projectConfig = await cachedDbAccess.GetMiscProjectConfig();

            ExportSettings exportSettings = await cachedDbAccess.GetExportSettings(project.Id);

            List <ScribanExportDailyRoutineEvent> mappedEvents = new List <ScribanExportDailyRoutineEvent>();

            foreach (KortistoNpcDailyRoutineEvent curEvent in dailyRoutine)
            {
                ScribanExportDailyRoutineEvent convertedEvent = await ConvertDailyRoutineEvent(dailyRoutineFunctionNameGenerator, npc, curEvent, project, projectConfig, exportSettings);

                mappedEvents.Add(convertedEvent);
            }

            return(mappedEvents);
        }