public async Task CustomizeAsync([Summary("Item ID (in hex)")] string itemHex, [Summary("Customization value sum")] int sum) { if (!Globals.Bot.Config.AllowLookup) { return; } ushort itemID = ItemUtil.GetID(itemHex); if (itemID == Item.NONE) { await ReplyAsync("Invalid item requested.").ConfigureAwait(false); return; } if (sum <= 0) { await ReplyAsync("No customization data specified.").ConfigureAwait(false); return; } var remake = ItemRemakeUtil.GetRemakeIndex(itemID); if (remake < 0) { await ReplyAsync("No customization data available for the requested item.").ConfigureAwait(false); return; } int body = sum & 7; int fabric = sum >> 5; if (fabric > 7 || ((fabric << 5) | body) != sum) { await ReplyAsync("Invalid customization data specified.").ConfigureAwait(false); return; } var info = ItemRemakeInfoData.List[remake]; // already checked out-of-range body/fabric values above bool hasBody = body == 0 || body <= info.ReBodyPatternNum; bool hasFabric = fabric == 0 || info.GetFabricDescription(fabric) != "Invalid"; if (!hasBody || !hasFabric) { await ReplyAsync("Requested customization for item appears to be invalid.").ConfigureAwait(false); } var item = new Item(itemID) { BodyType = body, PatternChoice = fabric }; var msg = ItemUtil.GetItemText(item); await ReplyAsync(msg).ConfigureAwait(false); }
public async Task StackAsync([Summary("Item ID (in hex)")] string itemHex, [Summary("Count of items in the stack")] int count) { if (!Globals.Bot.Config.AllowLookup) { return; } ushort itemID = ItemUtil.GetID(itemHex); if (itemID == Item.NONE || count < 1 || count > 99) { await ReplyAsync("Invalid item requested.").ConfigureAwait(false); return; } var ct = count - 1; // value 0 => count of 1 var item = new Item(itemID) { Count = (ushort)ct }; var msg = ItemUtil.GetItemText(item); await ReplyAsync(msg).ConfigureAwait(false); }