//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.Persistence.Initialization.Updates;
using System.Runtime.InteropServices;
using MUnique.OpenMU.AttributeSystem;
using MUnique.OpenMU.DataModel.Configuration;
using MUnique.OpenMU.DataModel.Configuration.Items;
using MUnique.OpenMU.GameLogic.Attributes;
using MUnique.OpenMU.PlugIns;
///
/// The chaos castle update plugin.
///
[PlugIn]
[Display(Name = PlugInName, Description = PlugInDescription)]
[Guid("B0F275DC-B3C2-4826-8263-FFDC8A8AFAEA")]
public class FixLevelDiv20ExcOptionUpdatePlugIn : UpdatePlugInBase
{
///
/// The plug in name.
///
internal const string PlugInName = "Excellent Option Level/20 damage fix";
///
/// The plug in description.
///
internal const string PlugInDescription = "This update fixes the excellent option which adds level / 20 as wizardry damage";
///
public override UpdateVersion Version => UpdateVersion.FixLevelDiv20ExcOptionUpdate;
///
public override string DataInitializationKey => VersionSeasonSix.DataInitialization.Id;
///
public override string Name => PlugInName;
///
public override string Description => PlugInDescription;
///
public override bool IsMandatory => true;
///
public override DateTime CreatedAt => new(2023, 04, 03, 20, 5, 0, DateTimeKind.Utc);
///
#pragma warning disable CS1998
protected override async ValueTask ApplyAsync(IContext context, GameConfiguration gameConfiguration)
#pragma warning restore CS1998
{
var level20Relationships = gameConfiguration.ItemOptions
.SelectMany(io => io.PossibleOptions.Where(p => p.OptionType == ItemOptionTypes.Excellent))
.SelectMany(o => o.PowerUpDefinition?.Boost?.RelatedValues.Where(s => s.InputAttribute == Stats.Level && Math.Abs(s.InputOperand - 20f) < 0.01) ?? Enumerable.Empty())
.ToList();
foreach (var relationship in level20Relationships)
{
relationship.InputOperand = 1f / 20f;
}
}
}