Create simple inventory list #120
1 changed files with 8 additions and 2 deletions
|
@ -3,6 +3,7 @@ import Inventory from "../database/entities/app/Inventory";
|
||||||
import { CoreClient } from "../client/client";
|
import { CoreClient } from "../client/client";
|
||||||
import SeriesMetadata, { CardMetadata } from "../contracts/SeriesMetadata";
|
import SeriesMetadata, { CardMetadata } from "../contracts/SeriesMetadata";
|
||||||
import EmbedColours from "../constants/EmbedColours";
|
import EmbedColours from "../constants/EmbedColours";
|
||||||
|
import { CardRarity, CardRarityToString } from "../constants/CardRarity";
|
||||||
|
|
||||||
export default class InventoryHelper {
|
export default class InventoryHelper {
|
||||||
public static async GenerateInventoryPage(userid: string, page: number): Promise<{ embed: EmbedBuilder, row: ActionRowBuilder<ButtonBuilder> }> {
|
public static async GenerateInventoryPage(userid: string, page: number): Promise<{ embed: EmbedBuilder, row: ActionRowBuilder<ButtonBuilder> }> {
|
||||||
|
@ -39,17 +40,21 @@ export default class InventoryHelper {
|
||||||
cardNumber: string,
|
cardNumber: string,
|
||||||
name: string,
|
name: string,
|
||||||
quantity: number,
|
quantity: number,
|
||||||
|
type: CardRarity,
|
||||||
}[],
|
}[],
|
||||||
seriesSubpage: number,
|
seriesSubpage: number,
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
for (let series of seriesToDisplay) {
|
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 cards = series.cards.slice(i, i + cardsPerPage);
|
||||||
const pageCards: {
|
const pageCards: {
|
||||||
cardNumber: string,
|
cardNumber: string,
|
||||||
name: string,
|
name: string,
|
||||||
quantity: number,
|
quantity: number,
|
||||||
|
type: CardRarity,
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
for (let card of cards) {
|
for (let card of cards) {
|
||||||
|
@ -63,6 +68,7 @@ export default class InventoryHelper {
|
||||||
cardNumber: card.id,
|
cardNumber: card.id,
|
||||||
name: card.name,
|
name: card.name,
|
||||||
quantity: item.Quantity,
|
quantity: item.Quantity,
|
||||||
|
type: card.type,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +91,7 @@ export default class InventoryHelper {
|
||||||
const embedDescription: string[] = [];
|
const embedDescription: string[] = [];
|
||||||
|
|
||||||
for (let card of currentPage.cards) {
|
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()
|
const embed = new EmbedBuilder()
|
||||||
|
|
Loading…
Reference in a new issue