Beispiel #1
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 <ScribanLearnedSkillConditionData> GetExportObject(LearnedSkillConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            KortistoNpc npc = await ConditionRenderingUtil.GetExportNpc(_cachedDbAccess, project, flexFieldObject, errorCollection, _isPlayer);

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

            EvneSkill skill = await _cachedDbAccess.GetSkillById(parsedData.SelectedSkillId);

            if (skill == null)
            {
                errorCollection.AddDialogSkillNotFoundError();
                return(null);
            }

            ScribanLearnedSkillConditionData conditionData = new ScribanLearnedSkillConditionData();
            ScribanExportNpc convertedNpc = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, npc, exportSettings, errorCollection);

            convertedNpc.IsPlayer = npc.IsPlayerNpc;
            conditionData.Npc     = convertedNpc;

            conditionData.SelectedSkill = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportSkill>(null, null, skill, exportSettings, errorCollection);

            return(conditionData);
        }
Beispiel #2
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 <ScribanValueConditionData> GetExportObject(ValueFieldConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            ScribanFlexFieldObject exportObject = await GetScribanFlexFieldObject(parsedData, project, errorCollection, flexFieldObject, exportSettings);

            if (exportObject == null)
            {
                return(null);
            }

            ScribanValueConditionData conditionData = new ScribanValueConditionData();

            conditionData.ValueObject = exportObject;

            conditionData.SelectedField = null;
            if (parsedData.FieldId != null)
            {
                conditionData.SelectedField = FlexFieldValueCollectorUtil.GetFlexField(conditionData.ValueObject.Fields.Values, parsedData.FieldId, parsedData.FieldName);
            }
            conditionData.IsOperatorPrimitive = ConditionRenderingUtil.IsConditionOperatorPrimitiveOperator(parsedData.Operator);
            conditionData.OriginalOperator    = parsedData.Operator;
            conditionData.Operator            = await ConditionRenderingUtil.GetCompareOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection);

            conditionData.CompareValue = FlexFieldValueCollectorUtil.MapValueToFieldValue(conditionData.SelectedField, parsedData.CompareValue, exportSettings);

            return(conditionData);
        }
        /// <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 <ScribanInventoryConditionData> GetExportObject(InventoryConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            KortistoNpc npc = await ConditionRenderingUtil.GetExportNpc(_cachedDbAccess, project, flexFieldObject, errorCollection, _isPlayer);

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

            StyrItem item = await _cachedDbAccess.GetItemById(parsedData.ItemId);

            if (item == null)
            {
                errorCollection.AddDialogItemNotFoundError();
                return(null);
            }

            ScribanInventoryConditionData conditionData = new ScribanInventoryConditionData();
            ScribanExportNpc convertedNpc = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, npc, exportSettings, errorCollection);

            convertedNpc.IsPlayer = npc.IsPlayerNpc;
            conditionData.Npc     = convertedNpc;

            conditionData.SelectedItem = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportItem>(null, null, item, exportSettings, errorCollection);

            conditionData.OriginalOperator = parsedData.Operator == InventoryConditionData.CompareOperator_AtLeast ? "AtLeast" : "AtMaximum";
            conditionData.Operator         = await ConditionRenderingUtil.GetItemCompareOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection);

            conditionData.Quantity = parsedData.Quantity;

            return(conditionData);
        }
        /// <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, GroupConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            string groupContent    = template.Code;
            string operatorContent = await ConditionRenderingUtil.GetGroupOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection);

            string renderedConditionElements = await _conditionRenderer.RenderConditionElements(project, parsedData.ConditionElements, operatorContent, errorCollection, flexFieldObject, exportSettings);

            groupContent = ExportUtil.BuildPlaceholderRegex(Placeholder_GroupContent).Replace(groupContent, renderedConditionElements);
            return(groupContent);
        }
        /// <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 <ScribanGroupConditionData> GetExportObject(GroupConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            ScribanGroupConditionData conditionData = new ScribanGroupConditionData();

            string operatorContent = await ConditionRenderingUtil.GetGroupOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection);

            string renderedConditionElements = await _conditionRenderer.RenderConditionElements(project, parsedData.ConditionElements, operatorContent, errorCollection, flexFieldObject, exportSettings);

            conditionData.Content = renderedConditionElements;

            return(conditionData);
        }
        /// <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 <ScribanRandomValueConditionData> GetExportObject(RandomValueConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            ScribanRandomValueConditionData conditionData = new ScribanRandomValueConditionData();

            conditionData.Operator = await ConditionRenderingUtil.GetCompareOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection);

            conditionData.OriginalOperator = parsedData.Operator;
            conditionData.MinValue         = parsedData.MinValue;
            conditionData.MaxValue         = parsedData.MaxValue;
            conditionData.CompareValue     = parsedData.CompareValue;

            return(conditionData);
        }
