From 5e230831938d1fe6d26b86f2bfe979a887977604 Mon Sep 17 00:00:00 2001 From: sven-n Date: Wed, 20 Mar 2024 18:40:58 +0100 Subject: [PATCH] Added a plugin configuration for jewel of bless consumption --- .../BlessJewelConsumeHandlerPlugIn.cs | 15 ++++++++++++++- ...ssJewelConsumeHandlerPlugInConfiguration.cs | 18 ++++++++++++++++++ .../SoulJewelConsumeHandlerPlugIn.cs | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugInConfiguration.cs diff --git a/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugIn.cs b/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugIn.cs index 65b5ae2f2..47e7d4b79 100644 --- a/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugIn.cs +++ b/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugIn.cs @@ -15,14 +15,26 @@ namespace MUnique.OpenMU.GameLogic.PlayerActions.ItemConsumeActions; /// [Guid("E95A0292-B3B4-4E8C-AC5A-7F3DB4F01A37")] [PlugIn(nameof(BlessJewelConsumeHandlerPlugIn), "Plugin which handles the jewel of bless consumption.")] -public class BlessJewelConsumeHandlerPlugIn : ItemModifyConsumeHandlerPlugIn +public class BlessJewelConsumeHandlerPlugIn : ItemModifyConsumeHandlerPlugIn, ISupportCustomConfiguration { /// public override ItemIdentifier Key => ItemConstants.JewelOfBless; + /// + /// Gets or sets the configuration. + /// + public BlessJewelConsumeHandlerPlugInConfiguration? Configuration { get; set; } + /// protected override bool ModifyItem(Item item, IContext persistenceContext) { + if (this.Configuration?.RepairTargetItems.Contains(item.Definition!) is true + && item.Durability < item.GetMaximumDurabilityOfOnePiece()) + { + item.Durability = item.GetMaximumDurabilityOfOnePiece(); + return true; + } + if (!item.CanLevelBeUpgraded()) { return false; @@ -37,6 +49,7 @@ protected override bool ModifyItem(Item item, IContext persistenceContext) level++; item.Level = level; + item.Durability = item.GetMaximumDurabilityOfOnePiece(); return true; } } \ No newline at end of file diff --git a/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugInConfiguration.cs b/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugInConfiguration.cs new file mode 100644 index 000000000..23994c22a --- /dev/null +++ b/src/GameLogic/PlayerActions/ItemConsumeActions/BlessJewelConsumeHandlerPlugInConfiguration.cs @@ -0,0 +1,18 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for full license information. +// + +namespace MUnique.OpenMU.GameLogic.PlayerActions.ItemConsumeActions; + +using MUnique.OpenMU.DataModel.Configuration.Items; + +/// +/// The configuration for the . +/// +public class BlessJewelConsumeHandlerPlugInConfiguration +{ + /// + /// Gets or sets the items which can be repaired by consuming a bless on them. + /// + public ICollection RepairTargetItems { get; set; } = new List(); +} \ No newline at end of file diff --git a/src/GameLogic/PlayerActions/ItemConsumeActions/SoulJewelConsumeHandlerPlugIn.cs b/src/GameLogic/PlayerActions/ItemConsumeActions/SoulJewelConsumeHandlerPlugIn.cs index 0d9738147..561d372db 100644 --- a/src/GameLogic/PlayerActions/ItemConsumeActions/SoulJewelConsumeHandlerPlugIn.cs +++ b/src/GameLogic/PlayerActions/ItemConsumeActions/SoulJewelConsumeHandlerPlugIn.cs @@ -62,6 +62,7 @@ protected override bool ModifyItem(Item item, IContext persistenceContext) if (this._randomizer.NextRandomBool(percent)) { item.Level++; + item.Durability = item.GetMaximumDurabilityOfOnePiece(); return true; // true doesn't mean that it was successful, just that the consumption happened. }