Create simple inventory list #120

Merged
Vylpes merged 10 commits from feature/97-simple-inventory-list into develop 2023-12-22 14:41:14 +00:00
Showing only changes of commit 366bf08d3e - Show all commits

View file

@ -25,31 +25,17 @@ export default class InventoryHelper {
const inventory = await Inventory.FetchAllByUserId(userid);
const allSeries: SeriesMetadata[] = [];
const allSeriesClaimed = CoreClient.Cards
.sort((a, b) => a.id - b.id)
.filter(x => {
x.cards = x.cards.filter(y => inventory.find(z => z.CardNumber == y.id));
for (let item of inventory) {
const series = CoreClient.Cards.find(x => x.cards.find(y => y.id == item.CardNumber));
if (!series || allSeries.includes(series)) {
continue;
}
allSeries.push(series);
}
const seriesToDisplay: SeriesMetadata[] = [];
for (let series of allSeries.sort((a, b) => a.id - b.id)) {
const seriesCards = series.cards.filter(x => inventory.find(y => y.CardNumber == x.id));
series.cards = seriesCards;
seriesToDisplay.push(series);
}
return x;
});
const pages: InventoryPage[] = [];
for (let series of seriesToDisplay) {
for (let series of allSeriesClaimed) {
const seriesCards = series.cards.sort((a, b) => b.type - a.type);
for (let i = 0; i < seriesCards.length; i+= cardsPerPage) {
@ -87,15 +73,9 @@ export default class InventoryHelper {
return Promise.reject("Unable to find page");
}
const embedDescription: string[] = [];
for (let card of currentPage.cards) {
embedDescription.push(`[${card.id}] ${card.name} (${CardRarityToString(card.type)}) x${card.quantity}`);
}
const embed = new EmbedBuilder()
.setTitle(`${currentPage.name} (${currentPage.seriesSubpage + 1})`)
.setDescription(embedDescription.join('\n'))
.setDescription(currentPage.cards.map(x => `[${x.id}] ${x.name} (${CardRarityToString(x.type)}) x${x.quantity}`).join('\n'))
.setFooter({ text: `Page ${page} of ${pages.length}` })
.setColor(EmbedColours.Ok);