Skip to content

Commit

Permalink
Added a plugin configuration for jewel of bless consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n committed Mar 20, 2024
1 parent a0f52ab commit 5e23083
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,26 @@ namespace MUnique.OpenMU.GameLogic.PlayerActions.ItemConsumeActions;
/// </summary>
[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<BlessJewelConsumeHandlerPlugInConfiguration>
{
/// <inheritdoc />
public override ItemIdentifier Key => ItemConstants.JewelOfBless;

/// <summary>
/// Gets or sets the configuration.
/// </summary>
public BlessJewelConsumeHandlerPlugInConfiguration? Configuration { get; set; }

/// <inheritdoc/>
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;
Expand All @@ -37,6 +49,7 @@ protected override bool ModifyItem(Item item, IContext persistenceContext)

level++;
item.Level = level;
item.Durability = item.GetMaximumDurabilityOfOnePiece();
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// <copyright file="BlessJewelConsumeHandlerPlugInConfiguration.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

namespace MUnique.OpenMU.GameLogic.PlayerActions.ItemConsumeActions;

using MUnique.OpenMU.DataModel.Configuration.Items;

/// <summary>
/// The configuration for the <see cref="BlessJewelConsumeHandlerPlugIn"/>.
/// </summary>
public class BlessJewelConsumeHandlerPlugInConfiguration
{
/// <summary>
/// Gets or sets the items which can be repaired by consuming a bless on them.
/// </summary>
public ICollection<ItemDefinition> RepairTargetItems { get; set; } = new List<ItemDefinition>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

Expand Down

0 comments on commit 5e23083

Please sign in to comment.