Skip to content

Commit a49162a

Browse files
committed
Merge PR tcgdex#891 (set_number endpoint changes)
2 parents 8c1a621 + 14789bb commit a49162a

File tree

9 files changed

+33
-24
lines changed

9 files changed

+33
-24
lines changed

data-asia/S/S-P.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ const set: Set = {
1010

1111
serie: serie,
1212

13-
cardCount: {
14-
official: 0
15-
},
1613
releaseDate: {
1714
id: '2022-07-14',
1815
th: '2022-05-11'

data-asia/S/SP5.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ const set: Set = {
99

1010
serie: serie,
1111

12-
cardCount: {
13-
official: 0
14-
},
1512
releaseDate: {
1613
'zh-tw': '2021-08-27'
1714
}

data-asia/SM/SM-P.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ const set: Set = {
99

1010
serie: serie,
1111

12-
cardCount: {
13-
official: 0
14-
},
1512
releaseDate: '2019-10-09'
1613
}
1714

data-asia/SV/SV-P.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ const set: Set = {
1111

1212
serie: serie,
1313

14-
cardCount: {
15-
official: 0
16-
},
1714
releaseDate: {
1815
'zh-tw': '2023-01-26',
1916
id: '2023-03-03',

data/Pokémon TCG Pocket/Promos-A.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ const set: Set = {
1616

1717
serie: serie,
1818

19-
cardCount: {
20-
official: 0
21-
},
22-
2319
boosters: {
2420
vol1: {
2521
name : {

data/Scarlet & Violet/SVP Black Star Promos.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ const set: Set = {
1515

1616
serie: serie,
1717

18-
cardCount: {
19-
official: 0
20-
},
21-
2218
releaseDate: "2023-03-31",
2319

2420
abbreviations: {

meta/definitions/api.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,28 @@ export interface Card extends CardResume {
333333
*/
334334
boosters?: Array<Booster>
335335

336+
/**
337+
* The card set number at the bottom left / right
338+
*/
339+
set_number: {
340+
/**
341+
* The full text of the card number
342+
*/
343+
text: string
344+
/**
345+
* the first part of the no. (if there is no `/` it will include everything)
346+
*/
347+
nominator: string
348+
/**
349+
* a parseable area as a number (ex: 065 = 65, GG55 = 55)
350+
*/
351+
numeric: number
352+
/**
353+
* The second part of the no (skipped if there is no `/`)
354+
*/
355+
denominator?: string
356+
}
357+
336358
updated: string
337359
}
338360

server/compiler/utils/cardUtil.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ export async function cardToCardSingle(localId: string, card: Card, lang: Suppor
168168
})) : undefined,
169169
updated: await getCardLastEdit(localId, card, lang),
170170

171+
set_number: {
172+
text: card.set.cardCount?.official && card.set.cardCount.official > 0 ? `${localId}/${card.set.cardCount.official}` : localId,
173+
nominator: localId.toString(),
174+
numeric: /^\d+$/.test(localId) ? parseInt(localId) : /^\w+?(\d+)$/.test(localId) ? parseInt(RegExp.$1) : undefined,
175+
denominator: card.set.cardCount?.official && card.set.cardCount.official > 0 ? card.set.cardCount.official : undefined
176+
},
177+
171178
thirdParty: card.thirdParty
172179
}
173180
}

server/compiler/utils/setUtil.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ export async function setToSetSimple(set: Set, lang: SupportedLanguages): Promis
7070
const pics = await getSetPictures(set, lang)
7171
return {
7272
cardCount: {
73-
official: set.cardCount.official,
74-
total: Math.max(set.cardCount.official, cards.length)
73+
official: set.cardCount?.official ?? 0, // keep at zero to not break clients
74+
total: Math.max(set.cardCount?.official ?? 0, cards.length)
7575
},
7676
id: set.id,
7777
logo: pics[0],
@@ -106,9 +106,9 @@ export async function setToSetSingle(set: Set, lang: SupportedLanguages): Promis
106106
firstEd: cards.reduce((count, card) => count + getVariantCountForType(card[1],"firstEdition"), 0),
107107
holo: cards.reduce((count, card) => count + getVariantCountForType(card[1],"holo"), 0),
108108
normal: cards.reduce((count, card) => count + getVariantCountForType(card[1],"normal"), 0),
109-
official: set.cardCount.official,
109+
official: set.cardCount?.official ?? 0, // keep at zero to not break clients
110110
reverse: cards.reduce((count, card) => count + getVariantCountForType(card[1],"reverse"), 0),
111-
total: Math.max(set.cardCount.official, cards.length)
111+
total: Math.max(set.cardCount?.official ?? 0, cards.length)
112112
},
113113
cards: await Promise.all(cards.map(([id, card]) => cardToCardSimple(id, card, lang))),
114114
id: set.id,

0 commit comments

Comments
 (0)