Пример #1
0
        /// <summary>
        /// Builds a preview text from parsed data
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="child">Child node</param>
        /// <param name="parent">Parent</param>
        /// <returns>Preview text</returns>
        public override async Task <string> BuildPreviewTextFromParsedData(SetDailyRoutineEventState.SetDailyRoutineEventStateData parsedData, FlexFieldObject flexFieldObject, ExportPlaceholderErrorCollection errorCollection, ExportDialogData child, ExportDialogData parent)
        {
            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);
            }

            string timeDisplay = FormatDailyRoutineEventTime(exportEvent.EarliestTime);

            if (exportEvent.EarliestTime != null && exportEvent.LatestTime != null && (exportEvent.EarliestTime.Hours != exportEvent.LatestTime.Hours || exportEvent.EarliestTime.Minutes != exportEvent.LatestTime.Minutes))
            {
                if (!string.IsNullOrEmpty(timeDisplay))
                {
                    timeDisplay += " - ";
                }
                timeDisplay += FormatDailyRoutineEventTime(exportEvent.LatestTime);
            }

            return(GetPreviewPrefix() + " (" + eventNpc.Name + ", " + timeDisplay + ")");
        }
Пример #2
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(SetDailyRoutineEventState.SetDailyRoutineEventStateData parsedData, ExportDialogData data, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            ExportTemplate actionTemplate = await GetExportTemplate(project);

            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);
            }

            string actionCode = await _dailyRoutineEventPlaceholderResolver.ResolveDailyRoutineEventPlaceholders(actionTemplate.Code, eventNpc, exportEvent);

            ExportObjectData flexFieldExportData = new ExportObjectData();

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

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

            return(actionCode);
        }
        /// <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);
        }
        /// <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);
        }
Пример #5
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, SetDailyRoutineEventStateData parsedData, ExportDialogData data, ExportDialogData nextStep, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection,
                                                                      FlexFieldObject flexFieldObject, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            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);
            }

            return(await FillPlaceholders(template, errorCollection, parsedData, eventNpc, exportEvent, flexFieldObject, data, nextStep, project, exportSettings, stepRenderer));
        }