diff --git a/src/GameLogic/Attributes/Stats.cs b/src/GameLogic/Attributes/Stats.cs index d9371f14a..307ce715c 100644 --- a/src/GameLogic/Attributes/Stats.cs +++ b/src/GameLogic/Attributes/Stats.cs @@ -899,6 +899,11 @@ public class Stats /// public static AttributeDefinition IsVip { get; } = new(new Guid("195474D6-59A2-4033-9C30-8628ECC0097E"), "Is VIP", "The flag, if an account is a VIP."); + /// + /// Gets the attribute for the number of points this class will receive for reset, overwrites the default value. + /// + public static AttributeDefinition PointsPerReset { get; } = new(new Guid("a34f4f57-b364-4cdb-9989-64cedd2cd831"), "Points Per Reset", "The number of points the player will receive for reset, overwrites the default 'PointsPerReset' value of the reset configuration."); + /// /// Gets the attributes which are regenerated in an interval. /// diff --git a/src/GameLogic/Resets/ResetCharacterAction.cs b/src/GameLogic/Resets/ResetCharacterAction.cs index e32447ca5..d95700414 100644 --- a/src/GameLogic/Resets/ResetCharacterAction.cs +++ b/src/GameLogic/Resets/ResetCharacterAction.cs @@ -124,7 +124,7 @@ private async ValueTask TryConsumeMoneyAsync(ResetConfiguration configurat private void UpdateStats(ResetConfiguration configuration) { - var calculatedPointsPerReset = configuration.PointsPerReset; + var calculatedPointsPerReset = this.GetResetPoints(configuration); if (configuration.MultiplyPointsByResetCount) { calculatedPointsPerReset *= this.GetResetCount(); @@ -140,6 +140,17 @@ private void UpdateStats(ResetConfiguration configuration) this._player.SelectedCharacter!.LevelUpPoints = Math.Max(0, calculatedPointsPerReset); } + private int GetResetPoints(ResetConfiguration configuration) + { + var pointsPerReset = (int)this._player.Attributes![Stats.PointsPerReset]; + if (pointsPerReset == 0) + { + pointsPerReset = configuration.PointsPerReset; + } + + return pointsPerReset; + } + private async ValueTask MoveHomeAsync() { var homeMapDef = this._player.SelectedCharacter!.CharacterClass!.HomeMap; diff --git a/src/Persistence/Initialization/Updates/AddPointsPerResetAttributePlugIn.cs b/src/Persistence/Initialization/Updates/AddPointsPerResetAttributePlugIn.cs new file mode 100644 index 000000000..5672c033a --- /dev/null +++ b/src/Persistence/Initialization/Updates/AddPointsPerResetAttributePlugIn.cs @@ -0,0 +1,57 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for full license information. +// + +namespace MUnique.OpenMU.Persistence.Initialization.Updates; + +using System; +using System.Runtime.InteropServices; +using MUnique.OpenMU.AttributeSystem; + +using MUnique.OpenMU.DataModel.Configuration; +using MUnique.OpenMU.GameLogic.Attributes; +using MUnique.OpenMU.PlugIns; + +/// +/// This update adds the . +/// +[PlugIn(PlugInName, PlugInDescription)] +[Guid("6011A1B8-7FA5-48EB-935D-EEAF83017799")] +public class AddPointsPerResetAttributePlugIn : UpdatePlugInBase +{ + /// + /// The plug in name. + /// + internal const string PlugInName = "Adds attribute PointsPerReset"; + + /// + /// The plug in description. + /// + internal const string PlugInDescription = "This update adds the attribute PointsPerReset."; + + /// + public override string Name => PlugInName; + + /// + public override string Description => PlugInDescription; + + /// + public override UpdateVersion Version => UpdateVersion.AddPointsPerResetByClassAttribute; + + /// + public override string DataInitializationKey => VersionSeasonSix.DataInitialization.Id; + + /// + public override bool IsMandatory => true; + + /// + public override DateTime CreatedAt => new(2024, 06, 09, 13, 30, 0, DateTimeKind.Utc); + + /// + protected override async ValueTask ApplyAsync(IContext context, GameConfiguration gameConfiguration) + { + var attribute = Stats.PointsPerReset; + var persistentAttribute = context.CreateNew(attribute.Id, attribute.Designation, attribute.Description); + gameConfiguration.Attributes.Add(persistentAttribute); + } +} \ No newline at end of file diff --git a/src/Persistence/Initialization/Updates/UpdateVersion.cs b/src/Persistence/Initialization/Updates/UpdateVersion.cs index cf9ee08d7..4e7a53394 100644 --- a/src/Persistence/Initialization/Updates/UpdateVersion.cs +++ b/src/Persistence/Initialization/Updates/UpdateVersion.cs @@ -84,4 +84,9 @@ public enum UpdateVersion /// The version of the . /// InfinityArrowSkillOnQuestCompletion = 15, + + /// + /// The version of the . + /// + AddPointsPerResetByClassAttribute = 16 } \ No newline at end of file