Compare commits
1 commit
main
...
feature/CD
Author | SHA1 | Date | |
---|---|---|---|
9d93b9b95e |
3 changed files with 34 additions and 4 deletions
|
@ -68,7 +68,7 @@ export default class Claim extends ButtonEvent {
|
|||
const imageFileName = card.card.path.split("/").pop()!;
|
||||
|
||||
const embed = DropEmbedHelper.GenerateDropEmbed(card, inventory.Quantity, imageFileName, interaction.user.username, user.Currency);
|
||||
const row = DropEmbedHelper.GenerateDropButtons(card, claimId, interaction.user.id, true);
|
||||
const row = DropEmbedHelper.GenerateDropButtons(card, claimId, interaction.user.id, true, false);
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [ embed ],
|
||||
|
|
|
@ -12,9 +12,18 @@ import CardConstants from "../constants/CardConstants";
|
|||
import GetCardsHelper from "../helpers/DropHelpers/GetCardsHelper";
|
||||
import DropEmbedHelper from "../helpers/DropHelpers/DropEmbedHelper";
|
||||
import {DropResult} from "../contracts/SeriesMetadata";
|
||||
import {GetSacrificeAmount} from "../constants/CardRarity";
|
||||
|
||||
export default class Reroll extends ButtonEvent {
|
||||
public override async execute(interaction: ButtonInteraction) {
|
||||
const cardId = interaction.customId.split(" ")[1];
|
||||
const doSacrifice = interaction.customId.split(" ")[2] == "true";
|
||||
|
||||
if (!cardId) {
|
||||
AppLogger.LogError("Button/Reroll", "cardId is undefined");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CoreClient.AllowDrops) {
|
||||
await interaction.reply("Bot is currently syncing, please wait until its done.");
|
||||
return;
|
||||
|
@ -36,6 +45,26 @@ export default class Reroll extends ButtonEvent {
|
|||
AppLogger.LogInfo("Button/Reroll", `New user (${interaction.user.id}) saved to the database`);
|
||||
}
|
||||
|
||||
// Sacrifice current card
|
||||
if (doSacrifice) {
|
||||
const cardData = GetCardsHelper.GetCardByCardNumber(cardId);
|
||||
|
||||
if (!cardData) {
|
||||
await interaction.reply("Unable to find card in the database.");
|
||||
return;
|
||||
}
|
||||
|
||||
const oldRow = DropEmbedHelper.GenerateDropButtons(cardData, "", interaction.user.id, true, false);
|
||||
|
||||
interaction.message.edit({
|
||||
components: [ oldRow ],
|
||||
});
|
||||
|
||||
const sacrificeAmount = GetSacrificeAmount(cardData.card.type);
|
||||
user.AddCurrency(sacrificeAmount);
|
||||
}
|
||||
|
||||
// Generate new card
|
||||
if (!user.RemoveCurrency(CardConstants.ClaimCost)) {
|
||||
await interaction.reply(`Not enough currency! You need ${CardConstants.ClaimCost} currency, you have ${user.Currency}!`);
|
||||
return;
|
||||
|
|
|
@ -66,7 +66,7 @@ export default class DropEmbedHelper {
|
|||
return embed;
|
||||
}
|
||||
|
||||
public static GenerateDropButtons(drop: DropResult, claimId: string, userId: string, disabled: boolean = false): ActionRowBuilder<ButtonBuilder> {
|
||||
public static GenerateDropButtons(drop: DropResult, claimId: string, userId: string, disabled: boolean = false, doSacrifice: boolean = true): ActionRowBuilder<ButtonBuilder> {
|
||||
AppLogger.LogSilly("CardDropHelperMetadata/GenerateDropButtons", `Parameters: drop=${drop.card.id}, claimId=${claimId}, userId=${userId}`);
|
||||
|
||||
return new ActionRowBuilder<ButtonBuilder>()
|
||||
|
@ -79,9 +79,10 @@ export default class DropEmbedHelper {
|
|||
new ButtonBuilder()
|
||||
.setCustomId(`sacrifice give ${userId} ${drop.card.id} 1`)
|
||||
.setLabel(`Sacrifice`)
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
.setDisabled(disabled),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("reroll")
|
||||
.setCustomId(`reroll ${drop.card.id} ${doSacrifice}`)
|
||||
.setEmoji("🔁")
|
||||
.setStyle(ButtonStyle.Primary),);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue