diff --git a/Config/MiscConfig.cs b/Config/MiscConfig.cs index ba1ee4a2..cfe9227a 100644 --- a/Config/MiscConfig.cs +++ b/Config/MiscConfig.cs @@ -69,5 +69,10 @@ public class MiscConfig /// True if all fields can have script settings /// public bool? AllowScriptSettingsForAllFieldTypes { get; set; } + + /// + /// True if item inventors must be disabled + /// + public bool? DisableItemInventory { get; set; } } } \ No newline at end of file diff --git a/Controllers/Api/StyrApiController.cs b/Controllers/Api/StyrApiController.cs index 22bcc328..a1c6c3ae 100644 --- a/Controllers/Api/StyrApiController.cs +++ b/Controllers/Api/StyrApiController.cs @@ -27,6 +27,8 @@ using GoNorth.Services.Export.ExportSnippets; using GoNorth.Data.Evne; using GoNorth.Data.StateMachines; +using Microsoft.Extensions.Options; +using GoNorth.Config; namespace GoNorth.Controllers.Api { @@ -162,6 +164,11 @@ public class StyrApiController : FlexFieldBaseApiController /// private readonly IKortistoNpcTemplateDbAccess _npcTemplateDbAccess; + /// + /// True if item inventory is disabled + /// + private readonly bool _disableItemInventory; + /// /// Constructor /// @@ -195,11 +202,12 @@ public class StyrApiController : FlexFieldBaseApiController /// Xss Checker /// Logger /// Localizer Factory + /// Config Data public StyrApiController(IStyrFolderDbAccess folderDbAccess, IStyrItemTemplateDbAccess templateDbAccess, IStyrItemDbAccess itemDbAccess, IStyrItemTagDbAccess tagDbAccess, IExportTemplateDbAccess exportTemplateDbAccess, IStyrImportFieldValuesLogDbAccess importFieldValuesLogDbAccess, ILanguageKeyDbAccess languageKeyDbAccess, IExportFunctionIdDbAccess exportFunctionIdDbAccess, IObjectExportSnippetDbAccess objectExportSnippetDbAccess, IObjectExportSnippetSnapshotDbAccess objectExportSnippetSnapshotDbAccess, IExportSnippetRelatedObjectNameResolver exportSnippetRelatedObjectNameResolver, IStateMachineDbAccess stateMachineDbAccess, IStyrItemImageAccess imageAccess, IStyrThumbnailService thumbnailService, IAikaQuestDbAccess aikaQuestDbAccess, IEvneSkillDbAccess skillDbAccess, ITaleDbAccess taleDbAccess, IKirjaPageDbAccess kirjaPageDbAccess, IKartaMapDbAccess kartaMapDbAccess, IKortistoNpcDbAccess kortistoNpcDbAccess, IKortistoNpcTemplateDbAccess npcTemplateDbAccess, IUserProjectAccess userProjectAccess, ICsvGenerator csvGenerator, ICsvParser csvReader, UserManager userManager, IImplementationStatusComparer implementationStatusComparer, ITimelineService timelineService, - IXssChecker xssChecker, ILogger logger, IStringLocalizerFactory localizerFactory) + IXssChecker xssChecker, ILogger logger, IStringLocalizerFactory localizerFactory, IOptions configuration) : base(folderDbAccess, templateDbAccess, itemDbAccess, tagDbAccess, exportTemplateDbAccess, importFieldValuesLogDbAccess, languageKeyDbAccess, exportFunctionIdDbAccess, objectExportSnippetDbAccess, objectExportSnippetSnapshotDbAccess, exportSnippetRelatedObjectNameResolver, stateMachineDbAccess, userProjectAccess, imageAccess, thumbnailService, csvGenerator, csvReader, userManager, implementationStatusComparer, timelineService, xssChecker, logger, localizerFactory) { @@ -210,6 +218,7 @@ public StyrApiController(IStyrFolderDbAccess folderDbAccess, IStyrItemTemplateDb _kartaMapDbAccess = kartaMapDbAccess; _kortistoNpcDbAccess = kortistoNpcDbAccess; _npcTemplateDbAccess = npcTemplateDbAccess; + _disableItemInventory = configuration.Value.Misc.DisableItemInventory.HasValue ? configuration.Value.Misc.DisableItemInventory.Value : false; } /// @@ -283,6 +292,20 @@ public async Task FlexFieldTemplateImageUpload(string id) return await BaseFlexFieldTemplateImageUpload(id); } + /// + /// Strips an object based on the rights of a user + /// + /// Flex field object to strip + /// Stripped object + protected override StyrItem StripObject(StyrItem flexFieldObject) + { + if(_disableItemInventory) + { + flexFieldObject.Inventory = new List(); + } + + return flexFieldObject; + } /// /// Checks if a object is referenced before a delete @@ -351,9 +374,32 @@ protected override async Task CheckObjectReferences(string id) return _localizer["CanNotDeleteItemUsedInSkill", referencedInSkillsString].Value; } + if(!_disableItemInventory) + { + List referencedInItems = await ((IStyrItemDbAccess)_objectDbAccess).GetItemsByItemInInventory(id); + if(referencedInItems.Count > 0) + { + string referencedInItemsString = string.Join(", ", referencedInItems.Select(n => n.Name)); + return _localizer["CanNotDeleteItemUsedInItemInventory", referencedInItemsString].Value; + } + } + return string.Empty; } + /// + /// Returns the items which have an item in their inventory with only the main values + /// + /// Item id + /// Items + [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] + [HttpGet] + public async Task GetItemsByItemInInventory(string itemId) + { + List items = await ((IStyrItemDbAccess)_objectDbAccess).GetItemsByItemInInventory(itemId); + return Ok(items); + } + /// /// Deletes additional depencendies for a flex field object /// @@ -372,6 +418,11 @@ protected override Task DeleteAdditionalFlexFieldObjectDependencies(StyrItem fle /// Updated flex field object protected override Task RunAdditionalUpdates(StyrItem flexFieldObject, StyrItem loadedFlexFieldObject) { + if(!_disableItemInventory) + { + loadedFlexFieldObject.Inventory = flexFieldObject.Inventory; + } + return Task.FromResult(loadedFlexFieldObject); } diff --git a/Controllers/ProjectConfigController.cs b/Controllers/ProjectConfigController.cs index ce1b7364..624d1cc6 100644 --- a/Controllers/ProjectConfigController.cs +++ b/Controllers/ProjectConfigController.cs @@ -1,5 +1,8 @@ +using GoNorth.Config; +using GoNorth.Models.ProjectConfigViewModel; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Options; namespace GoNorth.Controllers { @@ -10,6 +13,20 @@ namespace GoNorth.Controllers [ApiExplorerSettings(IgnoreApi = true)] public class ProjectConfigController : Controller { + /// + /// Misc config + /// + private readonly MiscConfig _config; + + /// + /// Constructor + /// + /// Configuration + public ProjectConfigController(IOptions configuration) + { + _config = configuration.Value.Misc; + } + /// /// Index view /// @@ -17,7 +34,9 @@ public class ProjectConfigController : Controller [HttpGet] public IActionResult Index() { - return View(); + IndexViewModel viewModel = new IndexViewModel(); + viewModel.DisableItemInventory = _config.DisableItemInventory.HasValue ? _config.DisableItemInventory.Value : false; + return View(viewModel); } } } diff --git a/Controllers/StyrController.cs b/Controllers/StyrController.cs index 2ae57a1f..af84a542 100644 --- a/Controllers/StyrController.cs +++ b/Controllers/StyrController.cs @@ -1,5 +1,6 @@ using GoNorth.Config; using GoNorth.Models.FlexFieldDatabaseModels; +using GoNorth.Models.StyrViewModels; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; @@ -44,9 +45,10 @@ public IActionResult Index() [HttpGet] public IActionResult Item() { - DetailFormViewModel viewModel = new DetailFormViewModel(); + ItemViewModel viewModel = new ItemViewModel(); viewModel.DisableAutoSaving = _config.DisableAutoSaving.HasValue ? _config.DisableAutoSaving.Value : false; viewModel.AllowScriptSettingsForAllFieldTypes = _config.AllowScriptSettingsForAllFieldTypes.HasValue ? _config.AllowScriptSettingsForAllFieldTypes.Value : false; + viewModel.DisableItemInventory = _config.DisableItemInventory.HasValue ? _config.DisableItemInventory.Value : false; return View(viewModel); } diff --git a/Data/Styr/IStyrItemDbAccess.cs b/Data/Styr/IStyrItemDbAccess.cs index e1bacd77..1e488f23 100644 --- a/Data/Styr/IStyrItemDbAccess.cs +++ b/Data/Styr/IStyrItemDbAccess.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using System.Threading.Tasks; using GoNorth.Data.FlexFieldDatabase; namespace GoNorth.Data.Styr @@ -7,5 +9,11 @@ namespace GoNorth.Data.Styr /// public interface IStyrItemDbAccess : IFlexFieldObjectDbAccess { + /// + /// Returns the items which have an item in their inventory with only the main values + /// + /// Item id + /// Npcs + Task> GetItemsByItemInInventory(string itemId); } } \ No newline at end of file diff --git a/Data/Styr/StyrInventoryItem.cs b/Data/Styr/StyrInventoryItem.cs new file mode 100644 index 00000000..92a60d66 --- /dev/null +++ b/Data/Styr/StyrInventoryItem.cs @@ -0,0 +1,55 @@ +using System; +using System.Text.Json.Serialization; +using GoNorth.Services.ImplementationStatusCompare; + +namespace GoNorth.Data.Styr +{ + /// + /// Inventory Item + /// + public class StyrInventoryItem : IImplementationListComparable, ICloneable + { + /// + /// Item Id + /// + public string ItemId { get; set; } + + /// + /// Quantity + /// + [ValueCompareAttribute] + public int Quantity { get; set; } + + /// + /// Role of the item + /// + [ValueCompareAttribute] + public string Role { get; set; } + + + /// + /// Id which is used in a list compare to detect deleted or new objects + /// + [JsonIgnore] + public string ListComparableId { get { return ItemId; } } + + /// + /// Value which is used in a list compare for display + /// + [JsonIgnore] + public CompareDifferenceValue ListComparableValue { get { return new CompareDifferenceValue(ItemId, CompareDifferenceValue.ValueResolveType.ResolveItemName); } } + + /// + /// Clones the object + /// + /// Cloned object + public object Clone() + { + return new StyrInventoryItem { + ItemId = this.ItemId, + Quantity = this.Quantity, + Role = this.Role + }; + } + } +} \ No newline at end of file diff --git a/Data/Styr/StyrItem.cs b/Data/Styr/StyrItem.cs index b9ec02f1..21a2f037 100644 --- a/Data/Styr/StyrItem.cs +++ b/Data/Styr/StyrItem.cs @@ -1,6 +1,9 @@ using System; +using System.Collections.Generic; +using System.Linq; using GoNorth.Data.FlexFieldDatabase; using GoNorth.Services.Export.Placeholder; +using GoNorth.Services.ImplementationStatusCompare; namespace GoNorth.Data.Styr { @@ -9,13 +12,22 @@ namespace GoNorth.Data.Styr /// public class StyrItem : FlexFieldObject, IExportSnippetExportable, ICloneable { + /// + /// Inventory Items + /// + [ListCompareAttribute(LabelKey = "InventoryChanged")] + public List Inventory { get; set; } + /// /// Clones the item /// /// Cloned item public object Clone() { - return CloneObject(); + StyrItem clonedItem = CloneObject(); + clonedItem.Inventory = Inventory != null ? Inventory.Select(i => i.Clone()).Cast().ToList() : null; + + return clonedItem; } } } \ No newline at end of file diff --git a/Data/Styr/StyrItemMongoDbAccess.cs b/Data/Styr/StyrItemMongoDbAccess.cs index d2f3ce56..ad1039a5 100644 --- a/Data/Styr/StyrItemMongoDbAccess.cs +++ b/Data/Styr/StyrItemMongoDbAccess.cs @@ -1,6 +1,11 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using GoNorth.Config; using GoNorth.Data.FlexFieldDatabase; using Microsoft.Extensions.Options; +using MongoDB.Driver; +using MongoDB.Driver.Linq; namespace GoNorth.Data.Styr { @@ -26,5 +31,18 @@ public class StyrItemMongoDbAccess : FlexFieldObjectBaseMongoDbAccess, public StyrItemMongoDbAccess(IOptions configuration) : base(StyrItemCollectionName, StyrItemRecyclingBinCollectionName, configuration) { } + + /// + /// Returns the items which have an item in their inventory with only the main values + /// + /// Item id + /// Npcs + public async Task> GetItemsByItemInInventory(string itemId) + { + return await _ObjectCollection.AsQueryable().Where(n => n.Inventory != null && n.Inventory.Any(i => i.ItemId == itemId)).OrderBy(n => n.Name).Select(n => new StyrItem { + Id = n.Id, + Name = n.Name + }).ToListAsync(); + } } } \ No newline at end of file diff --git a/DefaultExportTemplates/Object/ObjectItem.lua b/DefaultExportTemplates/Object/ObjectItem.lua index ec232eba..6162536f 100644 --- a/DefaultExportTemplates/Object/ObjectItem.lua +++ b/DefaultExportTemplates/Object/ObjectItem.lua @@ -10,4 +10,17 @@ function OnInit(this) -- Values this:add_localized_string_value("Name", "{{ langkey item.name }}") {{ item.unused_fields | attribute_list }} + {{- if !inventory.empty? ~}} + + -- Inventory + {{~ for cur_inventory_item in inventory ~}} + this:add_item("{{ cur_inventory_item.fields.ScriptName.value }}") + {{~ if cur_inventory_item.quantity > 1 ~}} + this:get_item({{ for.index }}):set_value("Quantity", {{ cur_inventory_item.quantity }}) + {{~ end ~}} + {{~ if cur_inventory_item.role ~}} + this:get_item({{ for.index }}):set_role("{{ cur_inventory_item.role }}") + {{~ end ~}} + {{~ end ~}} + {{~ end ~}} end \ No newline at end of file diff --git a/DefaultExportTemplates/Tale/TaleConditionNpcInventory.lua b/DefaultExportTemplates/Tale/TaleConditionNpcInventory.lua index 2d8c4de6..8fa90b0f 100644 --- a/DefaultExportTemplates/Tale/TaleConditionNpcInventory.lua +++ b/DefaultExportTemplates/Tale/TaleConditionNpcInventory.lua @@ -1 +1,5 @@ -BaseNpc_GetItemQuantityInInventory(this, "{{ condition.selected_item.fields.ScriptName.value }}") {{ condition.operator }} {{ condition.quantity }} \ No newline at end of file +{{- if condition.is_equipped_check -}} +BaseNpc_GetEquippedItemQuantityInInventory(this, "{{ condition.selected_item.fields.ScriptName.value }}") {{ condition.operator }} {{ condition.quantity }} +{{- else -}} +BaseNpc_GetItemQuantityInInventory(this, "{{ condition.selected_item.fields.ScriptName.value }}") {{ condition.operator }} {{ condition.quantity }} +{{- end -}} \ No newline at end of file diff --git a/DefaultExportTemplates/Tale/TaleConditionPlayerInventory.lua b/DefaultExportTemplates/Tale/TaleConditionPlayerInventory.lua index da1c8d66..550b1bc5 100644 --- a/DefaultExportTemplates/Tale/TaleConditionPlayerInventory.lua +++ b/DefaultExportTemplates/Tale/TaleConditionPlayerInventory.lua @@ -1 +1,5 @@ -BaseNpc_GetItemQuantityInInventory(playerNpc, "{{ condition.selected_item.fields.ScriptName.value }}") {{ condition.operator }} {{ condition.quantity }} \ No newline at end of file +{{- if condition.is_equipped_check -}} +BaseNpc_GetEquippedItemQuantityInInventory(playerNpc, "{{ condition.selected_item.fields.ScriptName.value }}") {{ condition.operator }} {{ condition.quantity }} +{{- else -}} +BaseNpc_GetItemQuantityInInventory(playerNpc, "{{ condition.selected_item.fields.ScriptName.value }}") {{ condition.operator }} {{ condition.quantity }} +{{- end -}} \ No newline at end of file diff --git a/DefaultExportTemplates/Tale/TaleDialogFunction.lua b/DefaultExportTemplates/Tale/TaleDialogFunction.lua index 400f064d..fe69bb81 100644 --- a/DefaultExportTemplates/Tale/TaleDialogFunction.lua +++ b/DefaultExportTemplates/Tale/TaleDialogFunction.lua @@ -11,6 +11,6 @@ function {{ dialog_function.function_name }}(this) {{~ end ~}}{{~ if (dialog_function.code | string.contains "dialogManager") || (dialog_function.code | string.contains "playerNpc") ~}} {{~ end ~}} - {{ dialog_function.code | indent_multiline}} + {{ dialog_function.code | indent_multiline }} end diff --git a/GoNorth.csproj b/GoNorth.csproj index a91155f4..c3e25668 100644 --- a/GoNorth.csproj +++ b/GoNorth.csproj @@ -11,13 +11,13 @@ - - - - - + + + + + - + diff --git a/GoNorthVersion.cs b/GoNorthVersion.cs index d8115062..3a7f17f7 100644 --- a/GoNorthVersion.cs +++ b/GoNorthVersion.cs @@ -10,6 +10,6 @@ public class GoNorthVersion /// /// Current GoNorth Version /// - public static readonly Version CurrentVersion = new Version(1, 9, 1, 0); + public static readonly Version CurrentVersion = new Version(1, 9, 1, 5); }; } \ No newline at end of file diff --git a/LICENSE b/LICENSE index c9d42ab9..5e1e1b05 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Steffen Noertershaeuser +Copyright (c) 2018 Steffen Werhahn, former Noertershaeuser Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Models/ProjectConfigViewModel/IndexViewModel.cs b/Models/ProjectConfigViewModel/IndexViewModel.cs new file mode 100644 index 00000000..5d5645d3 --- /dev/null +++ b/Models/ProjectConfigViewModel/IndexViewModel.cs @@ -0,0 +1,13 @@ +namespace GoNorth.Models.ProjectConfigViewModel +{ + /// + /// Index view model + /// + public class IndexViewModel + { + /// + /// True if items in items are disabled + /// + public bool DisableItemInventory { get; set; } + } +} diff --git a/Models/StyrViewModels/ItemViewModel.cs b/Models/StyrViewModels/ItemViewModel.cs new file mode 100644 index 00000000..b9d4334f --- /dev/null +++ b/Models/StyrViewModels/ItemViewModel.cs @@ -0,0 +1,15 @@ +using GoNorth.Models.FlexFieldDatabaseModels; + +namespace GoNorth.Models.StyrViewModels +{ + /// + /// Item Form Viewmodel + /// + public class ItemViewModel : DetailFormViewModel + { + /// + /// True if items in items are disabled + /// + public bool DisableItemInventory { get; set; } + } +} diff --git a/Program.cs b/Program.cs index 0ba0d238..4669f3ff 100644 --- a/Program.cs +++ b/Program.cs @@ -1,4 +1,4 @@ -// GoNorth - Created by Steffen Noertershaeuser +// GoNorth - Created by Steffen Werhahn, former Noertershaeuser using Microsoft.Extensions.Hosting; using Microsoft.AspNetCore.Hosting; using GoNorth.Logging; diff --git a/README.md b/README.md index dccaa15e..b825fb07 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ The next steps which I will implement in the future are: ## License GoNorth is open source and released under the [MIT LICENSE](LICENSE). -Copyright (c) 2018, 2019, 2020 Steffen Noertershaeuser. +Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 Steffen Werhahn, former Noertershaeuser. ## Acknowledgement GoNorth uses the following libraries: diff --git a/Resources/Controllers/Api/StyrApiController.de.json b/Resources/Controllers/Api/StyrApiController.de.json index fbaab854..8edceff0 100644 --- a/Resources/Controllers/Api/StyrApiController.de.json +++ b/Resources/Controllers/Api/StyrApiController.de.json @@ -10,6 +10,7 @@ "CanNotDeleteObjectUsedInExportSnippet": "Das Item ist in Export Snippets von \"{0}\" referenziert. Um Export Fehler zu verhindern muss es hier erst entfernt werden bevor es gelöscht werden kann.", "CanNotDeleteItemUsedInStateMachines": "Das Item ist in der State Machine von \"{0}\" referenziert. Um Export Fehler zu verhindern muss es hier erst entfernt werden bevor es gelöscht werden kann.", "CanNotDeleteItemUsedInSkill": "Das Item ist in den Fähigkeiten \"{0}\" referenziert. Um Story Fehler zu verhindern muss es hier erst entfernt werden bevor es gelöscht werden kann.", + "CanNotDeleteItemUsedInItemInventory": "Das Item wird in den Inventaren der Items \"{0}\" benutzt. Um Export Fehler zu verhindern muss es hier erst entfernt werden bevor es gelöscht werden kann.", "OnlyOneFileAllowed": "Es darf nur exakt eine Datei hochgeladen werden.", "CouldNotUploadImage": "Bild konnte nicht hochgeladen werden.", diff --git a/Resources/Controllers/Api/StyrApiController.en.json b/Resources/Controllers/Api/StyrApiController.en.json index 3a7b46a3..cfc4b09e 100644 --- a/Resources/Controllers/Api/StyrApiController.en.json +++ b/Resources/Controllers/Api/StyrApiController.en.json @@ -10,6 +10,7 @@ "CanNotDeleteObjectUsedInExportSnippet": "The item is referenced in export snippets of \"{0}\". To prevent errors while exporting it must be deleted there first.", "CanNotDeleteItemUsedInStateMachines": "The item is referenced in the state machine of \"{0}\" referenziert. To prevent errors while exporting it must be deleted there first.", "CanNotDeleteItemUsedInSkill": "The item is referenced in the skills \"{0}\". To prevent errors in the story it must be deleted there first.", + "CanNotDeleteItemUsedInItemInventory": "The item is used in the item inventories \"{0}\". To prevent errors whilte exporting it must be deleted there first.", "OnlyOneFileAllowed": "You must upload exactly one image file.", "CouldNotUploadImage": "Image could not be uploaded.", diff --git a/Resources/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.de.json b/Resources/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.de.json index 162787f6..5584dd7c 100644 --- a/Resources/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.de.json +++ b/Resources/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.de.json @@ -2,6 +2,7 @@ "PlaceholderDesc_Npc": "Npc zu dem das Item gehört", "PlaceholderDesc_SelectedItem": "Ausgewähltes Item das geprüft wird", "PlaceholderDesc_Operator": "Vergleichsoperator. Wird über die entsprechenden Templates geladen.", - "PlaceholderDesc_OriginalOperator": "Vergleichsoperator der nicht über die Templates aufgelöst wird. Kann AtLeast oder AtMaximum sein.", - "PlaceholderDesc_Quantity": "Anzahl die als Vergleichswert genutzt wird." + "PlaceholderDesc_OriginalOperator": "Vergleichsoperator der nicht über die Templates aufgelöst wird. Kann AtLeast, AtMaximum, HasEquipped oder HasNotEquipped sein.", + "PlaceholderDesc_Quantity": "Anzahl die als Vergleichswert genutzt wird.", + "PlaceholderDesc_IsEquippedCheck": "True wenn der Vergleichsoperator sich auf ein ausgerüstetes Item bezieht, sonst false." } \ No newline at end of file diff --git a/Resources/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.en.json b/Resources/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.en.json index 4b4d27fe..da1b817a 100644 --- a/Resources/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.en.json +++ b/Resources/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.en.json @@ -2,6 +2,7 @@ "PlaceholderDesc_Npc": "Npc to which the item belongs", "PlaceholderDesc_SelectedItem": "Chosen item that is being checked", "PlaceholderDesc_Operator": "Compare operator. Will be loaded using the corresponding templates.", - "PlaceholderDesc_OriginalOperator": "Compare operator which will not be loaded using the templates. Can be AtLeast or AtMaximum.", - "PlaceholderDesc_Quantity": "Quantity used for comparison." + "PlaceholderDesc_OriginalOperator": "Compare operator which will not be loaded using the templates. Can be AtLeast, AtMaximum, HasEquipped or HasNotEquipped.", + "PlaceholderDesc_Quantity": "Quantity used for comparison.", + "PlaceholderDesc_IsEquippedCheck": "True if the compare operator is related to an equipped item, else false." } \ No newline at end of file diff --git a/Resources/Services/Export/Placeholder/ScribanRenderingEngine/RenderingObjects/ScribanExportItemInventoryItem.de.json b/Resources/Services/Export/Placeholder/ScribanRenderingEngine/RenderingObjects/ScribanExportItemInventoryItem.de.json new file mode 100644 index 00000000..acf2f754 --- /dev/null +++ b/Resources/Services/Export/Placeholder/ScribanRenderingEngine/RenderingObjects/ScribanExportItemInventoryItem.de.json @@ -0,0 +1,4 @@ +{ + "PlaceholderDesc_Quantity": "Anzahl an Items im Inventar", + "PlaceholderDesc_Role": "Rolle des Items im Inventar" +} \ No newline at end of file diff --git a/Resources/Services/Export/Placeholder/ScribanRenderingEngine/RenderingObjects/ScribanExportItemInventoryItem.en.json b/Resources/Services/Export/Placeholder/ScribanRenderingEngine/RenderingObjects/ScribanExportItemInventoryItem.en.json new file mode 100644 index 00000000..fac2729d --- /dev/null +++ b/Resources/Services/Export/Placeholder/ScribanRenderingEngine/RenderingObjects/ScribanExportItemInventoryItem.en.json @@ -0,0 +1,4 @@ +{ + "PlaceholderDesc_Quantity": "Quantity of the item inside of the inventory", + "PlaceholderDesc_Role": "Role of the item inside of the inventory" +} \ No newline at end of file diff --git a/Resources/Services/ImplementationStatusCompare/GenericImplementationStatusComparer.de.json b/Resources/Services/ImplementationStatusCompare/GenericImplementationStatusComparer.de.json index 3640a023..ced21fbf 100644 --- a/Resources/Services/ImplementationStatusCompare/GenericImplementationStatusComparer.de.json +++ b/Resources/Services/ImplementationStatusCompare/GenericImplementationStatusComparer.de.json @@ -21,6 +21,7 @@ "PropertyNameDontExportToScript": "Nicht in Skript exportieren", "PropertyNameQuantity": "Anzahl", "PropertyNameIsEquipped": "Ausgerüstet", + "PropertyNameRole": "Rolle", "PropertyNameText": "Text", "PropertyNameIsRepeatable": "Wiederholbar", "PropertyNameCondition": "Bedingung", diff --git a/Resources/Services/ImplementationStatusCompare/GenericImplementationStatusComparer.en.json b/Resources/Services/ImplementationStatusCompare/GenericImplementationStatusComparer.en.json index a2eea25d..3071afa8 100644 --- a/Resources/Services/ImplementationStatusCompare/GenericImplementationStatusComparer.en.json +++ b/Resources/Services/ImplementationStatusCompare/GenericImplementationStatusComparer.en.json @@ -21,6 +21,7 @@ "PropertyNameDontExportToScript": "Do not export to script", "PropertyNameQuantity": "Quantity", "PropertyNameIsEquipped": "Is equipped", + "PropertyNameRole": "Role", "PropertyNameText": "Text", "PropertyNameIsRepeatable": "Repeatable", "PropertyNameCondition": "Condition", diff --git a/Resources/Views/FlexFieldDatabase/FlexFieldInventory.de.json b/Resources/Views/FlexFieldDatabase/FlexFieldInventory.de.json new file mode 100644 index 00000000..9680f6f9 --- /dev/null +++ b/Resources/Views/FlexFieldDatabase/FlexFieldInventory.de.json @@ -0,0 +1,14 @@ +{ + "Inventory": "Inventar", + "AddItemToInventory": "Item hinzufügen", + "Name": "Name", + "Quantity": "Anzahl", + "Equipped": "Ausgerüstet", + "Role": "Rolle", + "RemoveItemFromInventory": "Item aus dem Inventar entfernen", + "AreYouSure": "Bist du sicher?", + "AreYouSureYouWantToRemoveTheItem": "Bist du sicher das das Item entfernt werden soll?", + "Yes": "Ja", + "No": "Nein", + "ErrorOccured": "Es ist ein Fehler aufgetreten." +} \ No newline at end of file diff --git a/Resources/Views/FlexFieldDatabase/FlexFieldInventory.en.json b/Resources/Views/FlexFieldDatabase/FlexFieldInventory.en.json new file mode 100644 index 00000000..fbb43fef --- /dev/null +++ b/Resources/Views/FlexFieldDatabase/FlexFieldInventory.en.json @@ -0,0 +1,14 @@ +{ + "Inventory": "Inventory", + "AddItemToInventory": "Add item", + "Name": "Name", + "Quantity": "Quantity", + "Equipped": "Equipped", + "Role": "Role", + "RemoveItemFromInventory": "Remove item from inventory", + "AreYouSure": "Are you sure?", + "AreYouSureYouWantToRemoveTheItem": "Are you sure you want to remove the item?", + "Yes": "Yes", + "No": "No", + "ErrorOccured": "An error occured." +} \ No newline at end of file diff --git a/Resources/Views/Kortisto/Npc.de.json b/Resources/Views/Kortisto/Npc.de.json index 1dcba8a3..c7136cca 100644 --- a/Resources/Views/Kortisto/Npc.de.json +++ b/Resources/Views/Kortisto/Npc.de.json @@ -43,12 +43,7 @@ "DropImageHere": "Bild für Npc hier ablegen oder klicken um ein Bild auszuwählen", "OpenImageInFullSize": "Bild in voller Größe öffnen", - "Inventory": "Inventar", "AddItemToInventory": "Item hinzufügen", - "Quantity": "Anzahl", - "Equipped": "Ausgerüstet", - "RemoveItemFromInventory": "Item aus dem Inventar entfernen", - "AreYouSureYouWantToRemoveTheItem": "Bist du sicher das das Item entfernt werden soll?", "Skills": "Fähigkeiten", "AddSkill": "Fähigkeit hinzufügen", diff --git a/Resources/Views/Kortisto/Npc.en.json b/Resources/Views/Kortisto/Npc.en.json index 8bfa96a8..56aa39dc 100644 --- a/Resources/Views/Kortisto/Npc.en.json +++ b/Resources/Views/Kortisto/Npc.en.json @@ -43,12 +43,7 @@ "DropImageHere": "Drop image for npc here or click to choose an image", "OpenImageInFullSize": "Open image in full size", - "Inventory": "Inventory", "AddItemToInventory": "Add item", - "Quantity": "Quantity", - "Equipped": "Equipped", - "RemoveItemFromInventory": "Remove item from inventory", - "AreYouSureYouWantToRemoveTheItem": "Are you sure you want to remove the item?", "Skills": "Skills", "AddSkill": "Add skill", diff --git a/Resources/Views/ProjectConfig/Index.de.json b/Resources/Views/ProjectConfig/Index.de.json index 9485ac00..8425df61 100644 --- a/Resources/Views/ProjectConfig/Index.de.json +++ b/Resources/Views/ProjectConfig/Index.de.json @@ -7,6 +7,9 @@ "StateConfigSectionHeader": "Zustands Konfiguration", "StateConfigSectionDescription": "Jede Zeile wird als Zustand in der Zustand festlegen Aktion angezeigt:", + "ItemRolesSectionHeader": "Item Rollen", + "ItemRolesSectionDescription": "Jede Zeile wird als Vorschlag für Item Rollen angezeigt:", + "DayHourMinutesConfig": "Uhrzeit Konfiguration", "HoursPerDay": "Stunden pro Tag:", "MinutesPerHour": "Minuten pro Stunde:", diff --git a/Resources/Views/ProjectConfig/Index.en.json b/Resources/Views/ProjectConfig/Index.en.json index ce90b796..7397e977 100644 --- a/Resources/Views/ProjectConfig/Index.en.json +++ b/Resources/Views/ProjectConfig/Index.en.json @@ -7,6 +7,9 @@ "StateConfigSectionHeader": "Set state config", "StateConfigSectionDescription": "Add one line for each state that will be suggested in the set state action:", + "ItemRolesSectionHeader": "Item roles", + "ItemRolesSectionDescription": "Add one line for each item role that will be proposed to the user:", + "DayHourMinutesConfig": "Time config", "HoursPerDay": "Hours per day:", "MinutesPerHour": "Minutes per hour:", diff --git a/Resources/Views/Styr/Item.de.json b/Resources/Views/Styr/Item.de.json index d10b08b8..51c58c4d 100644 --- a/Resources/Views/Styr/Item.de.json +++ b/Resources/Views/Styr/Item.de.json @@ -45,6 +45,8 @@ "ReferencedInNpcInventories": "In Npc Inventaren:", + "ReferencedInItemInventories": "In Item Inventaren:", + "ReferencedInEvneSkills": "Referenziert in Fähigkeiten:", "ClickHereForDetailedReferences": "Das Item ist in mehreren Objekten referenziert. Klick hier für Details.", diff --git a/Resources/Views/Styr/Item.en.json b/Resources/Views/Styr/Item.en.json index 61f549bc..37af9258 100644 --- a/Resources/Views/Styr/Item.en.json +++ b/Resources/Views/Styr/Item.en.json @@ -45,6 +45,8 @@ "ReferencedInNpcInventories": "In npc inventory:", + "ReferencedInItemInventories": "In item inventory:", + "ReferencedInEvneSkills": "Referenced in skills:", "ClickHereForDetailedReferences": "The item is referenced in multiple objects. Click here for details.", diff --git a/Services/Export/Dialog/ConditionRendering/ConfigObject/InventoryConditionData.cs b/Services/Export/Dialog/ConditionRendering/ConfigObject/InventoryConditionData.cs index 113e2a50..2788fc12 100644 --- a/Services/Export/Dialog/ConditionRendering/ConfigObject/InventoryConditionData.cs +++ b/Services/Export/Dialog/ConditionRendering/ConfigObject/InventoryConditionData.cs @@ -15,6 +15,16 @@ public class InventoryConditionData /// public const int CompareOperator_AtMaximum = 1; + /// + /// Compare Operator for equipped + /// + public const int CompareOperator_HasEquipped = 2; + + /// + /// Compare Operator for has not equipped + /// + public const int CompareOperator_HasNotEquipped = 3; + /// /// Item Id diff --git a/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.cs b/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.cs index dfed5fef..95969750 100644 --- a/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.cs +++ b/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/RenderingObjects/ScribanInventoryConditionData.cs @@ -37,5 +37,11 @@ public class ScribanInventoryConditionData /// [ScribanExportValueLabel] public int Quantity { get; set; } + + /// + /// True if the condition is checking for an equipped item + /// + [ScribanExportValueLabel] + public bool IsEquippedCheck { get; set; } } } \ No newline at end of file diff --git a/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/ScribanInventoryConditionRenderer.cs b/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/ScribanInventoryConditionRenderer.cs index a863a009..e39747c0 100644 --- a/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/ScribanInventoryConditionRenderer.cs +++ b/Services/Export/Dialog/ConditionRendering/ScribanRenderingEngine/ScribanInventoryConditionRenderer.cs @@ -85,13 +85,34 @@ protected override async Task GetExportObject(Inv conditionData.SelectedItem = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject(null, null, item, exportSettings, errorCollection); - conditionData.OriginalOperator = parsedData.Operator == InventoryConditionData.CompareOperator_AtLeast ? "AtLeast" : "AtMaximum"; + conditionData.OriginalOperator = GetOriginalOperator(parsedData.Operator); conditionData.Operator = await ConditionRenderingUtil.GetItemCompareOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection); conditionData.Quantity = parsedData.Quantity; + conditionData.IsEquippedCheck = (parsedData.Operator == InventoryConditionData.CompareOperator_HasEquipped || parsedData.Operator == InventoryConditionData.CompareOperator_HasNotEquipped); return conditionData; } + /// + /// Returns the original operator as string + /// + /// Original Operator + /// Original operator as string + private string GetOriginalOperator(int originalOperator) + { + switch(originalOperator) + { + case InventoryConditionData.CompareOperator_AtLeast: + return "AtLeast"; + case InventoryConditionData.CompareOperator_HasEquipped: + return "HasEquipped"; + case InventoryConditionData.CompareOperator_HasNotEquipped: + return "HasNotEquipped"; + default: + return "AtMaximum"; + } + } + /// /// Returns the object key for scriban /// diff --git a/Services/Export/Dialog/ConditionRendering/Util/ConditionRenderingUtil.cs b/Services/Export/Dialog/ConditionRendering/Util/ConditionRenderingUtil.cs index 8d3d58f4..8df1ede5 100644 --- a/Services/Export/Dialog/ConditionRendering/Util/ConditionRenderingUtil.cs +++ b/Services/Export/Dialog/ConditionRendering/Util/ConditionRenderingUtil.cs @@ -85,9 +85,12 @@ public static async Task GetItemCompareOperatorFromTemplate(ICachedExpor switch(compareOperator) { case InventoryConditionData.CompareOperator_AtLeast: + case InventoryConditionData.CompareOperator_HasEquipped: return (await defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.GeneralCompareOperatorBiggerOrEqual)).Code; case InventoryConditionData.CompareOperator_AtMaximum: return (await defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.GeneralCompareOperatorLessOrEqual)).Code; + case InventoryConditionData.CompareOperator_HasNotEquipped: + return (await defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.GeneralCompareOperatorLess)).Code; } errorCollection.AddDialogUnknownConditionOperator(compareOperator.ToString()); diff --git a/Services/Export/ExportConstants.cs b/Services/Export/ExportConstants.cs index 9d5a861c..f32626fc 100644 --- a/Services/Export/ExportConstants.cs +++ b/Services/Export/ExportConstants.cs @@ -164,9 +164,9 @@ public class ExportConstants public const string ScribanNpcObjectKey = "npc"; /// - /// Scriban Npc inventory object key + /// Scriban inventory object key /// - public const string ScribanNpcInventoryObjectKey = "inventory"; + public const string ScribanInventoryObjectKey = "inventory"; /// /// Scriban Npc skill object key diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventFunctionListRenderer.cs b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventFunctionListRenderer.cs index 3a35fb61..706b0329 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventFunctionListRenderer.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventFunctionListRenderer.cs @@ -84,7 +84,7 @@ private async ValueTask RenderDailyRoutineFunctionList(TemplateContext c ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectDailyRoutineFunctionList, functionListTemplate.Code, objectData, functionListTemplate.RenderingEngine); _errorCollection.Merge(fillResult.Errors); - return ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code); + return fillResult.Code; } /// diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventFunctionRenderer.cs b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventFunctionRenderer.cs index 6a40680c..7dde4ae9 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventFunctionRenderer.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventFunctionRenderer.cs @@ -83,7 +83,7 @@ private async ValueTask RenderDailyRoutineEventFunction(TemplateContext ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectDailyRoutineFunction, eventFunctionTemplate.Code, objectData, eventFunctionTemplate.RenderingEngine); _errorCollection.Merge(fillResult.Errors); - return ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code); + return fillResult.Code; } /// diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventListRenderer.cs b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventListRenderer.cs index 2900bff1..e701b463 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventListRenderer.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DailyRoutineEventListRenderer.cs @@ -95,7 +95,7 @@ private async ValueTask RenderDailyRoutineEventList(TemplateContext cont ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectDailyRoutineEventList, eventListTemplate.Code, objectData, eventListTemplate.RenderingEngine); _errorCollection.Merge(fillResult.Errors); - return ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code); + return fillResult.Code; } /// diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DialogFunctionRenderer.cs b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DialogFunctionRenderer.cs index 36d25791..46190d3c 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DialogFunctionRenderer.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/DialogFunctionRenderer.cs @@ -91,7 +91,7 @@ private async ValueTask RenderDialogFunction(TemplateContext context, Sc ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.TaleDialogFunction, dialogFunctionTemplate.Code, objectData, dialogFunctionTemplate.RenderingEngine); _errorCollection.Merge(fillResult.Errors); - return ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code); + return fillResult.Code; } /// diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/ExportSnippetFunctionPipeRenderer.cs b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/ExportSnippetFunctionPipeRenderer.cs index b0505211..a255baf0 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/ExportSnippetFunctionPipeRenderer.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/ExportSnippetFunctionPipeRenderer.cs @@ -83,7 +83,7 @@ private async ValueTask RenderExportSnippetFunction(TemplateContext cont ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectExportSnippetFunction, snippetFunctionTemplate.Code, objectData, snippetFunctionTemplate.RenderingEngine); _errorCollection.Merge(fillResult.Errors); - return ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code); + return fillResult.Code; } /// diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/FlexFieldAttributeListRenderer.cs b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/FlexFieldAttributeListRenderer.cs index c02a1155..d9604f91 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/FlexFieldAttributeListRenderer.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/FlexFieldAttributeListRenderer.cs @@ -95,7 +95,7 @@ private async ValueTask RenderAttributeList(TemplateContext context, Scr ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectAttributeList, attributeListTemplate.Code, objectData, attributeListTemplate.RenderingEngine); _errorCollection.Merge(fillResult.Errors); - return ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code); + return fillResult.Code; } /// diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/IndentMultiLineRenderer.cs b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/IndentMultiLineRenderer.cs index d556b85b..7beef7ac 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/IndentMultiLineRenderer.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/IndentMultiLineRenderer.cs @@ -9,7 +9,7 @@ namespace GoNorth.Services.Export.Placeholder.ScribanRenderingEngine.RenderingFunctions { /// - /// Function to indent multiple lines of text to match the same indentation + /// Function to indent multiple lines of text to match the same indentation, Legacy Function, not needed anymore /// public class IndentMultiLineRenderer : ScribanBaseStringRenderingFunction { @@ -33,7 +33,8 @@ private ValueTask IndentValue(TemplateContext context, ScriptNode caller } string indentCode = arguments[0].ToString(); - return new ValueTask(ScribanOutputUtil.IndentMultilineCode(context, indentCode)); + indentCode = indentCode.Trim('\n', '\r'); + return new ValueTask(indentCode); } /// diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/InventoryListRenderer.cs b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/InventoryListRenderer.cs index b0845164..33a46ea2 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/InventoryListRenderer.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/InventoryListRenderer.cs @@ -98,7 +98,7 @@ private async ValueTask RenderInventoryList(TemplateContext context, Scr ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectInventory, inventoryTemplate.Code, objectData, inventoryTemplate.RenderingEngine); _errorCollection.Merge(fillResult.Errors); - return ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code); + return fillResult.Code; } /// diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/SkillListRenderer.cs b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/SkillListRenderer.cs index 1d5dbf69..11258896 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/SkillListRenderer.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/SkillListRenderer.cs @@ -98,7 +98,7 @@ private async ValueTask RenderSkillList(TemplateContext context, ScriptN ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectSkillList, skillListTemplate.Code, objectData, skillListTemplate.RenderingEngine); _errorCollection.Merge(fillResult.Errors); - return ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code); + return fillResult.Code; } /// diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/StateMachineFunctionPipeRenderer.cs b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/StateMachineFunctionPipeRenderer.cs index 33b6bf27..d4ea6dba 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/StateMachineFunctionPipeRenderer.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingFunctions/StateMachineFunctionPipeRenderer.cs @@ -83,7 +83,7 @@ private async ValueTask RenderStateMachineFunction(TemplateContext conte ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectStateFunction, eventFunctionTemplate.Code, objectData, eventFunctionTemplate.RenderingEngine); _errorCollection.Merge(fillResult.Errors); - return ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code); + return fillResult.Code; } /// diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/RenderingObjects/ScribanExportItemInventoryItem.cs b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingObjects/ScribanExportItemInventoryItem.cs new file mode 100644 index 00000000..1da0fcc2 --- /dev/null +++ b/Services/Export/Placeholder/ScribanRenderingEngine/RenderingObjects/ScribanExportItemInventoryItem.cs @@ -0,0 +1,22 @@ +using GoNorth.Services.Export.Placeholder.ScribanRenderingEngine.Util; + +namespace GoNorth.Services.Export.Placeholder.ScribanRenderingEngine.RenderingObjects +{ + /// + /// Class to export Items in an inventory to Scriban + /// + public class ScribanExportItemInventoryItem : ScribanExportItem + { + /// + /// Quantity in the inventory + /// + [ScribanExportValueLabel] + public int Quantity { get; set; } + + /// + /// Role of the item + /// + [ScribanExportValueLabel] + public string Role { get; set;} + } +} \ No newline at end of file diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/ScribanExportTemplatePlaceholderRenderingEngine.cs b/Services/Export/Placeholder/ScribanRenderingEngine/ScribanExportTemplatePlaceholderRenderingEngine.cs index ab7d540d..9b512470 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/ScribanExportTemplatePlaceholderRenderingEngine.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/ScribanExportTemplatePlaceholderRenderingEngine.cs @@ -76,6 +76,7 @@ public ScribanExportTemplatePlaceholderRenderingEngine(IExportTemplatePlaceholde new SkillExportValueCollector(exportTemplatePlaceholderResolver, exportCachedDbAccess, defaultTemplateProvider, languageKeyGenerator, localizerFactory), new AttributeListValueCollector(exportCachedDbAccess, languageKeyGenerator, localizerFactory), new InventoryValueCollector(exportCachedDbAccess, languageKeyGenerator, localizerFactory), + new ItemInventoryValueCollector(exportCachedDbAccess, languageKeyGenerator, localizerFactory), new NpcSkillValueCollector(exportCachedDbAccess, languageKeyGenerator, localizerFactory), new DialogValueCollector(exportTemplatePlaceholderResolver, exportCachedDbAccess, defaultTemplateProvider, taleDbAccess, languageKeyGenerator, dialogParser, dialogFunctionGenerator, dialogRenderer, localizerFactory), new DialogFunctionValueCollector(localizerFactory), diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/Util/ScribanOutputUtil.cs b/Services/Export/Placeholder/ScribanRenderingEngine/Util/ScribanOutputUtil.cs deleted file mode 100644 index e65b10e7..00000000 --- a/Services/Export/Placeholder/ScribanRenderingEngine/Util/ScribanOutputUtil.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using Scriban; - -namespace GoNorth.Services.Export.Placeholder.ScribanRenderingEngine.Util -{ - /// - /// Utility class to for Scriban output - /// - public static class ScribanOutputUtil - { - /// - /// Indents a multiline code - /// - /// Template context - /// Code to indent - /// Indented code - public static string IndentMultilineCode(TemplateContext context, string code) - { - string indentTemplate = context.Output.ToString(); - string[] allLines = indentTemplate.Split(Environment.NewLine); - if(allLines.Length > 0) - { - string indentLine = allLines[allLines.Length - 1].Trim('\n', '\r'); - if(string.IsNullOrWhiteSpace(indentLine)) - { - return ExportUtil.IndentListTemplate(code, indentLine).Trim(); - } - } - - return code; - } - } -} \ No newline at end of file diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/ValueCollector/InventoryValueCollector.cs b/Services/Export/Placeholder/ScribanRenderingEngine/ValueCollector/InventoryValueCollector.cs index bc7d707f..dd912a87 100644 --- a/Services/Export/Placeholder/ScribanRenderingEngine/ValueCollector/InventoryValueCollector.cs +++ b/Services/Export/Placeholder/ScribanRenderingEngine/ValueCollector/InventoryValueCollector.cs @@ -83,7 +83,7 @@ public override async Task CollectValues(TemplateType templateType, Template par _languageKeyGenerator.SetErrorCollection(_errorCollection); List items = await LoadInventory(parsedTemplate, inputNpc); - scriptObject.AddOrUpdate(ExportConstants.ScribanNpcInventoryObjectKey, items); + scriptObject.AddOrUpdate(ExportConstants.ScribanInventoryObjectKey, items); scriptObject.AddOrUpdate(ExportConstants.ScribanLanguageKeyName, _languageKeyGenerator); } @@ -142,7 +142,7 @@ public override List GetExportTemplatePlaceholdersFor } IStringLocalizer stringLocalizer = _localizerFactory.Create(typeof(InventoryValueCollector)); - exportPlaceholders.Add(new ExportTemplatePlaceholder(ExportConstants.ScribanNpcInventoryObjectKey, stringLocalizer["PlaceholderDesc_Inventory"])); + exportPlaceholders.Add(new ExportTemplatePlaceholder(ExportConstants.ScribanInventoryObjectKey, stringLocalizer["PlaceholderDesc_Inventory"])); List itemPlaceholders = ScribanPlaceholderGenerator.GetPlaceholdersForObject(_localizerFactory, ItemPlaceholderDefintionPrefix); itemPlaceholders.RemoveAll(p => p.Name == string.Format("{0}.{1}", ItemPlaceholderDefintionPrefix, StandardMemberRenamer.Rename(nameof(ScribanExportItem.UnusedFields)))); diff --git a/Services/Export/Placeholder/ScribanRenderingEngine/ValueCollector/ItemInventoryValueCollector.cs b/Services/Export/Placeholder/ScribanRenderingEngine/ValueCollector/ItemInventoryValueCollector.cs new file mode 100644 index 00000000..7af17447 --- /dev/null +++ b/Services/Export/Placeholder/ScribanRenderingEngine/ValueCollector/ItemInventoryValueCollector.cs @@ -0,0 +1,148 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using GoNorth.Data.Exporting; +using GoNorth.Data.Project; +using GoNorth.Data.Styr; +using GoNorth.Services.Export.Data; +using GoNorth.Services.Export.Placeholder.ScribanRenderingEngine.LanguageKeyGenerator; +using GoNorth.Services.Export.Placeholder.ScribanRenderingEngine.RenderingObjects; +using GoNorth.Services.Export.Placeholder.ScribanRenderingEngine.Util; +using Microsoft.Extensions.Localization; +using Scriban; +using Scriban.Runtime; + +namespace GoNorth.Services.Export.Placeholder.ScribanRenderingEngine.ValueCollector +{ + /// + /// Class for Item Inventory Scriban value collectors + /// + public class ItemInventoryValueCollector : BaseScribanValueCollector + { + /// + /// Prefix used for items in the placeholder definition + /// + private const string ItemPlaceholderDefintionPrefix = "cur_inventory_item"; + + /// + /// Export cached database access + /// + private readonly IExportCachedDbAccess _exportCachedDbAccess; + + /// + /// Language key generator + /// + private readonly IScribanLanguageKeyGenerator _languageKeyGenerator; + + /// + /// Localizer Factory + /// + private readonly IStringLocalizerFactory _localizerFactory; + + /// + /// Constructor + /// + /// Export cached database access + /// Language key generator + /// Localizer Factory + public ItemInventoryValueCollector(IExportCachedDbAccess exportCachedDbAccess, IScribanLanguageKeyGenerator languageKeyGenerator, + IStringLocalizerFactory localizerFactory) + { + _exportCachedDbAccess = exportCachedDbAccess; + _languageKeyGenerator = languageKeyGenerator; + _localizerFactory = localizerFactory; + } + + /// + /// Returns true if the value collector is valid for a given template type + /// + /// Template type + /// True if the value collector is valid, else false + public override bool IsValidForTemplateType(TemplateType templateType) + { + return templateType == TemplateType.ObjectItem; + } + + /// + /// Collects the values for an export + /// + /// Template type + /// Parsed scriban template + /// Scriban script object to fill + /// Export Data + /// Task + public override async Task CollectValues(TemplateType templateType, Template parsedTemplate, ScriptObject scriptObject, ExportObjectData data) + { + StyrItem inputItem = data.ExportData[ExportConstants.ExportDataObject] as StyrItem; + if(inputItem == null) + { + return; + } + + _languageKeyGenerator.SetErrorCollection(_errorCollection); + + List items = await LoadInventory(parsedTemplate, inputItem); + scriptObject.AddOrUpdate(ExportConstants.ScribanInventoryObjectKey, items); + scriptObject.AddOrUpdate(ExportConstants.ScribanLanguageKeyName, _languageKeyGenerator); + } + + /// + /// Loads the inventory + /// + /// Parsed scriban template + /// Input item + /// List of items + private async Task> LoadInventory(Template parsedTemplate, StyrItem inputItem) + { + if(inputItem.Inventory == null || !inputItem.Inventory.Any()) + { + return new List(); + } + + + GoNorthProject project = await _exportCachedDbAccess.GetUserProject(); + ExportSettings exportSettings = await _exportCachedDbAccess.GetExportSettings(project.Id); + + List inventoryItems = new List(); + List items = await _exportCachedDbAccess.GetItemsById(inputItem.Inventory.Select(i => i.ItemId).ToList()); + foreach(StyrInventoryItem curItem in inputItem.Inventory) + { + StyrItem loadedItem = items.FirstOrDefault(i => i.Id == curItem.ItemId); + if(loadedItem == null) + { + continue; + } + + ScribanExportItemInventoryItem exportItem = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject(null, parsedTemplate, loadedItem, exportSettings, _errorCollection); + exportItem.Quantity = curItem.Quantity; + exportItem.Role = curItem.Role; + inventoryItems.Add(exportItem); + } + + return inventoryItems; + } + + /// + /// Returns the Export Template Placeholders for a Template Type + /// + /// Template Type + /// Export Template Placeholder + public override List GetExportTemplatePlaceholdersForType(TemplateType templateType) + { + List exportPlaceholders = new List(); + if(templateType != TemplateType.ObjectItem) + { + return exportPlaceholders; + } + + IStringLocalizer stringLocalizer = _localizerFactory.Create(typeof(InventoryValueCollector)); + exportPlaceholders.Add(new ExportTemplatePlaceholder(ExportConstants.ScribanInventoryObjectKey, stringLocalizer["PlaceholderDesc_Inventory"])); + + List itemPlaceholders = ScribanPlaceholderGenerator.GetPlaceholdersForObject(_localizerFactory, ItemPlaceholderDefintionPrefix); + itemPlaceholders.RemoveAll(p => p.Name == string.Format("{0}.{1}", ItemPlaceholderDefintionPrefix, StandardMemberRenamer.Rename(nameof(ScribanExportItem.UnusedFields)))); + exportPlaceholders.AddRange(itemPlaceholders); + + return exportPlaceholders; + } + } +} \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index afa8a0db..4c62c0ec 100644 --- a/Startup.cs +++ b/Startup.cs @@ -358,7 +358,7 @@ public void ConfigureServices(IServiceCollection services) Description = "A portal to build storys for RPGs and other open world games.", Contact = new OpenApiContact { - Name = "Steffen Nörtershäuser" + Name = "Steffen Werhahn, former Nörtershäuser" }, License = new OpenApiLicense { diff --git a/UITests/package-lock.json b/UITests/package-lock.json index 33c711c9..17d77356 100644 --- a/UITests/package-lock.json +++ b/UITests/package-lock.json @@ -9,15 +9,15 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "mocha": "^10.1.0", - "mocha-junit-reporter": "^2.1.1", + "mocha": "^10.2.0", + "mocha-junit-reporter": "^2.2.0", "mocha-multi-reporters": "^1.5.1", - "puppeteer": "^19.2.2" + "puppeteer": "^19.7.2" }, "devDependencies": { "gulp": "^4.0.2", "gulp-zip": "^5.1.0", - "minimist": "^1.2.7" + "minimist": "^1.2.8" } }, "node_modules/@babel/code-frame": { @@ -117,16 +117,11 @@ } }, "node_modules/@types/node": { - "version": "18.11.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", - "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", + "version": "18.14.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.2.tgz", + "integrity": "sha512-1uEQxww3DaghA0RxqHx0O0ppVlo43pJhepY51OxuQIKHpjbnYLA7vcdwioNPzIqmC2u3I/dmylcqjlh0e7AyUA==", "optional": true }, - "node_modules/@types/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" - }, "node_modules/@types/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", @@ -561,9 +556,9 @@ } }, "node_modules/bl/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.1.tgz", + "integrity": "sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==", "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -776,6 +771,17 @@ "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" }, + "node_modules/chromium-bidi": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.4.tgz", + "integrity": "sha512-4BX5cSaponuvVT1+SbLYTOAgDoVtX/Khoc9UsbFJ/AsPVUeFAM3RiIDFI6XFhLYMi9WmVJqh1ZH+dRpNKkKwiQ==", + "dependencies": { + "mitt": "3.0.0" + }, + "peerDependencies": { + "devtools-protocol": "*" + } + }, "node_modules/class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -986,18 +992,17 @@ "dev": true }, "node_modules/cosmiconfig": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", - "integrity": "sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.0.0.tgz", + "integrity": "sha512-da1EafcpH6b/TD8vDRaWV7xFINlHlF6zKsGwS1TsuVJTZRkquaS5HTMq7uq6h31619QjbsYl21gVDOm32KM1vQ==", "dependencies": { - "@types/parse-json": "^4.0.0", "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" + "path-type": "^4.0.0" }, "engines": { - "node": ">=10" + "node": ">=14" } }, "node_modules/cosmiconfig/node_modules/parse-json": { @@ -1188,9 +1193,9 @@ } }, "node_modules/devtools-protocol": { - "version": "0.0.1056733", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1056733.tgz", - "integrity": "sha512-CmTu6SQx2g3TbZzDCAV58+LTxVdKplS7xip0g5oDXpZ+isr0rv5dDP8ToyVRywzPHkCCPKgKgScEcwz4uPWDIA==" + "version": "0.0.1094867", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1094867.tgz", + "integrity": "sha512-pmMDBKiRVjh0uKK6CT1WqZmM3hBVSgD+N2MrgyV1uNizAZMw4tx6i/RTc+/uCsKSCmg0xXx7arCP/OFcIwTsiQ==" }, "node_modules/diff": { "version": "5.0.0", @@ -3551,14 +3556,19 @@ } }, "node_modules/minimist": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", - "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/mitt": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.0.tgz", + "integrity": "sha512-7dX2/10ITVyqh4aOSVI9gdape+t9l2/8QxHrFmUXu4EEUpdlxl6RudZUPZoc+zuY2hk1j7XxVroIVIan/pD/SQ==" + }, "node_modules/mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", @@ -3601,9 +3611,9 @@ "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" }, "node_modules/mocha": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", - "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", "dependencies": { "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", @@ -3640,9 +3650,9 @@ } }, "node_modules/mocha-junit-reporter": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/mocha-junit-reporter/-/mocha-junit-reporter-2.1.1.tgz", - "integrity": "sha512-le1Z1uL6u7De/4uh0NQs+a7JledC8soZ4zZg/2IBpnigKDoyhmJ1GIImuV2m2QIlDYsgQ5AkyhVlH+zdYAiopw==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/mocha-junit-reporter/-/mocha-junit-reporter-2.2.0.tgz", + "integrity": "sha512-W83Ddf94nfLiTBl24aS8IVyFvO8aRDLlCvb+cKb/VEaN5dEbcqu3CXiTe8MQK2DvzS7oKE1RsFTxzN302GGbDQ==", "dependencies": { "debug": "^4.3.4", "md5": "^2.3.0", @@ -4404,40 +4414,48 @@ } }, "node_modules/puppeteer": { - "version": "19.2.2", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-19.2.2.tgz", - "integrity": "sha512-m1T5Mog5qu5+dMBptWYTn6pXRdnFbydbVUCthqwbfd8/kOiMlzZBR9ywjX79LpvI1Sj+/z8+FKeIsjnMul8ZYA==", + "version": "19.7.2", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-19.7.2.tgz", + "integrity": "sha512-4Lm7Qpe/LU95Svirei/jDLDvR5oMrl9BPGd7HMY5+Q28n+BhvKuW97gKkR+1LlI86bO8J3g8rG/Ll5kv9J1nlQ==", "hasInstallScript": true, "dependencies": { - "cosmiconfig": "7.0.1", - "devtools-protocol": "0.0.1056733", + "cosmiconfig": "8.0.0", "https-proxy-agent": "5.0.1", "progress": "2.0.3", "proxy-from-env": "1.1.0", - "puppeteer-core": "19.2.2" + "puppeteer-core": "19.7.2" }, "engines": { "node": ">=14.1.0" } }, "node_modules/puppeteer-core": { - "version": "19.2.2", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-19.2.2.tgz", - "integrity": "sha512-faojf+1pZ/tHXSr4x1q+9MVd9FrL3rpdbC0w7qN7MNClMoLuCvMbpR4vzcjoiJYgclt1n+SOPUOmHQViTw6frw==", + "version": "19.7.2", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-19.7.2.tgz", + "integrity": "sha512-PvI+fXqgP0uGJxkyZcX51bnzjFA73MODZOAv0fSD35yR7tvbqwtMV3/Y+hxQ0AMMwzxkEebP6c7po/muqxJvmQ==", "dependencies": { + "chromium-bidi": "0.4.4", "cross-fetch": "3.1.5", "debug": "4.3.4", - "devtools-protocol": "0.0.1056733", + "devtools-protocol": "0.0.1094867", "extract-zip": "2.0.1", "https-proxy-agent": "5.0.1", "proxy-from-env": "1.1.0", "rimraf": "3.0.2", "tar-fs": "2.1.1", "unbzip2-stream": "1.4.3", - "ws": "8.10.0" + "ws": "8.11.0" }, "engines": { "node": ">=14.1.0" + }, + "peerDependencies": { + "typescript": ">= 4.7.4" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, "node_modules/randombytes": { @@ -5177,9 +5195,9 @@ } }, "node_modules/tar-stream/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.1.tgz", + "integrity": "sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==", "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -5665,9 +5683,9 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "node_modules/ws": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.10.0.tgz", - "integrity": "sha512-+s49uSmZpvtAsd2h37vIPy1RBusaLawVe8of+GyEPsaJTCMpj/2v8NpeK1SHXjBlQ95lQTmQofOJnFiLoaN3yw==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", "engines": { "node": ">=10.0.0" }, @@ -5706,14 +5724,6 @@ "node": ">=10" } }, - "node_modules/yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "engines": { - "node": ">= 6" - } - }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -5870,16 +5880,11 @@ } }, "@types/node": { - "version": "18.11.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", - "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", + "version": "18.14.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.2.tgz", + "integrity": "sha512-1uEQxww3DaghA0RxqHx0O0ppVlo43pJhepY51OxuQIKHpjbnYLA7vcdwioNPzIqmC2u3I/dmylcqjlh0e7AyUA==", "optional": true }, - "@types/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" - }, "@types/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", @@ -6206,9 +6211,9 @@ }, "dependencies": { "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.1.tgz", + "integrity": "sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==", "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -6370,6 +6375,14 @@ "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" }, + "chromium-bidi": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.4.4.tgz", + "integrity": "sha512-4BX5cSaponuvVT1+SbLYTOAgDoVtX/Khoc9UsbFJ/AsPVUeFAM3RiIDFI6XFhLYMi9WmVJqh1ZH+dRpNKkKwiQ==", + "requires": { + "mitt": "3.0.0" + } + }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -6545,15 +6558,14 @@ "dev": true }, "cosmiconfig": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", - "integrity": "sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.0.0.tgz", + "integrity": "sha512-da1EafcpH6b/TD8vDRaWV7xFINlHlF6zKsGwS1TsuVJTZRkquaS5HTMq7uq6h31619QjbsYl21gVDOm32KM1vQ==", "requires": { - "@types/parse-json": "^4.0.0", "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" + "path-type": "^4.0.0" }, "dependencies": { "parse-json": { @@ -6697,9 +6709,9 @@ "dev": true }, "devtools-protocol": { - "version": "0.0.1056733", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1056733.tgz", - "integrity": "sha512-CmTu6SQx2g3TbZzDCAV58+LTxVdKplS7xip0g5oDXpZ+isr0rv5dDP8ToyVRywzPHkCCPKgKgScEcwz4uPWDIA==" + "version": "0.0.1094867", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1094867.tgz", + "integrity": "sha512-pmMDBKiRVjh0uKK6CT1WqZmM3hBVSgD+N2MrgyV1uNizAZMw4tx6i/RTc+/uCsKSCmg0xXx7arCP/OFcIwTsiQ==" }, "diff": { "version": "5.0.0", @@ -8630,11 +8642,16 @@ } }, "minimist": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", - "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", "dev": true }, + "mitt": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.0.tgz", + "integrity": "sha512-7dX2/10ITVyqh4aOSVI9gdape+t9l2/8QxHrFmUXu4EEUpdlxl6RudZUPZoc+zuY2hk1j7XxVroIVIan/pD/SQ==" + }, "mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", @@ -8667,9 +8684,9 @@ "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" }, "mocha": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", - "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", "requires": { "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", @@ -8811,9 +8828,9 @@ } }, "mocha-junit-reporter": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/mocha-junit-reporter/-/mocha-junit-reporter-2.1.1.tgz", - "integrity": "sha512-le1Z1uL6u7De/4uh0NQs+a7JledC8soZ4zZg/2IBpnigKDoyhmJ1GIImuV2m2QIlDYsgQ5AkyhVlH+zdYAiopw==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/mocha-junit-reporter/-/mocha-junit-reporter-2.2.0.tgz", + "integrity": "sha512-W83Ddf94nfLiTBl24aS8IVyFvO8aRDLlCvb+cKb/VEaN5dEbcqu3CXiTe8MQK2DvzS7oKE1RsFTxzN302GGbDQ==", "requires": { "debug": "^4.3.4", "md5": "^2.3.0", @@ -9270,33 +9287,33 @@ } }, "puppeteer": { - "version": "19.2.2", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-19.2.2.tgz", - "integrity": "sha512-m1T5Mog5qu5+dMBptWYTn6pXRdnFbydbVUCthqwbfd8/kOiMlzZBR9ywjX79LpvI1Sj+/z8+FKeIsjnMul8ZYA==", + "version": "19.7.2", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-19.7.2.tgz", + "integrity": "sha512-4Lm7Qpe/LU95Svirei/jDLDvR5oMrl9BPGd7HMY5+Q28n+BhvKuW97gKkR+1LlI86bO8J3g8rG/Ll5kv9J1nlQ==", "requires": { - "cosmiconfig": "7.0.1", - "devtools-protocol": "0.0.1056733", + "cosmiconfig": "8.0.0", "https-proxy-agent": "5.0.1", "progress": "2.0.3", "proxy-from-env": "1.1.0", - "puppeteer-core": "19.2.2" + "puppeteer-core": "19.7.2" } }, "puppeteer-core": { - "version": "19.2.2", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-19.2.2.tgz", - "integrity": "sha512-faojf+1pZ/tHXSr4x1q+9MVd9FrL3rpdbC0w7qN7MNClMoLuCvMbpR4vzcjoiJYgclt1n+SOPUOmHQViTw6frw==", + "version": "19.7.2", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-19.7.2.tgz", + "integrity": "sha512-PvI+fXqgP0uGJxkyZcX51bnzjFA73MODZOAv0fSD35yR7tvbqwtMV3/Y+hxQ0AMMwzxkEebP6c7po/muqxJvmQ==", "requires": { + "chromium-bidi": "0.4.4", "cross-fetch": "3.1.5", "debug": "4.3.4", - "devtools-protocol": "0.0.1056733", + "devtools-protocol": "0.0.1094867", "extract-zip": "2.0.1", "https-proxy-agent": "5.0.1", "proxy-from-env": "1.1.0", "rimraf": "3.0.2", "tar-fs": "2.1.1", "unbzip2-stream": "1.4.3", - "ws": "8.10.0" + "ws": "8.11.0" } }, "randombytes": { @@ -9903,9 +9920,9 @@ }, "dependencies": { "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.1.tgz", + "integrity": "sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==", "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -10312,9 +10329,9 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.10.0.tgz", - "integrity": "sha512-+s49uSmZpvtAsd2h37vIPy1RBusaLawVe8of+GyEPsaJTCMpj/2v8NpeK1SHXjBlQ95lQTmQofOJnFiLoaN3yw==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", "requires": {} }, "xml": { @@ -10333,11 +10350,6 @@ "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" }, - "yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==" - }, "yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", diff --git a/UITests/package.json b/UITests/package.json index 0ce51756..f3f423f6 100644 --- a/UITests/package.json +++ b/UITests/package.json @@ -11,17 +11,17 @@ "uitest", "gonorth" ], - "author": "Steffen Nörtershäuser", + "author": "Steffen Werhahn, former Nörtershäuser", "license": "MIT", "dependencies": { - "mocha": "^10.1.0", - "mocha-junit-reporter": "^2.1.1", + "mocha": "^10.2.0", + "mocha-junit-reporter": "^2.2.0", "mocha-multi-reporters": "^1.5.1", - "puppeteer": "^19.2.2" + "puppeteer": "^19.7.2" }, "devDependencies": { "gulp": "^4.0.2", "gulp-zip": "^5.1.0", - "minimist": "^1.2.7" + "minimist": "^1.2.8" } } diff --git a/Views/FlexFieldDatabase/FlexFieldInventory.cshtml b/Views/FlexFieldDatabase/FlexFieldInventory.cshtml new file mode 100644 index 00000000..e55e0cef --- /dev/null +++ b/Views/FlexFieldDatabase/FlexFieldInventory.cshtml @@ -0,0 +1,88 @@ +@using Microsoft.AspNetCore.Mvc.Localization + +@inject IViewLocalizer Localizer + +

