//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.Persistence.Initialization.Skills;
using MUnique.OpenMU.AttributeSystem;
using MUnique.OpenMU.DataModel.Attributes;
using MUnique.OpenMU.DataModel.Configuration;
using MUnique.OpenMU.GameLogic.Attributes;
///
/// Initializer for the greater defense buff effect.
///
public class GreaterDefenseEffectInitializer : InitializerBase
{
///
/// Initializes a new instance of the class.
///
/// The context.
/// The game configuration.
public GreaterDefenseEffectInitializer(IContext context, GameConfiguration gameConfiguration)
: base(context, gameConfiguration)
{
}
///
public override void Initialize()
{
var magicEffect = this.Context.CreateNew();
this.GameConfiguration.MagicEffects.Add(magicEffect);
magicEffect.Number = (short)MagicEffectNumber.GreaterDefense;
magicEffect.Name = "Greater Defense Buff Skill Effect";
magicEffect.InformObservers = true;
magicEffect.SendDuration = false;
magicEffect.StopByDeath = true;
magicEffect.Duration = this.Context.CreateNew();
magicEffect.Duration.ConstantValue.Value = 60; // 60 Seconds
// The buff gives 2 + (energy / 8) defense
var powerUpDefinition = this.Context.CreateNew();
magicEffect.PowerUpDefinitions.Add(powerUpDefinition);
powerUpDefinition.TargetAttribute = Stats.GreaterDefenseBonus.GetPersistent(this.GameConfiguration);
powerUpDefinition.Boost = this.Context.CreateNew();
powerUpDefinition.Boost.ConstantValue.Value = 2f;
powerUpDefinition.Boost.ConstantValue.AggregateType = AggregateType.AddRaw;
var boostPerEnergy = this.Context.CreateNew();
boostPerEnergy.InputAttribute = Stats.TotalEnergy.GetPersistent(this.GameConfiguration);
boostPerEnergy.InputOperator = InputOperator.Multiply;
boostPerEnergy.InputOperand = 1f / 8f; // one defense per 8 energy
powerUpDefinition.Boost.RelatedValues.Add(boostPerEnergy);
// Placeholder for DefenseIncreaseStr and DefenseIncreaseMastery master skills
var powerUpDefinition2 = this.Context.CreateNew();
magicEffect.PowerUpDefinitions.Add(powerUpDefinition2);
powerUpDefinition2.TargetAttribute = Stats.GreaterDefenseBonus.GetPersistent(this.GameConfiguration);
powerUpDefinition2.Boost = this.Context.CreateNew();
powerUpDefinition2.Boost.ConstantValue.Value = 1f;
powerUpDefinition2.Boost.ConstantValue.AggregateType = AggregateType.Multiplicate;
}
}