Add card type to list

This commit is contained in:
Ethan Lane 2023-12-19 14:59:56 +00:00
parent f475f5fb42
commit c8a4fe25d1

View file

@ -3,6 +3,7 @@ import Inventory from "../database/entities/app/Inventory";
import { CoreClient } from "../client/client";
import SeriesMetadata, { CardMetadata } from "../contracts/SeriesMetadata";
import EmbedColours from "../constants/EmbedColours";
import { CardRarity, CardRarityToString } from "../constants/CardRarity";
export default class InventoryHelper {
public static async GenerateInventoryPage(userid: string, page: number): Promise<{ embed: EmbedBuilder, row: ActionRowBuilder<ButtonBuilder> }> {
@ -39,17 +40,21 @@ export default class InventoryHelper {
cardNumber: string,
name: string,
quantity: number,
type: CardRarity,
}[],
seriesSubpage: number,
}[] = [];
for (let series of seriesToDisplay) {
for (let i = 0; i < series.cards.length; i+= cardsPerPage) {
const seriesCards = series.cards.sort((a, b) => b.type - a.type);
for (let i = 0; i < seriesCards.length; i+= cardsPerPage) {
const cards = series.cards.slice(i, i + cardsPerPage);
const pageCards: {
cardNumber: string,
name: string,
quantity: number,
type: CardRarity,
}[] = [];
for (let card of cards) {
@ -63,6 +68,7 @@ export default class InventoryHelper {
cardNumber: card.id,
name: card.name,
quantity: item.Quantity,
type: card.type,
});
}
@ -85,7 +91,7 @@ export default class InventoryHelper {
const embedDescription: string[] = [];
for (let card of currentPage.cards) {
embedDescription.push(`[${card.cardNumber}] ${card.name} (${card.quantity})`);
embedDescription.push(`[${card.cardNumber}] ${card.name} (${CardRarityToString(card.type)}) x${card.quantity}`);
}
const embed = new EmbedBuilder()