mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-08-15 01:41:59 +00:00
Compare commits
1 Commits
decks-supp
...
v2.15.2
Author | SHA1 | Date | |
---|---|---|---|
b4dbdef4fa |
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Base Set 2"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base4.gc",
|
||||
name: {
|
||||
en: "Grass Chopper"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Fighting", "Grass"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Base Set 2"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base4.hw",
|
||||
name: {
|
||||
en: "Hot Water"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Fire", "Water"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Base Set 2"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base4.lg",
|
||||
name: {
|
||||
en: "Lightning Bug"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Lightning", "Grass"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Base Set 2"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base4.po",
|
||||
name: {
|
||||
en: "Psych Out"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Psychic", "Water"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Base Set"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base1.bl",
|
||||
name: {
|
||||
en: "Blackout"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Water", "Fighting"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Base Set"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base1.br",
|
||||
name: {
|
||||
en: "Brushfire"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Fire", "Grass"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Base Set"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base1.ov",
|
||||
name: {
|
||||
en: "Overgrowth"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Water", "Grass"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Base Set"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base1.za",
|
||||
name: {
|
||||
en: "Zap!"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Lightning", "Psychic"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Fossil"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base1.bd",
|
||||
name: {
|
||||
en: "BodyGuard"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Grass", "Fighting"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Base Set"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base1.ld",
|
||||
name: {
|
||||
en: "LockDown"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Fire", "Water"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Jungle"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base2.pr",
|
||||
name: {
|
||||
en: "Power Reserve"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Psychic", "Grass"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Jungle"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base2.wb",
|
||||
name: {
|
||||
en: "Water Blast"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Water", "Fighting"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Team Rocket"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base4.de",
|
||||
name: {
|
||||
en: "Devastation"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Grass", "Water"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,14 +0,0 @@
|
||||
import { Deck } from "../../../../interfaces"
|
||||
import Set from "../../Team Rocket"
|
||||
|
||||
const deck: Deck = {
|
||||
id: "td.base4.to",
|
||||
name: {
|
||||
en: "Trouble"
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ["Psychic", "Grass"],
|
||||
cards: []
|
||||
}
|
||||
|
||||
export default deck
|
@@ -1,40 +0,0 @@
|
||||
import { Deck } from '../../../../interfaces'
|
||||
import Set from "../../Noble Victories"
|
||||
|
||||
const deck: Deck = {
|
||||
id: 'td.bw3.fd',
|
||||
name: {
|
||||
en: 'Fast Daze'
|
||||
},
|
||||
set: Set,
|
||||
typesFocus: ['Fire', 'Grass'],
|
||||
cards: [
|
||||
{ id: 'bw3-12', variant: 'holo' },
|
||||
'bw3-12',
|
||||
{ id: 'bw3-11', quantity: 4 },
|
||||
'bw3-3',
|
||||
{ id: 'bw3-2', quantity: 2 },
|
||||
{ id: 'bw3-1', quantity: 3 },
|
||||
'bw3-5',
|
||||
{ id: 'bw3-4', quantity: 2 },
|
||||
{ id: 'bw3-7', quantity: 2 },
|
||||
{ id: 'bw3-6', quantity: 2 },
|
||||
{ id: 'bw3-9', quantity: 3 },
|
||||
'bw3-21',
|
||||
{ id: 'bw3-21', quantity: 2 },
|
||||
{ id: 'bw3-17', quantity: 2 },
|
||||
{ id: 'bw3-16', quantity: 2 },
|
||||
{ id: 'bw3-7', quantity: 2 },
|
||||
{ id: 'bw1-93', quantity: 2 },
|
||||
{ id: 'bw1-100', quantity: 2 },
|
||||
{ id: 'bw2-91', quantity: 2 },
|
||||
{ id: 'bw2-91', quantity: 2 },
|
||||
'bw3-92',
|
||||
{ id: 'bw1-99', quantity: 2 },
|
||||
{ id: 'bw3-95', quantity: 2 },
|
||||
{ id: 'bw1-105', quantity: 12 },
|
||||
{ id: 'bw1-106', quantity: 6 }
|
||||
]
|
||||
}
|
||||
|
||||
export default deck
|
21
interfaces.d.ts
vendored
21
interfaces.d.ts
vendored
@@ -314,24 +314,3 @@ export interface Filter {
|
||||
cards: Array<string>
|
||||
}
|
||||
}
|
||||
|
||||
export interface Deck {
|
||||
id: `td.${string}.${string}`
|
||||
set: Set
|
||||
name: Languages
|
||||
typesFocus: Array<Types>
|
||||
cards: Array<{
|
||||
/**
|
||||
* Card Global ID
|
||||
*/
|
||||
id: string
|
||||
/**
|
||||
* Card quantity in the deck
|
||||
*/
|
||||
quantity?: number
|
||||
/**
|
||||
* Card variant
|
||||
*/
|
||||
variant?: keyof Omit<variants, 'normal' | 'firstEdition'>
|
||||
} | string>
|
||||
}
|
||||
|
@@ -63,12 +63,13 @@ export function betterSorter(a: string, b: string) {
|
||||
*/
|
||||
export function validateItem(validator: any | Array<any>, value: any): boolean {
|
||||
if (typeof value === 'object') {
|
||||
return objectLoop(value, (v) => {
|
||||
// invert signal so that an early exit mean that a match was found!
|
||||
return !objectLoop(value, (v) => {
|
||||
// early exit to not infinitively loop through objects
|
||||
if (typeof v === 'object') return true
|
||||
|
||||
// check for each childs
|
||||
return validateItem(validator, v)
|
||||
// check for each childs until one match
|
||||
return !validateItem(validator, v)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -104,10 +105,14 @@ export function validateItem(validator: any | Array<any>, value: any): boolean {
|
||||
* @returns the sorted data
|
||||
*/
|
||||
export function handleSort(data: Array<any>, query: Query<any>) {
|
||||
const sort: Query<any>['sort'] = query.sort ?? {field: 'id', order: 'ASC'}
|
||||
// handle when data has no entries
|
||||
if (data.length === 0) {
|
||||
return data
|
||||
}
|
||||
const firstEntry = data[0]
|
||||
const sort: Query<any>['sort'] = query.sort ?? {field: 'releaseDate' in firstEntry ? 'releaseDate' : 'id', order: 'ASC'}
|
||||
const field = sort.field
|
||||
const order = sort.order ?? 'ASC'
|
||||
const firstEntry = data[0]
|
||||
|
||||
// early exit if the order is not correctly set
|
||||
if (order !== 'ASC' && order !== 'DESC') {
|
||||
@@ -142,7 +147,7 @@ export function handleSort(data: Array<any>, query: Query<any>) {
|
||||
* @returns the data that is in the paginated query
|
||||
*/
|
||||
export function handlePagination(data: Array<any>, query: Query<any>) {
|
||||
if (!query.pagination) {
|
||||
if (!query.pagination || data.length === 0) {
|
||||
return data
|
||||
}
|
||||
const itemsPerPage = query.pagination.itemsPerPage ?? 100
|
||||
|
Reference in New Issue
Block a user