+ + @Localizer["Inventory"] +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@Localizer["Name"]@Localizer["Quantity"]@Localizer["Equipped"]@Localizer["Role"]
+ + + + + + + + + +
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/Views/Kortisto/Npc.cshtml b/Views/Kortisto/Npc.cshtml index 57969de4..aefbe59f 100644 --- a/Views/Kortisto/Npc.cshtml +++ b/Views/Kortisto/Npc.cshtml @@ -106,51 +106,7 @@ {
-

- - @Localizer["Inventory"] -

- -
- - - - - - - - - - - - - - - - - - -
@Localizer["Name"]@Localizer["Quantity"]@Localizer["Equipped"]
-
- - - + @await Html.PartialAsync("~/Views/FlexFieldDatabase/FlexFieldInventory.cshtml")
} @@ -169,13 +125,13 @@ @Localizer["Name"] - + - + @@ -241,7 +197,7 @@ @Localizer["TargetState"] @Localizer["Script"] @Localizer["EnabledByDefault"] - + @@ -394,7 +350,6 @@ - + ``` -#### Babel +#### Webpack / Browserify / Babel -[Babel](https://babeljs.io/) is a next generation JavaScript compiler. One of the features is the ability to use ES6/ES2015 modules now, even though browsers do not yet support this feature natively. +There are several ways to use [Webpack](https://webpack.js.org/), [Browserify](http://browserify.org/) or [Babel](https://babeljs.io/). For more information on using these tools, please refer to the corresponding project's documentation. In the script, including jQuery will usually look like this: ```js import $ from "jquery"; ``` -#### Browserify/Webpack - -There are several ways to use [Browserify](http://browserify.org/) and [Webpack](https://webpack.github.io/). For more information on using these tools, please refer to the corresponding project's documentation. In the script, including jQuery will usually look like this... +If you need to use jQuery in a file that's not an ECMAScript module, you can use the CommonJS syntax: ```js var $ = require( "jquery" ); diff --git a/wwwroot/lib/jquery/dist/jquery.js b/wwwroot/lib/jquery/dist/jquery.js index fc6c299b..b86de89a 100644 --- a/wwwroot/lib/jquery/dist/jquery.js +++ b/wwwroot/lib/jquery/dist/jquery.js @@ -1,5 +1,5 @@ /*! - * jQuery JavaScript Library v3.6.0 + * jQuery JavaScript Library v3.6.3 * https://jquery.com/ * * Includes Sizzle.js @@ -9,7 +9,7 @@ * Released under the MIT license * https://jquery.org/license * - * Date: 2021-03-02T17:08Z + * Date: 2022-12-20T21:28Z */ ( function( global, factory ) { @@ -23,7 +23,7 @@ // (such as Node.js), expose a factory as module.exports. // This accentuates the need for the creation of a real `window`. // e.g. var jQuery = require("jquery")(window); - // See ticket #14549 for more info. + // See ticket trac-14549 for more info. module.exports = global.document ? factory( global, true ) : function( w ) { @@ -151,7 +151,7 @@ function toType( obj ) { var - version = "3.6.0", + version = "3.6.3", // Define a local copy of jQuery jQuery = function( selector, context ) { @@ -522,14 +522,14 @@ function isArrayLike( obj ) { } var Sizzle = /*! - * Sizzle CSS Selector Engine v2.3.6 + * Sizzle CSS Selector Engine v2.3.9 * https://sizzlejs.com/ * * Copyright JS Foundation and other contributors * Released under the MIT license * https://js.foundation/ * - * Date: 2021-02-16 + * Date: 2022-12-19 */ ( function( window ) { var i, @@ -879,6 +879,27 @@ function Sizzle( selector, context, results, seed ) { } try { + + // `qSA` may not throw for unrecognized parts using forgiving parsing: + // https://drafts.csswg.org/selectors/#forgiving-selector + // like the `:has()` pseudo-class: + // https://drafts.csswg.org/selectors/#relational + // `CSS.supports` is still expected to return `false` then: + // https://drafts.csswg.org/css-conditional-4/#typedef-supports-selector-fn + // https://drafts.csswg.org/css-conditional-4/#dfn-support-selector + if ( support.cssSupportsSelector && + + // eslint-disable-next-line no-undef + !CSS.supports( "selector(:is(" + newSelector + "))" ) ) { + + // Support: IE 11+ + // Throw to get to the same code path as an error directly in qSA. + // Note: once we only support browser supporting + // `CSS.supports('selector(...)')`, we can most likely drop + // the `try-catch`. IE doesn't implement the API. + throw new Error(); + } + push.apply( results, newContext.querySelectorAll( newSelector ) ); @@ -1174,6 +1195,31 @@ setDocument = Sizzle.setDocument = function( node ) { !el.querySelectorAll( ":scope fieldset div" ).length; } ); + // Support: Chrome 105+, Firefox 104+, Safari 15.4+ + // Make sure forgiving mode is not used in `CSS.supports( "selector(...)" )`. + // + // `:is()` uses a forgiving selector list as an argument and is widely + // implemented, so it's a good one to test against. + support.cssSupportsSelector = assert( function() { + /* eslint-disable no-undef */ + + return CSS.supports( "selector(*)" ) && + + // Support: Firefox 78-81 only + // In old Firefox, `:is()` didn't use forgiving parsing. In that case, + // fail this test as there's no selector to test against that. + // `CSS.supports` uses unforgiving parsing + document.querySelectorAll( ":is(:jqfake)" ) && + + // `*` is needed as Safari & newer Chrome implemented something in between + // for `:has()` - it throws in `qSA` if it only contains an unsupported + // argument but multiple ones, one of which is supported, are fine. + // We want to play safe in case `:is()` gets the same treatment. + !CSS.supports( "selector(:is(*,:jqfake))" ); + + /* eslint-enable */ + } ); + /* Attributes ---------------------------------------------------------------------- */ @@ -1440,6 +1486,17 @@ setDocument = Sizzle.setDocument = function( node ) { } ); } + if ( !support.cssSupportsSelector ) { + + // Support: Chrome 105+, Safari 15.4+ + // `:has()` uses a forgiving selector list as an argument so our regular + // `try-catch` mechanism fails to catch `:has()` with arguments not supported + // natively like `:has(:contains("Foo"))`. Where supported & spec-compliant, + // we now use `CSS.supports("selector(:is(SELECTOR_TO_BE_TESTED))")`, but + // outside that we mark `:has` as buggy. + rbuggyQSA.push( ":has" ); + } + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) ); @@ -1452,7 +1509,14 @@ setDocument = Sizzle.setDocument = function( node ) { // As in, an element does not contain itself contains = hasCompare || rnative.test( docElem.contains ) ? function( a, b ) { - var adown = a.nodeType === 9 ? a.documentElement : a, + + // Support: IE <9 only + // IE doesn't have `contains` on `document` so we need to check for + // `documentElement` presence. + // We need to fall back to `a` when `documentElement` is missing + // as `ownerDocument` of elements within `