Compare commits
No commits in common. "f086ca4bdaa0be6cf8a62df6f14c6a756148157e" and "9f5042d696a887cdb8e0724d181b730b97437a60" have entirely different histories.
f086ca4bda
...
9f5042d696
2 changed files with 6 additions and 20 deletions
|
@ -23,7 +23,6 @@ export default class Sacrifice extends ButtonEvent {
|
|||
private async confirm(interaction: ButtonInteraction) {
|
||||
const userId = interaction.customId.split(" ")[2];
|
||||
const cardNumber = interaction.customId.split(" ")[3];
|
||||
const quantity = Number(interaction.customId.split(" ")[4]) ?? 1;
|
||||
|
||||
if (userId != interaction.user.id) {
|
||||
await interaction.reply("Only the user who created this sacrifice can confirm it.");
|
||||
|
@ -32,16 +31,11 @@ export default class Sacrifice extends ButtonEvent {
|
|||
|
||||
const cardInInventory = await Inventory.FetchOneByCardNumberAndUserId(userId, cardNumber);
|
||||
|
||||
if (!cardInInventory || cardInInventory.Quantity == 0) {
|
||||
if (!cardInInventory) {
|
||||
await interaction.reply("Unable to find card in inventory.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cardInInventory.Quantity < quantity) {
|
||||
await interaction.reply("You can only sacrifice what you own.");
|
||||
return;
|
||||
}
|
||||
|
||||
const cardData = CardDropHelperMetadata.GetCardByCardNumber(cardNumber);
|
||||
|
||||
if (!cardData) {
|
||||
|
@ -56,11 +50,11 @@ export default class Sacrifice extends ButtonEvent {
|
|||
return;
|
||||
}
|
||||
|
||||
cardInInventory.RemoveQuantity(quantity);
|
||||
cardInInventory.RemoveQuantity(1);
|
||||
|
||||
await cardInInventory.Save(Inventory, cardInInventory);
|
||||
|
||||
const cardValue = GetSacrificeAmount(cardData.card.type) * quantity;
|
||||
const cardValue = GetSacrificeAmount(cardData.card.type);
|
||||
const cardRarityString = CardRarityToString(cardData.card.type);
|
||||
|
||||
user.AddCurrency(cardValue);
|
||||
|
@ -72,7 +66,6 @@ export default class Sacrifice extends ButtonEvent {
|
|||
`Series: ${cardData.series.name}`,
|
||||
`Rarity: ${cardRarityString}`,
|
||||
`Quantity Owned: ${cardInInventory.Quantity}`,
|
||||
`Quantity To Sacrifice: ${quantity}`,
|
||||
`Sacrifice Amount: ${cardValue}`,
|
||||
];
|
||||
|
||||
|
@ -105,7 +98,6 @@ export default class Sacrifice extends ButtonEvent {
|
|||
private async cancel(interaction: ButtonInteraction) {
|
||||
const userId = interaction.customId.split(" ")[2];
|
||||
const cardNumber = interaction.customId.split(" ")[3];
|
||||
const quantity = Number(interaction.customId.split(" ")[4]) ?? 1;
|
||||
|
||||
if (userId != interaction.user.id) {
|
||||
await interaction.reply("Only the user who created this sacrifice can cancel it.");
|
||||
|
@ -114,16 +106,11 @@ export default class Sacrifice extends ButtonEvent {
|
|||
|
||||
const cardInInventory = await Inventory.FetchOneByCardNumberAndUserId(userId, cardNumber);
|
||||
|
||||
if (!cardInInventory || cardInInventory.Quantity == 0) {
|
||||
if (!cardInInventory) {
|
||||
await interaction.reply("Unable to find card in inventory.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cardInInventory.Quantity < quantity) {
|
||||
await interaction.reply("You can only sacrifice what you own.");
|
||||
return;
|
||||
}
|
||||
|
||||
const cardData = CardDropHelperMetadata.GetCardByCardNumber(cardNumber);
|
||||
|
||||
if (!cardData) {
|
||||
|
@ -131,7 +118,7 @@ export default class Sacrifice extends ButtonEvent {
|
|||
return;
|
||||
}
|
||||
|
||||
const cardValue = GetSacrificeAmount(cardData.card.type) * quantity;
|
||||
const cardValue = GetSacrificeAmount(cardData.card.type);
|
||||
const cardRarityString = CardRarityToString(cardData.card.type);
|
||||
|
||||
const description = [
|
||||
|
@ -139,7 +126,6 @@ export default class Sacrifice extends ButtonEvent {
|
|||
`Series: ${cardData.series.name}`,
|
||||
`Rarity: ${cardRarityString}`,
|
||||
`Quantity Owned: ${cardInInventory.Quantity}`,
|
||||
`Quantity To Sacrifice: ${quantity}`,
|
||||
`Sacrifice Amount: ${cardValue}`,
|
||||
];
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ export default class Sacrifice extends Command {
|
|||
return;
|
||||
}
|
||||
|
||||
const cardValue = GetSacrificeAmount(cardData.card.type) * quantity;
|
||||
const cardValue = GetSacrificeAmount(cardData.card.type);
|
||||
const cardRarityString = CardRarityToString(cardData.card.type);
|
||||
|
||||
const description = [
|
||||
|
|
Loading…
Reference in a new issue