Пример #1
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>
        /// Builds the event list
        /// </summary>
        /// <param name="eventCode">Code for the events to repeat</param>
        /// <param name="project">Project to export for</param>
        /// <param name="npc">Npc</param>
        /// <returns>Daily Routine event list of the npc</returns>
        private string BuildEventList(string eventCode, GoNorthProject project, KortistoNpc npc)
        {
            if (npc.DailyRoutine == null)
            {
                return(string.Empty);
            }

            int    eventIndex    = 0;
            string eventListCode = string.Empty;

            foreach (KortistoNpcDailyRoutineEvent curEvent in npc.DailyRoutine)
            {
                string curEventCode = ExportUtil.BuildPlaceholderRegex(Placeholder_CurEvent_Index).Replace(eventCode, eventIndex.ToString());

                curEventCode = _eventPlaceholderResolver.ResolveDailyRoutineEventPlaceholders(curEventCode, npc, curEvent).Result;

                eventListCode += curEventCode;
                ++eventIndex;
            }

            return(eventListCode);
        }
        /// <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);
        }