# Description - Update the drop mechanic to take currency on drop instead of claim - Update the time until anyone can claim the card to 2 minutes - Remove the restriction that the last drop can only be claimed by the user who dropped it - Now just controlled by the 2 minutes rule #415 ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) # How Has This Been Tested? Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration. # Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that provde my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules Reviewed-on: #428 Reviewed-by: VylpesTester <tester@vylpes.com> Co-authored-by: Ethan Lane <ethan@vylpes.com> Co-committed-by: Ethan Lane <ethan@vylpes.com>
88 lines
No EOL
3.5 KiB
TypeScript
88 lines
No EOL
3.5 KiB
TypeScript
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
|
|
import { DropResult } from "../../contracts/SeriesMetadata";
|
|
import AppLogger from "../../client/appLogger";
|
|
import { CardRarityToColour, CardRarityToString } from "../../constants/CardRarity";
|
|
import StringTools from "../StringTools";
|
|
|
|
export default class DropEmbedHelper {
|
|
public static GenerateDropEmbed(drop: DropResult, quantityClaimed: number, imageFileName: string, claimedBy?: string, currency?: number): EmbedBuilder {
|
|
AppLogger.LogSilly("CardDropHelperMetadata/GenerateDropEmbed", `Parameters: drop=${drop.card.id}, quantityClaimed=${quantityClaimed}, imageFileName=${imageFileName}`);
|
|
|
|
const description = drop.card.subseries ?? drop.series.name;
|
|
let colour = CardRarityToColour(drop.card.type);
|
|
|
|
if (drop.card.colour && StringTools.IsHexCode(drop.card.colour)) {
|
|
const hexCode = Number("0x" + drop.card.colour);
|
|
|
|
if (hexCode) {
|
|
colour = hexCode;
|
|
} else {
|
|
AppLogger.LogWarn("CardDropHelperMetadata/GenerateDropEmbed", `Card's colour override is invalid: ${drop.card.id}, ${drop.card.colour}`);
|
|
}
|
|
} else if (drop.card.colour) {
|
|
AppLogger.LogWarn("CardDropHelperMetadata/GenerateDropEmbed", `Card's colour override is invalid: ${drop.card.id}, ${drop.card.colour}`);
|
|
}
|
|
|
|
let imageUrl = `attachment://${imageFileName}`;
|
|
|
|
if (drop.card.path.startsWith("http://") || drop.card.path.startsWith("https://")) {
|
|
imageUrl = drop.card.path;
|
|
}
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setTitle(drop.card.name)
|
|
.setDescription(description)
|
|
.setFooter({ text: `${CardRarityToString(drop.card.type)} · ${drop.card.id}` })
|
|
.setColor(colour)
|
|
.setImage(imageUrl)
|
|
.addFields([
|
|
{
|
|
name: "Claimed",
|
|
value: `${quantityClaimed}`,
|
|
inline: true,
|
|
}
|
|
]);
|
|
|
|
if (claimedBy != null) {
|
|
embed.addFields([
|
|
{
|
|
name: "Claimed by",
|
|
value: claimedBy,
|
|
inline: true,
|
|
}
|
|
]);
|
|
}
|
|
|
|
if (currency != null) {
|
|
embed.addFields([
|
|
{
|
|
name: "Currency",
|
|
value: `${currency}`,
|
|
inline: true,
|
|
}
|
|
]);
|
|
}
|
|
|
|
return embed;
|
|
}
|
|
|
|
public static GenerateDropButtons(drop: DropResult, claimId: string, userId: string, disabled: boolean = false): ActionRowBuilder<ButtonBuilder> {
|
|
AppLogger.LogSilly("CardDropHelperMetadata/GenerateDropButtons", `Parameters: drop=${drop.card.id}, claimId=${claimId}, userId=${userId}`);
|
|
|
|
return new ActionRowBuilder<ButtonBuilder>()
|
|
.addComponents(
|
|
new ButtonBuilder()
|
|
.setCustomId(`claim ${drop.card.id} ${claimId} ${userId}`)
|
|
.setLabel("Claim")
|
|
.setStyle(ButtonStyle.Success)
|
|
.setDisabled(disabled),
|
|
new ButtonBuilder()
|
|
.setCustomId(`sacrifice confirm ${userId} ${drop.card.id} 1`)
|
|
.setLabel(`Sacrifice`)
|
|
.setStyle(ButtonStyle.Danger),
|
|
new ButtonBuilder()
|
|
.setCustomId("reroll")
|
|
.setEmoji("🔁")
|
|
.setStyle(ButtonStyle.Primary),);
|
|
}
|
|
} |