1
|
|
import { capitalize } from "../../utils"
|
2
|
|
|
3
|
|
export class Card {
|
4
|
|
oracleId: string
|
5
|
|
language: string
|
6
|
|
identities: string[]
|
7
|
|
handModifier: string
|
8
|
|
layout: string
|
9
|
|
legalities: {
|
10
|
|
format: string
|
11
|
|
legality: string
|
12
|
|
}[]
|
13
|
|
|
14
|
|
lifeModifier: string
|
15
|
|
cost: string
|
16
|
|
text: string
|
17
|
|
type: string
|
18
|
|
border: string
|
19
|
|
number: string
|
20
|
|
flavorText: string
|
21
|
|
frame: string
|
22
|
|
fullArt: string
|
23
|
|
rarity: string
|
24
|
|
printedName: string
|
25
|
|
printedText: string
|
26
|
|
printedType: string;
|
27
|
|
[prop: string]: any
|
28
|
|
|
29
|
|
constructor({
|
30
|
|
oracle_id: oracleId,
|
31
|
|
lang,
|
32
|
|
color_identity: identities,
|
33
|
|
hand_modifier: handModifier,
|
34
|
|
layout,
|
35
|
|
legalities,
|
36
|
|
life_modifier: lifeModifier,
|
37
|
|
mana_cost: cost,
|
38
|
|
oracle_text: text,
|
39
|
|
type_line: type,
|
40
|
|
border_color: border,
|
41
|
|
collector_number: number,
|
42
|
|
flavor_text: flavorText,
|
43
|
|
frame,
|
44
|
|
full_art: fullArt,
|
45
|
|
rarity,
|
46
|
|
printed_name: printedName,
|
47
|
|
printed_text: printedText,
|
48
|
|
printed_type_line: printedType,
|
49
|
|
...rest
|
50
|
|
}: Record<any, any>) {
|
51
|
0
|
this.oracleId = oracleId
|
52
|
0
|
this.language = lang
|
53
|
0
|
this.identities = identities
|
54
|
0
|
this.handModifier = handModifier
|
55
|
0
|
this.layout = layout
|
56
|
|
.split(`_`)
|
57
|
0
|
.map((name: string) => capitalize(name))
|
58
|
|
.join(``)
|
59
|
|
|
60
|
0
|
this.legalities = Object.entries(legalities).map(([format, legality]) => {
|
61
|
1
|
const key = format === `1v1` ? `CommanderVersus` : capitalize(format)
|
62
|
|
const value =
|
63
|
1
|
legality === `not_legal` ? `Illegal` : capitalize(legality as string)
|
64
|
|
|
65
|
0
|
return { format: key, legality: value }
|
66
|
|
})
|
67
|
|
|
68
|
0
|
this.lifeModifier = lifeModifier
|
69
|
0
|
this.cost = cost
|
70
|
0
|
this.text = text
|
71
|
0
|
this.type = type
|
72
|
0
|
this.border = capitalize(border)
|
73
|
0
|
this.number = number
|
74
|
0
|
this.flavorText = flavorText
|
75
|
|
|
76
|
0
|
const frames: Record<string, string> = {
|
77
|
|
1993: `Original`,
|
78
|
|
1997: `Classic`,
|
79
|
|
2003: `Modern`,
|
80
|
|
2015: `Holofoil`,
|
81
|
|
future: `Future`
|
82
|
|
}
|
83
|
|
|
84
|
0
|
this.frame = frames[frame]
|
85
|
0
|
this.fullArt = fullArt
|
86
|
0
|
this.rarity = capitalize(rarity)
|
87
|
0
|
this.printedName = printedName
|
88
|
0
|
this.printedText = printedText
|
89
|
0
|
this.printedType = printedType
|
90
|
|
|
91
|
0
|
for (const [prop, value] of Object.entries(rest)) {
|
92
|
0
|
this[prop] = value
|
93
|
|
}
|
94
|
|
}
|
95
|
|
}
|