mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-07-29 11:09:51 +00:00
Update interfaces
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
import { Page } from "puppeteer-core"
|
||||
|
||||
enum Rarity {
|
||||
Common,
|
||||
Uncommon,
|
||||
@ -22,15 +20,54 @@ enum Rarity {
|
||||
LEGEND,
|
||||
}
|
||||
|
||||
const en = [
|
||||
"Common",
|
||||
"unCommon",
|
||||
"Rare",
|
||||
|
||||
"Rare Holo",
|
||||
"Rare Holo EX",
|
||||
"Rare Holo GX",
|
||||
"Rare Holo Lv.X",
|
||||
|
||||
"Rare Ultra",
|
||||
"Rare Prime",
|
||||
"Rare ACE",
|
||||
"Rare BREAK",
|
||||
"Rainbow Rare",
|
||||
|
||||
"LEGEND"
|
||||
]
|
||||
|
||||
const fr = [
|
||||
"Commun",
|
||||
"Non Commun",
|
||||
"Rare",
|
||||
|
||||
"Rare Holo",
|
||||
"Rare Holo EX",
|
||||
"Rare Holo GX",
|
||||
"Rare Holo Lv.X",
|
||||
|
||||
"Rare Ultra",
|
||||
"Rare Prime",
|
||||
"Rare ACE",
|
||||
"Rare BREAK",
|
||||
"Rainbow Rare",
|
||||
|
||||
"LEGEND"
|
||||
]
|
||||
|
||||
namespace Rarity {
|
||||
|
||||
export async function getRarity(tab: Page): Promise<Rarity> {
|
||||
const rarity = await tab.$eval(".stats-footer span", (el: HTMLElement) => {
|
||||
const arr = el.innerText.split(" ")
|
||||
arr.shift()
|
||||
return arr.join(" ")
|
||||
})
|
||||
return getLocalRarity(rarity)
|
||||
export function toLang(r: Rarity, lang: string): string {
|
||||
switch (lang) {
|
||||
case "en":
|
||||
return en[r]
|
||||
case "fr":
|
||||
return fr[r]
|
||||
}
|
||||
throw new Error(`Error, rarity lang not found! (${lang})`)
|
||||
}
|
||||
|
||||
export function getLocalRarity(str?: string): Rarity {
|
||||
|
Reference in New Issue
Block a user