1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-06-12 15:59:18 +00:00

feat: Add Scarlet & violet three first sets (#446)
Some checks failed
Build / build (push) Failing after 59s

This commit is contained in:
2023-11-12 14:56:22 +01:00
committed by GitHub
parent e0e3a1a4fd
commit 3c93a3534c
988 changed files with 56362 additions and 22 deletions

View File

@ -1,9 +1,9 @@
/* eslint-disable sort-keys */
import { Card, Set, SupportedLanguages, Types } from '../../../interfaces'
import { CardResume, Card as CardSingle } from '../../../meta/definitions/api'
import { setToSetSimple } from './setUtil'
import { cardIsLegal, DB_PATH, fetchRemoteFile, smartGlob } from './util'
import { Set, SupportedLanguages, Card, Types } from '../../../interfaces'
import { Card as CardSingle, CardResume } from '../../../meta/definitions/api'
import translate from './translationUtil'
import { DB_PATH, cardIsLegal, fetchRemoteFile, smartGlob } from './util'
export async function getCardPictures(cardId: string, card: Card, lang: SupportedLanguages): Promise<string | undefined> {
try {
@ -131,15 +131,18 @@ export async function getCards(lang: SupportedLanguages, set?: Set): Promise<Arr
const cards = await smartGlob(`${DB_PATH}/data/${(set && set.serie.name.en) ?? '*'}/${(set && set.name.en) ?? '*'}/*.js`)
const list: Array<[string, Card]> = []
for (const path of cards) {
const id = path.substring(path.lastIndexOf('/') + 1, path.lastIndexOf('.'))
const setName = (set && set.name.en) ?? (() => {
const part1 = path.substr(0, path.lastIndexOf(id) - 1)
return part1.substr(part1.lastIndexOf('/') + 1)
})()
const serieName = (set && set.serie.name.en) ?? (() => {
const part1 = path.substr(0, path.lastIndexOf(setName) - 1)
return part1.substr(part1.lastIndexOf('/') + 1)
})()
let items = path.split('/')
items = items.slice(items.length - 3)
// get the card id
let id = items[2]
id = id.substring(0, id.lastIndexOf('.'))
// get it's set name
const setName = (set && set.name.en) ?? items[1]
// get it's serie name
const serieName = (set && set.serie.name.en) ?? items[0]
// console.log(path, id, setName)
const c = await getCard(serieName, setName, id)
if (!c.name[lang]) {