Repository navigation
feat(items): add the gladiator's honor #1471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // <copyright file="GladiatorsHonorConsumeHandlerPlugIn.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 System.Runtime.InteropServices; | ||
| using MUnique.OpenMU.GameLogic.PlugIns; | ||
| using MUnique.OpenMU.PlugIns; | ||
|
|
||
| /// <summary> | ||
| /// The consume handler for the Gladiator's Honor, which applies its effect only in Vulcanus, | ||
| /// like the game client describes it. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// The experience bonus of its effect is applied by the <see cref="VulcanusExperiencePlugIn"/>, | ||
| /// so it only counts while the player stays in Vulcanus. | ||
| /// </remarks> | ||
| [PlugIn] | ||
| [Display(Name = nameof(PlugInResources.GladiatorsHonorConsumeHandlerPlugIn_Name), Description = nameof(PlugInResources.GladiatorsHonorConsumeHandlerPlugIn_Description), ResourceType = typeof(PlugInResources))] | ||
| [Guid("FBB2F1AB-8097-41B0-A10E-8323C10D053A")] | ||
| public class GladiatorsHonorConsumeHandlerPlugIn : ApplyMagicEffectConsumeHandlerPlugIn, ISupportCustomConfiguration<VulcanusMapConfiguration>, ISupportDefaultCustomConfiguration | ||
| { | ||
| /// <inheritdoc /> | ||
| public VulcanusMapConfiguration? Configuration { get; set; } | ||
|
|
||
| /// <inheritdoc /> | ||
| public override ItemIdentifier Key => ItemConstants.GladiatorsHonor; | ||
|
|
||
| /// <inheritdoc /> | ||
| public override async ValueTask<bool> ConsumeItemAsync(Player player, Item item, Item? targetItem, FruitUsage fruitUsage) | ||
| { | ||
| var mapNumber = (this.Configuration ??= new VulcanusMapConfiguration()).MapNumber; | ||
| if (player.CurrentMap?.MapId != mapNumber) | ||
| { | ||
| await player.ShowLocalizedBlueMessageAsync(nameof(PlayerMessage.ItemCantBeUsedOnThisMap)).ConfigureAwait(false); | ||
| return false; | ||
| } | ||
|
|
||
| return await base.ConsumeItemAsync(player, item, targetItem, fruitUsage).ConfigureAwait(false); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public object CreateDefaultConfig() => new VulcanusMapConfiguration(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // <copyright file="VulcanusExperiencePlugIn.cs" company="MUnique"> | ||
| // Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
| // </copyright> | ||
|
|
||
| namespace MUnique.OpenMU.GameLogic.PlugIns; | ||
|
|
||
| using System.Runtime.InteropServices; | ||
| using MUnique.OpenMU.GameLogic.Attributes; | ||
| using MUnique.OpenMU.PlugIns; | ||
|
|
||
| /// <summary> | ||
| /// Increases the experience of a player in Vulcanus by its <see cref="Stats.VulcanusExperienceRate"/>, | ||
| /// which is given e.g. by the Gladiator's Honor. | ||
| /// </summary> | ||
| [PlugIn] | ||
| [Display(Name = nameof(PlugInResources.VulcanusExperiencePlugIn_Name), Description = nameof(PlugInResources.VulcanusExperiencePlugIn_Description), ResourceType = typeof(PlugInResources))] | ||
| [Guid("03E6A271-821E-49B8-B6E9-B24E95B6D16E")] | ||
| public class VulcanusExperiencePlugIn : IExperienceCalculationPlugIn, ISupportCustomConfiguration<VulcanusMapConfiguration>, ISupportDefaultCustomConfiguration | ||
| { | ||
| /// <inheritdoc /> | ||
| public VulcanusMapConfiguration? Configuration { get; set; } | ||
|
|
||
| /// <inheritdoc /> | ||
| public ValueTask CalculateExperienceAsync(Player player, ExperienceCalculationArgs args) | ||
| { | ||
| var mapNumber = (this.Configuration ??= new VulcanusMapConfiguration()).MapNumber; | ||
| if (player.CurrentMap?.MapId == mapNumber | ||
| && player.Attributes?[Stats.VulcanusExperienceRate] is > 0 and var rate) | ||
| { | ||
| args.Experience *= 1 + rate; | ||
| } | ||
|
|
||
| return ValueTask.CompletedTask; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public object CreateDefaultConfig() => new VulcanusMapConfiguration(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // <copyright file="VulcanusMapConfiguration.cs" company="MUnique"> | ||
| // Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
| // </copyright> | ||
|
|
||
| namespace MUnique.OpenMU.GameLogic.PlugIns; | ||
|
|
||
| /// <summary> | ||
| /// Configuration of the plugins of the Gladiator's Honor, which only apply in Vulcanus. | ||
| /// </summary> | ||
| public class VulcanusMapConfiguration | ||
| { | ||
| /// <summary> | ||
| /// The default number of the map Vulcanus. | ||
| /// </summary> | ||
| internal const short DefaultMapNumber = 63; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the number of the map in which the Gladiator's Honor can be used and gives its bonus. | ||
| /// </summary> | ||
| [Display(ResourceType = typeof(PlugInResources), Name = nameof(PlugInResources.VulcanusMapConfiguration_MapNumber_Name))] | ||
| public short MapNumber { get; set; } = DefaultMapNumber; | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only producer of this attribute is the new Gladiator's Honor effect in
BuffItems, and its only consumer isVulcanusExperiencePlugIn. This violates rule 3 ofdocs/CODING_RULES.md: “Don't introduce new stats for one specific item or skill.” It turns this item's implementation detail into a permanent persisted attribute/GUID contract and requires additional attribute-creation handling during upgrades. Keep the map restriction in the feature plugin and represent the bonus through existing experience attributes or item/plugin configuration instead.AGENTS.md reference: AGENTS.md:L16-L17
Useful? React with 👍 / 👎.