public Item(string data, string commandScope = "") { var dataChunks = data.Split(':'); var itemData = dataChunks[0].Split('.'); if (itemData[0].TrimStart(' ').TrimEnd(' ') != "Items") { throw new ParserException($"{commandScope}: \"{data}\" is not an item, make sure it has \"Items.\" prepended"); } if (!Enum.TryParse(itemData[1], out Type)) { throw new ParserException($"{commandScope}: \"{data}\" has an invalid itemType"); } UseAny = false; SubValue = 0; if (itemData.Length >= 3) { if (itemData[2] == "*") { UseAny = true; } else if (!byte.TryParse(itemData[2], NumberStyles.HexNumber, null, out SubValue)) { if (Enum.TryParse(itemData[2], out Kinstone)) { SubValue = (byte)Kinstone; } else { throw new ParserException($"{commandScope}: \"{data}\" has an invalid itemSub"); } } } Dungeon = ""; if (dataChunks.Length > 1) { Dungeon = dataChunks[1]; } if (Type == ItemType.KinstoneX) { Kinstone = (KinstoneType)SubValue; } else { Kinstone = KinstoneType.UnTyped; } }
public Item(ItemType type, byte subValue, string dungeon = "") { Type = type; SubValue = subValue; if (type == ItemType.KinstoneX) { Kinstone = (KinstoneType)subValue; } else { Kinstone = KinstoneType.UnTyped; } Dungeon = dungeon; }