Skip to content

Commit

Permalink
Merge pull request #3090 from eugene-doobu/feature/add-invalid-item-ids
Browse files Browse the repository at this point in the history
add InvalidMaterialItemId
  • Loading branch information
eugene-doobu authored Dec 17, 2024
2 parents 0e0124b + 36bdf88 commit 84f701a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Lib9c/Action/InvalidItemIdException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Runtime.Serialization;

namespace Nekoyume.Action
{
/// <summary>
/// Represents an exception that is thrown when an invalid item ID is used.
/// </summary>
[Serializable]
public class InvalidItemIdException : ArgumentOutOfRangeException
{
/// <summary>
/// Initializes a new instance of the <see cref="InvalidItemIdException"/> class.
/// </summary>
public InvalidItemIdException()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="InvalidItemIdException"/> class with a specified error message.
/// </summary>
/// <param name="msg">The message that describes the error.</param>
public InvalidItemIdException(string msg) : base(msg)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="InvalidItemIdException"/> class with a specified error message
/// </summary>
/// <param name="info">SerializationInfo</param>
/// <param name="context">StreamingContext</param>
protected InvalidItemIdException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
14 changes: 14 additions & 0 deletions Lib9c/Action/Synthesize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ namespace Nekoyume.Action
[ActionType(TypeIdentifier)]
public class Synthesize : GameAction
{
/// <summary>
/// The list of invalid item ids for material.
/// </summary>
public static readonly int[] InvalidMaterialItemId = { 10660004, 10760009, 40100042, 40100043, };

private const string TypeIdentifier = "synthesize";

private const string MaterialsKey = "m";
Expand Down Expand Up @@ -116,6 +121,15 @@ public override IWorld Execute(IActionContext context)
addressesHex
);

// Check Invalid Item
foreach (var materialItem in materialItems)
{
if (InvalidMaterialItemId.Contains(materialItem.Id))
{
throw new InvalidItemIdException($"{materialItem.Id} is invalid item id.");
}
}

// Unequip items (if necessary)
foreach (var materialItem in materialItems)
{
Expand Down

0 comments on commit 84f701a

Please sign in to comment.