/// <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); }
/// <summary> /// Builds a scriban flex field object from a flex field exportable /// </summary> /// <param name="exportable">Exportable</param> /// <param name="exportSettings">Export settings</param> /// <param name="errorCollection">Error collection</param> /// <returns>Scriban flex field object</returns> public static ScribanFlexFieldObject ConvertScribanFlexFieldObject(IFlexFieldExportable exportable, ExportSettings exportSettings, ExportPlaceholderErrorCollection errorCollection) { ScribanFlexFieldObject flexFieldObject = null; if (exportable is StyrItem) { flexFieldObject = new ScribanExportItem(); } else if (exportable is EvneSkill) { flexFieldObject = new ScribanExportSkill(); } else if (exportable is KortistoNpc) { flexFieldObject = new ScribanExportNpc(); } else if (exportable is AikaQuest) { flexFieldObject = new ScribanExportQuest(); } flexFieldObject.Id = exportable.Id; flexFieldObject.Name = exportable.Name; flexFieldObject.Fields = new ScribanFlexFieldDictionary(flexFieldObject, errorCollection, exportable.Fields.Where(f => IsFlexFieldValidForExport(f, true)).SelectMany(f => ConvertFieldToExportField(flexFieldObject, f, exportSettings)).DistinctBy(f => f.Name).ToDictionary(f => f.Name)); flexFieldObject.UsedFieldIds = new HashSet <string>(); return(flexFieldObject); }
/// <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> /// 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); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="curStep">Current Step</param> /// <param name="nextStep">Next step</param> /// <param name="flexFieldObject">Flexfield object to which the dialog belongs</param> /// <returns>Updated code</returns> public T BuildDialogRenderObject<T>(ExportDialogData curStep, ExportDialogData nextStep, FlexFieldObject flexFieldObject) where T : ScribanDialogStepBaseDataWithNextNode, new() { ScribanExportNpc exportNpc = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject<ScribanExportNpc>(null, null, flexFieldObject, _exportSettings, _errorCollection); T renderObject = new T(); SetRenderObjectBaseData(renderObject, curStep, exportNpc); renderObject.ChildNode = null; if (nextStep != null) { renderObject.ChildNode = new ScribanDialogStepBaseData(); SetRenderObjectBaseData(renderObject.ChildNode, nextStep, exportNpc); } return renderObject; }