Beispiel #7
0
        /// <summary>
        /// Returns the scriban flex field object for the export
        /// </summary>
        /// <param name="parsedData">Parsed condition</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>Scriban export object</returns>
        protected override async Task <ScribanFlexFieldObject> GetScribanFlexFieldObject(ValueFieldConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            KortistoNpc npc = await ConditionRenderingUtil.GetExportNpc(_cachedDbAccess, project, flexFieldObject, errorCollection, _isPlayer);

            if (npc == null)
            {
                return(null);
            }

            ScribanExportNpc convertedNpc = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, npc, exportSettings, errorCollection);

            convertedNpc.IsPlayer = npc.IsPlayerNpc;
            return(convertedNpc);
        }
Beispiel #8
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);
        }
        /// <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, InventoryConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            StyrItem item = await _cachedDbAccess.GetItemById(parsedData.ItemId);

            if (item == null)
            {
                errorCollection.AddDialogItemNotFoundError();
                return(string.Empty);
            }

            ExportObjectData itemExportData = new ExportObjectData();

            itemExportData.ExportData.Add(ExportConstants.ExportDataObject, item);
            itemExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeItem);

            string conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Operator).Replace(template.Code, await ConditionRenderingUtil.GetItemCompareOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection));

            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Quantity).Replace(conditionCode, parsedData.Quantity.ToString());
            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_Operator_IsAtLeast_Start, Placeholder_Operator_IsAtLeast_End, parsedData.Operator == InventoryConditionData.CompareOperator_AtLeast);
            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_Operator_IsAtMaximum_Start, Placeholder_Operator_IsAtMaximum_End, parsedData.Operator == InventoryConditionData.CompareOperator_AtMaximum);

            _itemPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            conditionCode = await _itemPlaceholderResolver.FillPlaceholders(conditionCode, itemExportData);

            return(conditionCode);
        }
        /// <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 #11
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, RandomValueConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            string conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Operator).Replace(template.Code, await ConditionRenderingUtil.GetCompareOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection));

            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_MinValue).Replace(conditionCode, parsedData.MinValue.ToString());
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_MaxValue).Replace(conditionCode, parsedData.MaxValue.ToString());
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_CompareValue).Replace(conditionCode, parsedData.CompareValue.ToString());

            return(conditionCode);
        }
        /// <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, ValueFieldConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            IFlexFieldExportable valueObject = await GetValueObject(parsedData, flexFieldObject, errorCollection);

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

            FlexField exportField = DialogFlexFieldUtil.GetFlexField(valueObject, parsedData.FieldId);

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

            string conditionCode = template.Code;

            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_IsOperatorPrimitiveStart, Placeholder_IsOperatorPrimitiveEnd, ConditionRenderingUtil.IsConditionOperatorPrimitiveOperator(parsedData.Operator));
            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_IsOperatorNonPrimitiveStart, Placeholder_IsOperatorNonPrimitiveEnd, !ConditionRenderingUtil.IsConditionOperatorPrimitiveOperator(parsedData.Operator));
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ValueName).Replace(conditionCode, m => {
                return(DialogFlexFieldUtil.GetFieldName(exportField, parsedData.FieldName, errorCollection));
            });
            string operatorCode = await ConditionRenderingUtil.GetCompareOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection);

            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Operator).Replace(conditionCode, operatorCode);
            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_ValueIsString_Start, Placeholder_ValueIsString_End, exportField.FieldType != ExportConstants.FlexFieldType_Number);
            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_ValueIsNumber_Start, Placeholder_ValueIsNumber_End, exportField.FieldType == ExportConstants.FlexFieldType_Number);
            conditionCode = ExportUtil.RenderPlaceholderIfFuncTrue(conditionCode, 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);
            });
            conditionCode = ExportUtil.RenderPlaceholderIfFuncTrue(conditionCode, 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);
            });
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_CompareValue).Replace(conditionCode, m => {
                if (exportField.FieldType != ExportConstants.FlexFieldType_Number)
                {
                    return(ExportUtil.EscapeCharacters(parsedData.CompareValue, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));
                }

                return(parsedData.CompareValue);
            });

            ExportObjectData flexFieldExportData = new ExportObjectData();

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

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

            return(conditionCode);
        }