Update drop mechanic to take currency on drop instead of claim
This commit is contained in:
parent
5089ad6ab6
commit
f98f15b06a
4 changed files with 15 additions and 14 deletions
|
@ -36,11 +36,6 @@ export default class Claim extends ButtonEvent {
|
||||||
|
|
||||||
AppLogger.LogSilly("Button/Claim", `${user.Id} has ${user.Currency} currency`);
|
AppLogger.LogSilly("Button/Claim", `${user.Id} has ${user.Currency} currency`);
|
||||||
|
|
||||||
if (!user.RemoveCurrency(CardConstants.ClaimCost)) {
|
|
||||||
await interaction.channel.send(`${interaction.user}, Not enough currency! You need ${CardConstants.ClaimCost} currency, you have ${user.Currency}!`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const claimed = await eClaim.FetchOneByClaimId(claimId);
|
const claimed = await eClaim.FetchOneByClaimId(claimId);
|
||||||
|
|
||||||
if (claimed) {
|
if (claimed) {
|
||||||
|
@ -53,8 +48,6 @@ export default class Claim extends ButtonEvent {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await user.Save(User, user);
|
|
||||||
|
|
||||||
let inventory = await Inventory.FetchOneByCardNumberAndUserId(userId, cardNumber);
|
let inventory = await Inventory.FetchOneByCardNumberAndUserId(userId, cardNumber);
|
||||||
|
|
||||||
if (!inventory) {
|
if (!inventory) {
|
||||||
|
|
|
@ -35,11 +35,13 @@ export default class Reroll extends ButtonEvent {
|
||||||
AppLogger.LogInfo("Commands/Drop", `New user (${interaction.user.id}) saved to the database`);
|
AppLogger.LogInfo("Commands/Drop", `New user (${interaction.user.id}) saved to the database`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Currency < CardConstants.ClaimCost) {
|
if (!user.RemoveCurrency(CardConstants.ClaimCost)) {
|
||||||
await interaction.reply(`Not enough currency! You need ${CardConstants.ClaimCost} currency, you have ${user.Currency}!`);
|
await interaction.reply(`Not enough currency! You need ${CardConstants.ClaimCost} currency, you have ${user.Currency}!`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await user.Save(User, user);
|
||||||
|
|
||||||
const randomCard = await GetCardsHelper.FetchCard(interaction.user.id);
|
const randomCard = await GetCardsHelper.FetchCard(interaction.user.id);
|
||||||
|
|
||||||
if (!randomCard) {
|
if (!randomCard) {
|
||||||
|
|
|
@ -43,11 +43,13 @@ export default class Drop extends Command {
|
||||||
AppLogger.LogInfo("Commands/Drop", `New user (${interaction.user.id}) saved to the database`);
|
AppLogger.LogInfo("Commands/Drop", `New user (${interaction.user.id}) saved to the database`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Currency < CardConstants.ClaimCost) {
|
if (!user.RemoveCurrency(CardConstants.ClaimCost)) {
|
||||||
await interaction.reply(ErrorMessages.NotEnoughCurrency(CardConstants.ClaimCost, user.Currency));
|
await interaction.reply(ErrorMessages.NotEnoughCurrency(CardConstants.ClaimCost, user.Currency));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await user.Save(User, user);
|
||||||
|
|
||||||
const randomCard = await GetCardsHelper.FetchCard(interaction.user.id);
|
const randomCard = await GetCardsHelper.FetchCard(interaction.user.id);
|
||||||
|
|
||||||
if (!randomCard) {
|
if (!randomCard) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
|
||||||
import { DropResult } from "../../contracts/SeriesMetadata";
|
import { DropResult } from "../../contracts/SeriesMetadata";
|
||||||
import AppLogger from "../../client/appLogger";
|
import AppLogger from "../../client/appLogger";
|
||||||
import { CardRarityToColour, CardRarityToString } from "../../constants/CardRarity";
|
import { CardRarityToColour, CardRarityToString, GetSacrificeAmount } from "../../constants/CardRarity";
|
||||||
import StringTools from "../StringTools";
|
import StringTools from "../StringTools";
|
||||||
import CardConstants from "../../constants/CardConstants";
|
import CardConstants from "../../constants/CardConstants";
|
||||||
|
|
||||||
|
@ -74,12 +74,16 @@ export default class DropEmbedHelper {
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId(`claim ${drop.card.id} ${claimId} ${userId}`)
|
.setCustomId(`claim ${drop.card.id} ${claimId} ${userId}`)
|
||||||
.setLabel(`Claim (${CardConstants.ClaimCost} 🪙)`)
|
.setLabel("Claim")
|
||||||
.setStyle(ButtonStyle.Primary)
|
.setStyle(ButtonStyle.Success)
|
||||||
.setDisabled(disabled),
|
.setDisabled(disabled),
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId(`sacrifice confirm ${userId} ${drop.card.id} 1`)
|
||||||
|
.setLabel(`Sacrifice`)
|
||||||
|
.setStyle(ButtonStyle.Danger),
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId("reroll")
|
.setCustomId("reroll")
|
||||||
.setLabel("Reroll")
|
.setEmoji("🔁")
|
||||||
.setStyle(ButtonStyle.Secondary));
|
.setStyle(ButtonStyle.Primary),);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue