Add ability to sacrifice multiple cards at once #354
1 changed files with 14 additions and 3 deletions
|
@ -16,11 +16,16 @@ export default class Sacrifice extends Command {
|
||||||
x
|
x
|
||||||
.setName("cardnumber")
|
.setName("cardnumber")
|
||||||
.setDescription("The card to sacrifice from your inventory")
|
.setDescription("The card to sacrifice from your inventory")
|
||||||
.setRequired(true));
|
.setRequired(true))
|
||||||
|
.addNumberOption(x =>
|
||||||
|
x
|
||||||
|
.setName("quantity")
|
||||||
|
.setDescription("The amount to sacrifice (default 1)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async execute(interaction: CommandInteraction<CacheType>): Promise<void> {
|
public override async execute(interaction: CommandInteraction<CacheType>): Promise<void> {
|
||||||
const cardnumber = interaction.options.get("cardnumber", true);
|
const cardnumber = interaction.options.get("cardnumber", true);
|
||||||
|
const quantity = interaction.options.get("quantity")?.value as number ?? 1;
|
||||||
Vylpes marked this conversation as resolved
Outdated
|
|||||||
|
|
||||||
const cardInInventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, cardnumber.value! as string);
|
const cardInInventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, cardnumber.value! as string);
|
||||||
|
|
||||||
|
@ -29,6 +34,11 @@ export default class Sacrifice extends Command {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cardInInventory.Quantity < quantity) {
|
||||||
|
await interaction.reply(`You can only sacrifice what you own! You have ${cardInInventory.Quantity} of this card`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const cardData = CardDropHelperMetadata.GetCardByCardNumber(cardnumber.value! as string);
|
const cardData = CardDropHelperMetadata.GetCardByCardNumber(cardnumber.value! as string);
|
||||||
|
|
||||||
if (!cardData) {
|
if (!cardData) {
|
||||||
|
@ -44,6 +54,7 @@ export default class Sacrifice extends Command {
|
||||||
`Series: ${cardData.series.name}`,
|
`Series: ${cardData.series.name}`,
|
||||||
`Rarity: ${cardRarityString}`,
|
`Rarity: ${cardRarityString}`,
|
||||||
`Quantity Owned: ${cardInInventory.Quantity}`,
|
`Quantity Owned: ${cardInInventory.Quantity}`,
|
||||||
|
`Quantity To Sacrifice: ${quantity}`,
|
||||||
`Sacrifice Amount: ${cardValue}`,
|
`Sacrifice Amount: ${cardValue}`,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -56,11 +67,11 @@ export default class Sacrifice extends Command {
|
||||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||||
.addComponents([
|
.addComponents([
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId(`sacrifice confirm ${interaction.user.id} ${cardnumber.value!}`)
|
.setCustomId(`sacrifice confirm ${interaction.user.id} ${cardnumber.value!} ${quantity}`)
|
||||||
.setLabel("Confirm")
|
.setLabel("Confirm")
|
||||||
.setStyle(ButtonStyle.Success),
|
.setStyle(ButtonStyle.Success),
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId(`sacrifice cancel ${interaction.user.id} ${cardnumber.value!}`)
|
.setCustomId(`sacrifice cancel ${interaction.user.id} ${cardnumber.value!} ${quantity}`)
|
||||||
.setLabel("Cancel")
|
.setLabel("Cancel")
|
||||||
.setStyle(ButtonStyle.Secondary),
|
.setStyle(ButtonStyle.Secondary),
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in a new issue
Same here