diff --git a/Lib9c/Action/InvalidItemIdException.cs b/Lib9c/Action/InvalidItemIdException.cs new file mode 100644 index 0000000000..ca1e7c0b29 --- /dev/null +++ b/Lib9c/Action/InvalidItemIdException.cs @@ -0,0 +1,36 @@ +using System; +using System.Runtime.Serialization; + +namespace Nekoyume.Action +{ + /// + /// Represents an exception that is thrown when an invalid item ID is used. + /// + [Serializable] + public class InvalidItemIdException : ArgumentOutOfRangeException + { + /// + /// Initializes a new instance of the class. + /// + public InvalidItemIdException() + { + } + + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// The message that describes the error. + public InvalidItemIdException(string msg) : base(msg) + { + } + + /// + /// Initializes a new instance of the class with a specified error message + /// + /// SerializationInfo + /// StreamingContext + protected InvalidItemIdException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} diff --git a/Lib9c/Action/Synthesize.cs b/Lib9c/Action/Synthesize.cs index 1f5438af8e..417acc506d 100644 --- a/Lib9c/Action/Synthesize.cs +++ b/Lib9c/Action/Synthesize.cs @@ -30,6 +30,11 @@ namespace Nekoyume.Action [ActionType(TypeIdentifier)] public class Synthesize : GameAction { + /// + /// The list of invalid item ids for material. + /// + public static readonly int[] InvalidMaterialItemId = { 10660004, 10760009, 40100042, 40100043, }; + private const string TypeIdentifier = "synthesize"; private const string MaterialsKey = "m"; @@ -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) {