Skip to content

Commit

Permalink
Merge pull request #469 from MUnique/dev/fix-socket-seed-crafting
Browse files Browse the repository at this point in the history
Fixed socket seed crafting
  • Loading branch information
sven-n authored Aug 25, 2024
2 parents 0525cf6 + 434501f commit 38f5610
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// <copyright file="FixSocketSeedCraftingUpdatePlugIn.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

namespace MUnique.OpenMU.Persistence.Initialization.Updates;

using System.Runtime.InteropServices;
using MUnique.OpenMU.DataModel.Configuration;
using MUnique.OpenMU.DataModel.Configuration.Items;
using MUnique.OpenMU.PlugIns;

/// <summary>
/// This update sets the right settings for the socket seed crafting.
/// </summary>
[PlugIn(PlugInName, PlugInDescription)]
[Guid("C802EFC2-1D42-4218-871E-8886D115F3ED")]
public class FixSocketSeedCraftingUpdatePlugIn : UpdatePlugInBase
{
/// <summary>
/// The plug in name.
/// </summary>
internal const string PlugInName = "Fixed socket seed crafting";

/// <summary>
/// The plug in description.
/// </summary>
internal const string PlugInDescription = "This update sets the right settings for the socket seed crafting.";

/// <inheritdoc />
public override string Name => PlugInName;

/// <inheritdoc />
public override string Description => PlugInDescription;

/// <inheritdoc />
public override UpdateVersion Version => UpdateVersion.FixSocketSeedCrafting;

/// <inheritdoc />
public override string DataInitializationKey => VersionSeasonSix.DataInitialization.Id;

/// <inheritdoc />
public override bool IsMandatory => true;

/// <inheritdoc />
public override DateTime CreatedAt => new(2024, 08, 25, 15, 00, 0, DateTimeKind.Utc);

/// <inheritdoc />
protected override async ValueTask ApplyAsync(IContext context, GameConfiguration gameConfiguration)
{
var seedMaster = gameConfiguration.Monsters.FirstOrDefault(m => m.NpcWindow == NpcWindow.SeedMaster);
if (seedMaster is null)
{
return;
}

var seedCrafting = seedMaster.ItemCraftings.FirstOrDefault(c => c.Number == 42);
if (seedCrafting?.SimpleCraftingSettings is not { } craftingSettings)
{
return;
}

var option = gameConfiguration.ItemOptionTypes.First(o => object.Equals(o, ItemOptionTypes.Option));
foreach (var requirement in craftingSettings.RequiredItems)
{
requirement.RequiredItemOptions.Remove(option);
}
}
}
5 changes: 5 additions & 0 deletions src/Persistence/Initialization/Updates/UpdateVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,9 @@ public enum UpdateVersion
/// The version of the <see cref="FixDamageAbsorbItemsUpdatePlugIn"/>.
/// </summary>
FixDamageAbsorbItems = 23,

/// <summary>
/// The version of the <see cref="FixSocketSeedCraftingUpdatePlugIn"/>.
/// </summary>
FixSocketSeedCrafting = 24,
}
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@ private ItemCrafting SeedCrafting()
randomExcItem.MaximumItemLevel = 15;
randomExcItem.NpcPriceDivisor = 2_000_000;
randomExcItem.RequiredItemOptions.Add(this.GameConfiguration.ItemOptionTypes.First(o => o == ItemOptionTypes.Excellent));
randomExcItem.RequiredItemOptions.Add(this.GameConfiguration.ItemOptionTypes.First(o => o == ItemOptionTypes.Option));
craftingSettings.RequiredItems.Add(randomExcItem);

var randomAncientItem = this.Context.CreateNew<ItemCraftingRequiredItem>();
Expand All @@ -553,7 +552,6 @@ private ItemCrafting SeedCrafting()
randomAncientItem.MaximumItemLevel = 15;
randomAncientItem.NpcPriceDivisor = 2_000_000;
randomAncientItem.RequiredItemOptions.Add(this.GameConfiguration.ItemOptionTypes.First(o => o == ItemOptionTypes.AncientBonus));
randomAncientItem.RequiredItemOptions.Add(this.GameConfiguration.ItemOptionTypes.First(o => o == ItemOptionTypes.Option));
craftingSettings.RequiredItems.Add(randomAncientItem);

var chaos = this.Context.CreateNew<ItemCraftingRequiredItem>();
Expand Down

0 comments on commit 38f5610

Please sign in to comment.