Beispiel #1
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, FadeToFromBlackActionData parsedData, ExportDialogData data, ExportDialogData nextStep, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection,
                                                                      FlexFieldObject flexFieldObject, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_FadeTime).Replace(template.Code, parsedData.FadeTime.ToString());

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, data, nextStep, flexFieldObject));
        }
        /// <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="npc">Npc to move</param>
        /// <param name="targetNpc">Target npc</param>
        /// <param name="directContinueFunction">Direct continue function</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="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, MoveNpcToNpcActionData parsedData, KortistoNpc npc, KortistoNpc targetNpc, string directContinueFunction,
                                                                FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            ExportObjectData flexFieldExportData = new ExportObjectData();

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

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

            if (!_isTeleport)
            {
                actionCode = BuildDirectContinueFunction(directContinueFunction, actionCode);
                actionCode = BuildMovementState(parsedData, actionCode);
            }

            ExportObjectData flexFieldTargetExportData = new ExportObjectData();

            flexFieldTargetExportData.ExportData.Add(ExportConstants.ExportDataObject, targetNpc);
            flexFieldTargetExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc);

            _flexFieldTargetPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = _flexFieldTargetPlaceholderResolver.FillPlaceholders(actionCode, flexFieldTargetExportData).Result;

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
Beispiel #3
0
        /// <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="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="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, CodeActionData parsedData, FlexFieldObject flexFieldObject, ExportDialogData curStep,
                                                                ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ScriptName).Replace(template.Code, ExportUtil.EscapeCharacters(parsedData.ScriptName, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));

            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ScriptCode).Replace(actionCode, parsedData.ScriptCode);

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
        /// <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="projectConfig">Project config</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="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, SetGameTimeActionData parsedData, MiscProjectConfig projectConfig, FlexFieldObject flexFieldObject,
                                                                ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Hours).Replace(template.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(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
Beispiel #5
0
        /// <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="valueObject">Value object 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="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, LearnForgetSkillActionData parsedData, IFlexFieldExportable valueObject, FlexFieldObject flexFieldObject,
                                                                ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeSkill);

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

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
        /// <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)
        {
            string actionCode = 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);
            actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData).Result;

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
Beispiel #7
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, ChangeTargetNpcStateActionData parsedData, ExportDialogData data, ExportDialogData nextStep, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection,
                                                                      FlexFieldObject flexFieldObject, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_State).Replace(template.Code, ExportUtil.EscapeCharacters(parsedData.ObjectState, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, flexFieldObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeSkill);

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

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, data, nextStep, flexFieldObject));
        }
        /// <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="valueObject">Value object to use</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="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, PlayAnimationActionData parsedData, IFlexFieldExportable valueObject, FlexFieldObject flexFieldObject,
                                                                ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Animation).Replace(template.Code, ExportUtil.EscapeCharacters(parsedData.AnimationName, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));

            ExportObjectData flexFieldExportData = new ExportObjectData();

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

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

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
        /// <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="valueObject">Value object 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="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, InventoryActionData parsedData, IFlexFieldExportable valueObject, FlexFieldObject flexFieldObject, ExportDialogData curStep,
                                                                ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Quantity).Replace(template.Code, parsedData.Quantity.HasValue ? parsedData.Quantity.Value.ToString() : "1");

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeItem);

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

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
Beispiel #10
0
        /// <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="directContinueFunction">Direct continue function</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="stepRenderer">Action Step renderer</param>
        /// <returns>Filled placeholders</returns>
        protected override async Task <string> FillPlaceholders(ExportTemplate template, ExportPlaceholderErrorCollection errorCollection, WaitActionData parsedData, string directContinueFunction, FlexFieldObject flexFieldObject,
                                                                ExportDialogData curStep, ExportDialogData nextStep, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Wait_Amount).Replace(template.Code, parsedData.WaitAmount.ToString());

            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_WaitTypeIsRealTime_Start, Placeholder_WaitTypeIsRealTime_End, parsedData.WaitType == WaitActionData.WaitTypeRealTime);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_WaitTypeIsGameTime_Start, Placeholder_WaitTypeIsGameTime_End, parsedData.WaitType == WaitActionData.WaitTypeGameTime);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_WaitUnitIsMilliseconds_Start, Placeholder_WaitUnitIsMilliseconds_End, parsedData.WaitUnit == WaitActionData.WaitUnitMilliseconds);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_WaitUnitIsSeconds_Start, Placeholder_WaitUnitIsSeconds_End, parsedData.WaitUnit == WaitActionData.WaitUnitSeconds);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_WaitUnitIsMinutes_Start, Placeholder_WaitUnitIsMinutes_End, parsedData.WaitUnit == WaitActionData.WaitUnitMinutes);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_WaitUnitIsHours_Start, Placeholder_WaitUnitIsHours_End, parsedData.WaitUnit == WaitActionData.WaitUnitHours);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_WaitUnitIsDays_Start, Placeholder_WaitUnitIsDays_End, parsedData.WaitUnit == WaitActionData.WaitUnitDays);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_HasDirectContinueFunction_Start, Placeholder_HasDirectContinueFunction_End, !string.IsNullOrEmpty(directContinueFunction));
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_HasNoDirectContinueFunction_Start, Placeholder_HasNoDirectContinueFunction_End, string.IsNullOrEmpty(directContinueFunction));
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_DirectContinueFunction).Replace(actionCode, directContinueFunction);

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
Beispiel #11
0
        /// <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="valueObject">Value object</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="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, SetQuestStateActionData parsedData, IFlexFieldExportable valueObject, FlexFieldObject flexFieldObject,
                                                                ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.RenderPlaceholderIfTrue(template.Code, Placeholder_QuestState_NotStarted_Start, Placeholder_QuestState_NotStarted_End, parsedData.QuestState == SetQuestStateActionData.QuestState_NotStarted);

            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_QuestState_InProgress_Start, Placeholder_QuestState_InProgress_End, parsedData.QuestState == SetQuestStateActionData.QuestState_InProgress);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_QuestState_Success_Start, Placeholder_QuestState_Success_End, parsedData.QuestState == SetQuestStateActionData.QuestState_Success);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_QuestState_Failed_Start, Placeholder_QuestState_Failed_End, parsedData.QuestState == SetQuestStateActionData.QuestState_Failed);

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeQuest);

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

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
Beispiel #12
0
        /// <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="valueObject">Value object</param>
        /// <param name="marker">Marker at which to spawn the object</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="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, SpawnObjectActionData parsedData, IFlexFieldExportable valueObject, KartaMapNamedMarkerQueryResult marker,
                                                                FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TargetMarker_Name).Replace(template.Code, marker.MarkerName);

            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Rotation_Pitch).Replace(actionCode, parsedData.Pitch.ToString());
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Rotation_Yaw).Replace(actionCode, parsedData.Yaw.ToString());
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Rotation_Roll).Replace(actionCode, parsedData.Roll.ToString());

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, GetFlexFieldExportObjectType());

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

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
        /// <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="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="valueObject">Value object to export</param>
        /// <param name="curStep">Current step that is rendered</param>
        /// <param name="nextStep">Next step that is being rendered</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, AddQuestTextData parsedData, IFlexFieldExportable valueObject, FlexFieldObject flexFieldObject,
                                                                ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_QuestText).Replace(template.Code, ExportUtil.EscapeCharacters(parsedData.QuestText, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));

            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_QuestText_Preview).Replace(actionCode, ExportUtil.BuildTextPreview(parsedData.QuestText));
            actionCode = await ExportUtil.BuildPlaceholderRegex(Placeholder_QuestText_LangKey).ReplaceAsync(actionCode, async m => {
                return(await _languageKeyGenerator.GetDialogTextLineKey(flexFieldObject.Id, valueObject.Name, ExportConstants.LanguageKeyTypeQuest, curStep.Id, parsedData.QuestText));
            });

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeQuest);

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

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
        /// <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="valueItem">Item to export</param>
        /// <param name="valueNpc">Npc 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="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, UseItemActionData parsedData, IFlexFieldExportable valueItem, IFlexFieldExportable valueNpc,
                                                                FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = template.Code;

            ExportObjectData flexFieldExportDataItem = new ExportObjectData();

            flexFieldExportDataItem.ExportData.Add(ExportConstants.ExportDataObject, valueItem);
            flexFieldExportDataItem.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeItem);
            _flexFieldPlaceholderResolverItem.SetErrorMessageCollection(errorCollection);
            actionCode = await _flexFieldPlaceholderResolverItem.FillPlaceholders(actionCode, flexFieldExportDataItem);

            ExportObjectData flexFieldExportDataNpc = new ExportObjectData();

            flexFieldExportDataNpc.ExportData.Add(ExportConstants.ExportDataObject, valueNpc);
            flexFieldExportDataNpc.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc);
            _flexFieldPlaceholderResolverNpc.SetErrorMessageCollection(errorCollection);
            actionCode = await _flexFieldPlaceholderResolverNpc.FillPlaceholders(actionCode, flexFieldExportDataNpc);

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
Beispiel #15
0
        /// <summary>
        /// Fills the placeholders
        /// </summary>
        /// <param name="cachedDbAccess">Cached database access</param>
        /// <param name="errorCollection">Error collection</param>
        /// <param name="code">Code to fill</param>
        /// <param name="valueObject">Value object to use</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="languageKeyGenerator">Language key generator, null to not use it</param>
        /// <param name="stepRenderer">Action Step renderer</param>
        /// <typeparam name="T">Value object type</typeparam>
        /// <returns>Filled placeholders</returns>
        public static async Task <string> FillPlaceholders <T>(IExportCachedDbAccess cachedDbAccess, ExportPlaceholderErrorCollection errorCollection, string code, T valueObject, FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep,
                                                               IScribanLanguageKeyGenerator languageKeyGenerator, IActionStepRenderer stepRenderer) where T : class
        {
            if (!stepRenderer.UsesValueObject())
            {
                code = await stepRenderer.ReplaceBasePlaceholders(errorCollection, code, curStep, nextStep, flexFieldObject);
            }

            Template parsedTemplate = ScribanParsingUtil.ParseTemplate(code, errorCollection);

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

            if (languageKeyGenerator != null)
            {
                languageKeyGenerator.SetErrorCollection(errorCollection);
            }

            TemplateContext context = BuildTemplateContext(cachedDbAccess, errorCollection, valueObject, languageKeyGenerator, stepRenderer, flexFieldObject, curStep, nextStep);

            return(await parsedTemplate.RenderAsync(context));
        }
