/// <summary> /// Returns the value object to use /// </summary> /// <param name="parsedData">Parsed data</param> /// <param name="flexFieldObject">Flex field object</param> /// <param name="errorCollection">Error Collection</param> /// <returns>Value Object</returns> protected override async Task <IFlexFieldExportable> GetValueObject(ValueFieldActionData parsedData, FlexFieldObject flexFieldObject, ExportPlaceholderErrorCollection errorCollection) { AikaQuest quest = await _cachedDbAccess.GetQuestById(parsedData.ObjectId); if (quest == null) { errorCollection.AddDialogQuestNotFoundError(); return(null); } return(quest); }
/// <summary> /// Returns the value object to use /// </summary> /// <param name="parsedData">Parsed data</param> /// <param name="flexFieldObject">Flex field object</param> /// <param name="errorCollection">Error Collection</param> /// <returns>Value Object</returns> protected override async Task <IFlexFieldExportable> GetValueObject(ValueFieldActionData parsedData, FlexFieldObject flexFieldObject, ExportPlaceholderErrorCollection errorCollection) { EvneSkill skill = await _cachedDbAccess.GetSkillById(parsedData.ObjectId); if (skill == null) { errorCollection.AddDialogSkillNotFoundError(); return(null); } return(skill); }
/// <summary> /// Returns the value object to use /// </summary> /// <param name="parsedData">Parsed data</param> /// <param name="flexFieldObject">Flex field object</param> /// <param name="errorCollection">Error Collection</param> /// <returns>Value Object</returns> protected override async Task <IFlexFieldExportable> GetValueObject(ValueFieldActionData parsedData, FlexFieldObject flexFieldObject, ExportPlaceholderErrorCollection errorCollection) { if (_isPlayer) { GoNorthProject curProject = await _cachedDbAccess.GetUserProject(); flexFieldObject = await _cachedDbAccess.GetPlayerNpc(curProject.Id); if (flexFieldObject == null) { errorCollection.AddNoPlayerNpcExistsError(); return(null); } } return(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)); }
/// <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) { ScribanValueActionData valueData = new ScribanValueActionData(); valueData.ValueObject = FlexFieldValueCollectorUtil.ConvertScribanFlexFieldObject(valueObject, exportSettings, errorCollection); valueData.TargetField = FlexFieldValueCollectorUtil.GetFlexField(valueData.ValueObject.Fields.Values, parsedData.FieldId, parsedData.FieldName); if (valueData.TargetField == null) { errorCollection.AddErrorFlexField(parsedData.FieldName, valueObject.Name); return(string.Empty); } valueData.Operator = actionOperator; valueData.OriginalOperator = parsedData.Operator; valueData.ValueChange = FlexFieldValueCollectorUtil.MapValueToFieldValue(valueData.TargetField, parsedData.ValueChange, exportSettings); return(await ScribanActionRenderingUtil.FillPlaceholders(_cachedDbAccess, errorCollection, template.Code, valueData, flexFieldObject, curStep, nextStep, _scribanLanguageKeyGenerator, stepRenderer)); }
/// <summary> /// Returns the value object to use /// </summary> /// <param name="parsedData">Parsed data</param> /// <param name="flexFieldObject">Flex field object</param> /// <param name="errorCollection">Error Collection</param> /// <returns>Value Object</returns> protected override Task <IFlexFieldExportable> GetValueObject(ValueFieldActionData parsedData, FlexFieldObject flexFieldObject, ExportPlaceholderErrorCollection errorCollection) { return(Task.FromResult <IFlexFieldExportable>(flexFieldObject)); }
/// <summary> /// Returns the value object to use /// </summary> /// <param name="parsedData">Parsed data</param> /// <param name="npc">Npc</param> /// <param name="errorCollection">Error Collection</param> /// <returns>Value Object</returns> protected abstract Task <IFlexFieldExportable> GetValueObject(ValueFieldActionData parsedData, KortistoNpc npc, ExportPlaceholderErrorCollection errorCollection);