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