Beispiel #16
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, OpenShopActionRenderer.OpenShopActionData parsedData, ExportDialogData data, ExportDialogData nextStep, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection,
                                                               FlexFieldObject flexFieldObject, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
 {
     return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, template.Code, data, nextStep, flexFieldObject));
 }
        /// <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="valueObject">Value object to use</param>
        /// <param name="actionOperator">Action operator to use</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="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, ValueFieldActionData parsedData, IFlexFieldExportable valueObject, string actionOperator,
                                                                FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            FlexField exportField = DialogFlexFieldUtil.GetFlexField(valueObject, parsedData.FieldId);

            if (exportField == null)
            {
                errorCollection.AddErrorFlexField(parsedData.FieldName, valueObject.Name);
                return(string.Empty);
            }

            string actionCode = template.Code;

            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ValueName).Replace(actionCode, m => {
                return(DialogFlexFieldUtil.GetFieldName(exportField, parsedData.FieldName, errorCollection));
            });
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Operator).Replace(actionCode, actionOperator);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsSetTo_Start, Placeholder_OperatorIsSetTo_End, parsedData.Operator == "=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsNotSetTo_Start, Placeholder_OperatorIsNotSetTo_End, parsedData.Operator != "=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsAdd_Start, Placeholder_OperatorIsAdd_End, parsedData.Operator == "+=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsNotAdd_Start, Placeholder_OperatorIsNotAdd_End, parsedData.Operator != "+=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsSubstract_Start, Placeholder_OperatorIsSubstract_End, parsedData.Operator == "-=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsNotSubstract_Start, Placeholder_OperatorIsNotSubstract_End, parsedData.Operator != "-=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsMultiply_Start, Placeholder_OperatorIsMultiply_End, parsedData.Operator == "*=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsNotMultiply_Start, Placeholder_OperatorIsNotMultiply_End, parsedData.Operator != "*=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsDivide_Start, Placeholder_OperatorIsDivide_End, parsedData.Operator == "/=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsNotDivide_Start, Placeholder_OperatorIsNotDivide_End, parsedData.Operator != "/=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_ValueIsString_Start, Placeholder_ValueIsString_End, exportField.FieldType != ExportConstants.FlexFieldType_Number);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_ValueIsNumber_Start, Placeholder_ValueIsNumber_End, exportField.FieldType == ExportConstants.FlexFieldType_Number);
            actionCode = ExportUtil.RenderPlaceholderIfFuncTrue(actionCode, Placeholder_ValueNameEquals_Start, Placeholder_ValueNameEquals_End, m => {
                string searchedFieldName = m.Groups[1].Value;
                searchedFieldName        = searchedFieldName.ToLowerInvariant();
                string fieldName         = string.Empty;
                if (!string.IsNullOrEmpty(exportField.Name))
                {
                    fieldName = exportField.Name.ToLowerInvariant();
                }
                return(fieldName == searchedFieldName);
            });
            actionCode = ExportUtil.RenderPlaceholderIfFuncTrue(actionCode, Placeholder_ValueNameNotEquals_Start, Placeholder_ValueNameNotEquals_End, m => {
                string searchedFieldName = m.Groups[1].Value;
                searchedFieldName        = searchedFieldName.ToLowerInvariant();
                string fieldName         = string.Empty;
                if (!string.IsNullOrEmpty(exportField.Name))
                {
                    fieldName = exportField.Name.ToLowerInvariant();
                }
                return(fieldName != searchedFieldName);
            });
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ValueChange).Replace(actionCode, m => {
                if (exportField.FieldType != ExportConstants.FlexFieldType_Number)
                {
                    return(ExportUtil.EscapeCharacters(parsedData.ValueChange, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));
                }

                return(parsedData.ValueChange);
            });

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, GetFlexFieldExportObjectType());

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

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }