@flesh-and-blood/types 3.9.7 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/cards.js +140 -0
- package/dist/helpers/index.js +2 -0
- package/dist/helpers/printings.js +432 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +3 -1
- package/dist/interfaces.js +492 -0
- package/dist/sets.js +2113 -0
- package/package.json +29 -5
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Type, Keyword, Subtype, Trait } from "../interfaces";
|
|
2
|
+
const getCardIdentifier = (card, useNumber) => {
|
|
3
|
+
const { name: unformattedName, pitch } = card;
|
|
4
|
+
const name = unformattedName.trim().toLowerCase().replace("//", "-").normalize("NFD").replace(/\p{Diacritic}/gu, "").replace(/ /g, "-").replace("\xF0", "d").replace("\u0111", "d").replace("\xED", "i").replace(/[^a-z0-9 -]/g, "").replace(/--/, "-");
|
|
5
|
+
let suffix = "";
|
|
6
|
+
switch (pitch) {
|
|
7
|
+
case "1":
|
|
8
|
+
case 1:
|
|
9
|
+
suffix = useNumber ? "-1" : "-red";
|
|
10
|
+
break;
|
|
11
|
+
case "2":
|
|
12
|
+
case 2:
|
|
13
|
+
suffix = useNumber ? "-2" : "-yellow";
|
|
14
|
+
break;
|
|
15
|
+
case "3":
|
|
16
|
+
case 3:
|
|
17
|
+
suffix = useNumber ? "-3" : "-blue";
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
return `${name}${suffix}`;
|
|
21
|
+
};
|
|
22
|
+
const getCardFromGEMCardIdentifier = (gemCardIdentifier, cards) => {
|
|
23
|
+
let exactMatch;
|
|
24
|
+
let fallbackMatch;
|
|
25
|
+
const identifierParts = gemCardIdentifier.split("-");
|
|
26
|
+
const cardIdentifierGuess = identifierParts.map((part) => {
|
|
27
|
+
const shouldReplaceNumberWithColor = ["1", "2", "3"].some(
|
|
28
|
+
(pitch) => pitch === part
|
|
29
|
+
);
|
|
30
|
+
return shouldReplaceNumberWithColor ? part.replace("1", "red").replace("2", "yellow").replace("3", "blue") : part;
|
|
31
|
+
}).join("-");
|
|
32
|
+
for (const card of cards) {
|
|
33
|
+
const { cardIdentifier, oppositeSideCardIdentifiers } = card;
|
|
34
|
+
const matchesExactly = cardIdentifier === cardIdentifierGuess;
|
|
35
|
+
if (matchesExactly) {
|
|
36
|
+
exactMatch = card;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
const matchesDoubleSidedGuess = oppositeSideCardIdentifiers?.some(
|
|
40
|
+
(oppositeSideCardIdentifier) => `${cardIdentifier}--${oppositeSideCardIdentifier}` === cardIdentifierGuess
|
|
41
|
+
);
|
|
42
|
+
if (matchesDoubleSidedGuess) {
|
|
43
|
+
fallbackMatch = card;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return exactMatch || fallbackMatch;
|
|
47
|
+
};
|
|
48
|
+
const getFrontAndBackCardIdentifier = (card, cardBack, useNumber) => {
|
|
49
|
+
const cardFrontIdentifier = getCardIdentifier(card, useNumber);
|
|
50
|
+
const cardBackIdentifier = cardBack ? getCardIdentifier(cardBack, useNumber) : "";
|
|
51
|
+
const joiner = cardBackIdentifier ? "--" : "";
|
|
52
|
+
return `${cardFrontIdentifier}${joiner}${cardBackIdentifier}`;
|
|
53
|
+
};
|
|
54
|
+
const getIsArenaCard = ({
|
|
55
|
+
keywords,
|
|
56
|
+
traits,
|
|
57
|
+
types
|
|
58
|
+
}) => {
|
|
59
|
+
const isDeckCard = getIsDeckCard({ keywords, traits, types });
|
|
60
|
+
const isToken = getIsCardTokenForDeck({
|
|
61
|
+
keywords,
|
|
62
|
+
traits,
|
|
63
|
+
types
|
|
64
|
+
});
|
|
65
|
+
const isInventoryCardType = [
|
|
66
|
+
Type.Companion,
|
|
67
|
+
Type.DemiHero,
|
|
68
|
+
Type.Equipment,
|
|
69
|
+
Type.Weapon
|
|
70
|
+
].some((type) => types.includes(type));
|
|
71
|
+
return !isDeckCard && !isToken && isInventoryCardType;
|
|
72
|
+
};
|
|
73
|
+
const getIsDeckCard = ({
|
|
74
|
+
keywords,
|
|
75
|
+
traits,
|
|
76
|
+
types
|
|
77
|
+
}) => {
|
|
78
|
+
const isDeckCardType = [
|
|
79
|
+
Type.Action,
|
|
80
|
+
Type.AttackReaction,
|
|
81
|
+
Type.Block,
|
|
82
|
+
Type.DefenseReaction,
|
|
83
|
+
Type.Instant,
|
|
84
|
+
Type.Mentor,
|
|
85
|
+
Type.Resource
|
|
86
|
+
].some((type) => types.includes(type));
|
|
87
|
+
const isToken = getIsCardTokenForDeck({
|
|
88
|
+
keywords,
|
|
89
|
+
traits,
|
|
90
|
+
types
|
|
91
|
+
});
|
|
92
|
+
return isDeckCardType && !isToken;
|
|
93
|
+
};
|
|
94
|
+
const getIsCardTokenForDeck = ({
|
|
95
|
+
keywords,
|
|
96
|
+
traits,
|
|
97
|
+
types
|
|
98
|
+
}) => {
|
|
99
|
+
const isAgentOfChaos = !!traits && traits?.includes(Trait.AgentOfChaos);
|
|
100
|
+
const isEphemeral = !!keywords && keywords.includes(Keyword.Ephemeral);
|
|
101
|
+
const isHeroMacroOrToken = [Type.Macro, Type.Token].some(
|
|
102
|
+
(type) => types.includes(type)
|
|
103
|
+
);
|
|
104
|
+
return isAgentOfChaos || isEphemeral || isHeroMacroOrToken;
|
|
105
|
+
};
|
|
106
|
+
const TOKEN_CARD_OVERRIDES = ["cracked-bauble-yellow", "goldfin-harpoon"];
|
|
107
|
+
const getCanCardBeTokenForDeck = (card) => {
|
|
108
|
+
const isTokenOverride = TOKEN_CARD_OVERRIDES.includes(card.cardIdentifier);
|
|
109
|
+
const isToken = getIsCardTokenForDeck(card);
|
|
110
|
+
const cardBackCanBeOutsideDeck = card.isCardBack && card.cardIdentifier !== "inner-chi-blue";
|
|
111
|
+
return isTokenOverride || isToken || cardBackCanBeOutsideDeck;
|
|
112
|
+
};
|
|
113
|
+
const getCanAddToDeck = ({
|
|
114
|
+
isCardBack,
|
|
115
|
+
keywords,
|
|
116
|
+
traits,
|
|
117
|
+
types
|
|
118
|
+
}) => {
|
|
119
|
+
const isArenaCard = getIsArenaCard({ keywords, traits, types });
|
|
120
|
+
const isDeckCard = getIsDeckCard({ keywords, traits, types });
|
|
121
|
+
const isCardFront = !isCardBack;
|
|
122
|
+
return isCardFront && (isArenaCard || isDeckCard);
|
|
123
|
+
};
|
|
124
|
+
const getShouldRotateCardImage = (card) => {
|
|
125
|
+
const isMeld = card.keywords?.includes(Keyword.Meld);
|
|
126
|
+
const isMacro = card.types?.includes(Type.Macro);
|
|
127
|
+
const isLandmarkThatShouldRotate = !isMacro && card.subtypes?.includes(Subtype.Landmark) || false;
|
|
128
|
+
return isMeld || isLandmarkThatShouldRotate;
|
|
129
|
+
};
|
|
130
|
+
export {
|
|
131
|
+
getCanAddToDeck,
|
|
132
|
+
getCanCardBeTokenForDeck,
|
|
133
|
+
getCardFromGEMCardIdentifier,
|
|
134
|
+
getCardIdentifier,
|
|
135
|
+
getFrontAndBackCardIdentifier,
|
|
136
|
+
getIsArenaCard,
|
|
137
|
+
getIsCardTokenForDeck,
|
|
138
|
+
getIsDeckCard,
|
|
139
|
+
getShouldRotateCardImage
|
|
140
|
+
};
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Treatment,
|
|
3
|
+
Foiling,
|
|
4
|
+
ReleaseEdition
|
|
5
|
+
} from "../interfaces";
|
|
6
|
+
import { fullSetIdentifiers } from "../sets";
|
|
7
|
+
const identifierExtensionMapping = {
|
|
8
|
+
// [Release.RhinarBlitzDeck]: "-Blitz",
|
|
9
|
+
};
|
|
10
|
+
const suffixOverrides = {
|
|
11
|
+
"FAB470-RFB": "-V2",
|
|
12
|
+
"FAB470-RFC": "-V3",
|
|
13
|
+
"OMN203-MVB": "-V2",
|
|
14
|
+
"OMN203-MVC": "-V3",
|
|
15
|
+
"MPG112-A": "-V2",
|
|
16
|
+
"MPG112-B": "-V3",
|
|
17
|
+
MPG112_V2: "-V2",
|
|
18
|
+
MPG112_V3: "-V3",
|
|
19
|
+
MST158_V3: "-V3",
|
|
20
|
+
"ROS162-B": "-V2",
|
|
21
|
+
ROS162_V2: "-V2",
|
|
22
|
+
"ROS008-MV_V2_BACK": "-V3",
|
|
23
|
+
SUP009_V3: "-V3",
|
|
24
|
+
SUP009_V3_BACK: "-V3",
|
|
25
|
+
"HER146-ARF": "-ARF"
|
|
26
|
+
};
|
|
27
|
+
const getPrint = (printing) => {
|
|
28
|
+
const identifierExtension = identifierExtensionMapping[printing.set] || "";
|
|
29
|
+
const identifier = `${printing.identifier}${identifierExtension}`;
|
|
30
|
+
const edition = printing.edition ? `-${printing.edition}` : ``;
|
|
31
|
+
const foiling = printing.foiling ? `-${printing.foiling}` : ``;
|
|
32
|
+
const treatment = printing.treatments?.length ? `-${printing.treatments.sort().join("-")}` : printing.treatment ? `-${printing.treatment}` : ``;
|
|
33
|
+
const back = printing.image?.toLowerCase().includes("back") ? `-Back` : ``;
|
|
34
|
+
const suffix = suffixOverrides[printing.image?.toUpperCase() || ""] || "";
|
|
35
|
+
return `${identifier}${edition}${foiling}${treatment}${back}${suffix}`;
|
|
36
|
+
};
|
|
37
|
+
const orderedFullSetBlackBorderIdentifiers = Object.keys(
|
|
38
|
+
fullSetIdentifiers
|
|
39
|
+
).filter((set) => !set.toLowerCase().includes("hp")).reverse().map((set) => set.toUpperCase());
|
|
40
|
+
const SPECIAL_IMAGE_PRINTING_OVERRIDES = {
|
|
41
|
+
"adaptive-plating": {
|
|
42
|
+
print: "EVO013-Cold"
|
|
43
|
+
},
|
|
44
|
+
"command-and-conquer-red": {
|
|
45
|
+
print: "ANQ009-Rainbow-Alternate Art-Alternate Border-Extended Art"
|
|
46
|
+
},
|
|
47
|
+
"cracked-bauble-yellow": {
|
|
48
|
+
print: "LGS083-Cold"
|
|
49
|
+
},
|
|
50
|
+
"dash-io": {
|
|
51
|
+
print: "HER089-Cold"
|
|
52
|
+
},
|
|
53
|
+
"fate-foreseen-red": {
|
|
54
|
+
print: "FAB024-Rainbow"
|
|
55
|
+
},
|
|
56
|
+
"florian-rotwood-harbinger": {
|
|
57
|
+
print: "ROS001-Cold-Full Art-Back"
|
|
58
|
+
},
|
|
59
|
+
"pleiades-superstar": {
|
|
60
|
+
print: "SUP009-Cold-Full Art"
|
|
61
|
+
},
|
|
62
|
+
"pitfall-trap-yellow": {
|
|
63
|
+
print: "LGS151-Rainbow"
|
|
64
|
+
},
|
|
65
|
+
"prism-sculptor-of-arc-light": {
|
|
66
|
+
print: "HER069-Cold-Full Art-Back"
|
|
67
|
+
},
|
|
68
|
+
quicken: {
|
|
69
|
+
print: "EVO250"
|
|
70
|
+
},
|
|
71
|
+
"ravenous-rabble-red": {
|
|
72
|
+
print: "FAB190-Rainbow-Extended Art"
|
|
73
|
+
},
|
|
74
|
+
"rockslide-trap-blue": {
|
|
75
|
+
print: "LGS152-Rainbow"
|
|
76
|
+
},
|
|
77
|
+
"rosetta-thorn": {
|
|
78
|
+
print: "ROS256-Cold"
|
|
79
|
+
},
|
|
80
|
+
"sigil-of-solace-red": {
|
|
81
|
+
print: "FAB178-Rainbow-Alternate Art-Extended Art"
|
|
82
|
+
},
|
|
83
|
+
"spectral-shield": {
|
|
84
|
+
print: "MST158-Alternate Art-V3"
|
|
85
|
+
},
|
|
86
|
+
"tripwire-trap-red": {
|
|
87
|
+
print: "LGS150-Rainbow"
|
|
88
|
+
},
|
|
89
|
+
"viserai-rune-blood": {
|
|
90
|
+
print: "HER011-Cold"
|
|
91
|
+
},
|
|
92
|
+
"wreck-havoc-red": {
|
|
93
|
+
print: "OUT198"
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const printingsToIgnore = ["JDG044-Full Art-Back"];
|
|
97
|
+
const getSpecialPrinting = (card, printings) => {
|
|
98
|
+
const { cardIdentifier } = card;
|
|
99
|
+
const matchingOverride = Object.entries(
|
|
100
|
+
SPECIAL_IMAGE_PRINTING_OVERRIDES
|
|
101
|
+
).find(([identifier]) => identifier === cardIdentifier);
|
|
102
|
+
const printingsIncludeMatchingOverride = !!matchingOverride && printings.some((printing) => {
|
|
103
|
+
const [, { print }] = matchingOverride;
|
|
104
|
+
return printing.print === print;
|
|
105
|
+
});
|
|
106
|
+
if (printingsIncludeMatchingOverride) {
|
|
107
|
+
const [, { print }] = matchingOverride;
|
|
108
|
+
const matchingPrint = printings.find(
|
|
109
|
+
(printing) => printing.print === print
|
|
110
|
+
);
|
|
111
|
+
return matchingPrint || printings[0];
|
|
112
|
+
} else {
|
|
113
|
+
let firstImage;
|
|
114
|
+
let alternativeArt;
|
|
115
|
+
let alternateBorder;
|
|
116
|
+
let alternateText;
|
|
117
|
+
let coldExtendedArt;
|
|
118
|
+
let coldFullArt;
|
|
119
|
+
let coldFullArt2;
|
|
120
|
+
let extendedArt;
|
|
121
|
+
let backFullArt;
|
|
122
|
+
let frontFullArt;
|
|
123
|
+
let firstFullArt;
|
|
124
|
+
let nonFoilExtendedArt;
|
|
125
|
+
let promoExtendedArt;
|
|
126
|
+
let fullArtAlternateArt;
|
|
127
|
+
let marvel;
|
|
128
|
+
let alphaEdition;
|
|
129
|
+
let firstEdition;
|
|
130
|
+
let promoEdition;
|
|
131
|
+
let unlimitedEdition;
|
|
132
|
+
let coldFoil;
|
|
133
|
+
let promoColdFoil;
|
|
134
|
+
for (const printing of printings) {
|
|
135
|
+
const { edition, foiling, identifier, image, print, treatments } = printing;
|
|
136
|
+
const upperCaseImage = image?.toUpperCase() || "";
|
|
137
|
+
const isMissingFunctionalText = identifier.toLowerCase().includes("win");
|
|
138
|
+
const hasImage = !!upperCaseImage;
|
|
139
|
+
const isGoldFoil = foiling === Foiling.Gold;
|
|
140
|
+
const isWhiteBorder = upperCaseImage.includes("HP");
|
|
141
|
+
const shouldIgnore = printingsToIgnore.includes(print);
|
|
142
|
+
const shouldConsiderPrinting = hasImage && !isMissingFunctionalText && !isWhiteBorder && !shouldIgnore && !isGoldFoil;
|
|
143
|
+
if (shouldConsiderPrinting) {
|
|
144
|
+
if (!firstImage) {
|
|
145
|
+
firstImage = printing;
|
|
146
|
+
}
|
|
147
|
+
if (treatments?.includes(Treatment.FA)) {
|
|
148
|
+
firstFullArt = printing;
|
|
149
|
+
if (foiling === Foiling.Cold) {
|
|
150
|
+
coldFullArt = printing;
|
|
151
|
+
if (upperCaseImage.includes("_V3")) {
|
|
152
|
+
coldFullArt2 = printing;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (upperCaseImage.includes("BACK")) {
|
|
157
|
+
backFullArt = printing;
|
|
158
|
+
} else {
|
|
159
|
+
frontFullArt = printing;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (treatments?.includes(Treatment.EA)) {
|
|
163
|
+
extendedArt = printing;
|
|
164
|
+
if (foiling === Foiling.Cold) {
|
|
165
|
+
coldExtendedArt = printing;
|
|
166
|
+
}
|
|
167
|
+
if (!foiling) {
|
|
168
|
+
nonFoilExtendedArt = printing;
|
|
169
|
+
}
|
|
170
|
+
if (edition === ReleaseEdition.Promo) {
|
|
171
|
+
promoExtendedArt = printing;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (treatments?.includes(Treatment.AA)) {
|
|
175
|
+
alternativeArt = printing;
|
|
176
|
+
}
|
|
177
|
+
if (treatments?.includes(Treatment.AB)) {
|
|
178
|
+
alternateBorder = printing;
|
|
179
|
+
}
|
|
180
|
+
if (treatments?.includes(Treatment.AT)) {
|
|
181
|
+
alternateText = printing;
|
|
182
|
+
}
|
|
183
|
+
if ((upperCaseImage.includes("_V2") || upperCaseImage.includes("-MV")) && treatments?.includes(Treatment.FA)) {
|
|
184
|
+
marvel = printing;
|
|
185
|
+
}
|
|
186
|
+
if (edition === ReleaseEdition.Alpha) {
|
|
187
|
+
alphaEdition = printing;
|
|
188
|
+
} else if (edition === ReleaseEdition.First) {
|
|
189
|
+
firstEdition = printing;
|
|
190
|
+
} else if (edition === ReleaseEdition.Promo) {
|
|
191
|
+
promoEdition = printing;
|
|
192
|
+
} else if (edition === ReleaseEdition.Unlimited) {
|
|
193
|
+
unlimitedEdition = printing;
|
|
194
|
+
}
|
|
195
|
+
if (foiling === Foiling.Cold) {
|
|
196
|
+
coldFoil = printing;
|
|
197
|
+
if (edition === ReleaseEdition.Promo) {
|
|
198
|
+
promoColdFoil = printing;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const finalFullArt = fullArtAlternateArt || coldFullArt2 || frontFullArt || backFullArt || coldFullArt || firstFullArt;
|
|
204
|
+
return finalFullArt || coldExtendedArt || marvel || promoExtendedArt || nonFoilExtendedArt || extendedArt || alternateBorder || alternativeArt || alternateText || promoColdFoil || alphaEdition || firstEdition || promoEdition || unlimitedEdition || coldFoil || firstImage;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
const DEFAULT_IMAGE_PRINTING_OVERRIDES = {
|
|
208
|
+
"command-and-conquer-red": {
|
|
209
|
+
print: "HNT260"
|
|
210
|
+
},
|
|
211
|
+
"fyendals-spring-tunic": {
|
|
212
|
+
print: "EVO249"
|
|
213
|
+
},
|
|
214
|
+
might: {
|
|
215
|
+
print: "TER028"
|
|
216
|
+
},
|
|
217
|
+
"pitfall-trap-yellow": {
|
|
218
|
+
print: "LGS151-Rainbow"
|
|
219
|
+
},
|
|
220
|
+
"portside-exchange-blue": {
|
|
221
|
+
print: "SEA145"
|
|
222
|
+
},
|
|
223
|
+
"rockslide-trap-blue": {
|
|
224
|
+
print: "LGS152-Rainbow"
|
|
225
|
+
},
|
|
226
|
+
"rosetta-thorn": {
|
|
227
|
+
print: "ELE222-First"
|
|
228
|
+
},
|
|
229
|
+
"spectral-shield": {
|
|
230
|
+
print: "MST158"
|
|
231
|
+
},
|
|
232
|
+
"tripwire-trap-red": {
|
|
233
|
+
print: "LGS150-Rainbow"
|
|
234
|
+
},
|
|
235
|
+
vigor: {
|
|
236
|
+
print: "HVY242"
|
|
237
|
+
},
|
|
238
|
+
"wreck-havoc-red": {
|
|
239
|
+
print: "OUT198"
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
const getDefaultPrinting = (card, printings) => {
|
|
243
|
+
const { cardIdentifier } = card;
|
|
244
|
+
const matchingOverride = Object.entries(
|
|
245
|
+
DEFAULT_IMAGE_PRINTING_OVERRIDES
|
|
246
|
+
).find(([identifier]) => identifier === cardIdentifier);
|
|
247
|
+
const printingsIncludeMatchingOverride = !!matchingOverride && printings.some((printing) => {
|
|
248
|
+
const [, { print }] = matchingOverride;
|
|
249
|
+
return printing.print === print;
|
|
250
|
+
});
|
|
251
|
+
if (printingsIncludeMatchingOverride) {
|
|
252
|
+
const [, { print }] = matchingOverride;
|
|
253
|
+
const matchingPrint = printings.find(
|
|
254
|
+
(printing) => printing.print === print
|
|
255
|
+
);
|
|
256
|
+
return matchingPrint || printings[0];
|
|
257
|
+
} else {
|
|
258
|
+
let firstImage;
|
|
259
|
+
let nonPromoImage;
|
|
260
|
+
for (const printing of printings) {
|
|
261
|
+
const { edition, image, treatment } = printing;
|
|
262
|
+
const hasImage = !!image;
|
|
263
|
+
const isWhiteBorder = image?.includes("HP");
|
|
264
|
+
const isCardBack = image?.includes("BACK");
|
|
265
|
+
const isAMessyImageName = (image || "").length > 10 || image?.includes("width");
|
|
266
|
+
const shouldConsiderPrinting = hasImage && !isWhiteBorder && !isCardBack && !isAMessyImageName;
|
|
267
|
+
if (shouldConsiderPrinting) {
|
|
268
|
+
if (!firstImage) {
|
|
269
|
+
firstImage = printing;
|
|
270
|
+
}
|
|
271
|
+
if (!nonPromoImage && edition !== ReleaseEdition.Promo && treatment !== Treatment.FA) {
|
|
272
|
+
nonPromoImage = printing;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (firstImage && nonPromoImage) {
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return nonPromoImage || firstImage || printings[0];
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
const BOOMER_IMAGE_PRINTING_OVERRIDES = {};
|
|
283
|
+
const getBoomerPrinting = (card, printings) => {
|
|
284
|
+
const { cardIdentifier } = card;
|
|
285
|
+
const matchingOverride = Object.entries(BOOMER_IMAGE_PRINTING_OVERRIDES).find(
|
|
286
|
+
([identifier]) => identifier === cardIdentifier
|
|
287
|
+
);
|
|
288
|
+
const printingsIncludeMatchingOverride = !!matchingOverride && printings.some((printing) => {
|
|
289
|
+
const [, { print }] = matchingOverride;
|
|
290
|
+
return printing.print === print;
|
|
291
|
+
});
|
|
292
|
+
if (printingsIncludeMatchingOverride) {
|
|
293
|
+
const [, { print }] = matchingOverride;
|
|
294
|
+
const matchingPrint = printings.find(
|
|
295
|
+
(printing) => printing.print === print
|
|
296
|
+
);
|
|
297
|
+
return matchingPrint || printings[0];
|
|
298
|
+
} else {
|
|
299
|
+
let firstPrinting = printings.length > 0 ? printings[0] : void 0;
|
|
300
|
+
for (const release of Object.values(fullSetIdentifiers)) {
|
|
301
|
+
const matchingPrinting = printings.find(
|
|
302
|
+
(printing) => printing.set === release
|
|
303
|
+
);
|
|
304
|
+
if (matchingPrinting) {
|
|
305
|
+
firstPrinting = matchingPrinting;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return firstPrinting;
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
const MAX_RARITY_IMAGE_PRINTING_OVERRIDES = {};
|
|
313
|
+
const getMaxRarityPrinting = (card, printings) => {
|
|
314
|
+
const { cardIdentifier } = card;
|
|
315
|
+
const matchingOverride = Object.entries(
|
|
316
|
+
MAX_RARITY_IMAGE_PRINTING_OVERRIDES
|
|
317
|
+
).find(([identifier]) => identifier === cardIdentifier);
|
|
318
|
+
const printingsIncludeMatchingOverride = !!matchingOverride && printings.some((printing) => {
|
|
319
|
+
const [, { print }] = matchingOverride;
|
|
320
|
+
return printing.print === print;
|
|
321
|
+
});
|
|
322
|
+
if (printingsIncludeMatchingOverride) {
|
|
323
|
+
const [, { print }] = matchingOverride;
|
|
324
|
+
const matchingPrint = printings.find(
|
|
325
|
+
(printing) => printing.print === print
|
|
326
|
+
);
|
|
327
|
+
return matchingPrint || printings[0];
|
|
328
|
+
} else {
|
|
329
|
+
let firstImage;
|
|
330
|
+
let alternativeArt;
|
|
331
|
+
let alternateBorder;
|
|
332
|
+
let alternateText;
|
|
333
|
+
let coldExtendedArt;
|
|
334
|
+
let coldFullArt;
|
|
335
|
+
let coldFullArt2;
|
|
336
|
+
let extendedArt;
|
|
337
|
+
let backFullArt;
|
|
338
|
+
let frontFullArt;
|
|
339
|
+
let firstFullArt;
|
|
340
|
+
let nonFoilExtendedArt;
|
|
341
|
+
let promoExtendedArt;
|
|
342
|
+
let fullArtAlternateArt;
|
|
343
|
+
let marvel;
|
|
344
|
+
let alphaEdition;
|
|
345
|
+
let firstEdition;
|
|
346
|
+
let promoEdition;
|
|
347
|
+
let unlimitedEdition;
|
|
348
|
+
let coldFoil;
|
|
349
|
+
let goldFoil;
|
|
350
|
+
let promoColdFoil;
|
|
351
|
+
for (const printing of printings) {
|
|
352
|
+
const { edition, foiling, identifier, image, print, treatments } = printing;
|
|
353
|
+
const upperCaseImage = image?.toUpperCase() || "";
|
|
354
|
+
const isMissingFunctionalText = identifier.toLowerCase().includes("win");
|
|
355
|
+
const hasImage = !!upperCaseImage;
|
|
356
|
+
const isWhiteBorder = upperCaseImage.includes("HP");
|
|
357
|
+
const shouldIgnore = printingsToIgnore.includes(print);
|
|
358
|
+
const shouldConsiderPrinting = hasImage && !isMissingFunctionalText && !isWhiteBorder && !shouldIgnore;
|
|
359
|
+
if (shouldConsiderPrinting) {
|
|
360
|
+
if (!firstImage) {
|
|
361
|
+
firstImage = printing;
|
|
362
|
+
}
|
|
363
|
+
if (treatments?.includes(Treatment.FA)) {
|
|
364
|
+
firstFullArt = printing;
|
|
365
|
+
if (foiling === Foiling.Cold) {
|
|
366
|
+
coldFullArt = printing;
|
|
367
|
+
if (upperCaseImage.includes("_V3")) {
|
|
368
|
+
coldFullArt2 = printing;
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (upperCaseImage.includes("BACK")) {
|
|
373
|
+
backFullArt = printing;
|
|
374
|
+
} else {
|
|
375
|
+
frontFullArt = printing;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (treatments?.includes(Treatment.EA)) {
|
|
379
|
+
extendedArt = printing;
|
|
380
|
+
if (foiling === Foiling.Cold) {
|
|
381
|
+
coldExtendedArt = printing;
|
|
382
|
+
}
|
|
383
|
+
if (!foiling) {
|
|
384
|
+
nonFoilExtendedArt = printing;
|
|
385
|
+
}
|
|
386
|
+
if (edition === ReleaseEdition.Promo) {
|
|
387
|
+
promoExtendedArt = printing;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (treatments?.includes(Treatment.AA)) {
|
|
391
|
+
alternativeArt = printing;
|
|
392
|
+
}
|
|
393
|
+
if (treatments?.includes(Treatment.AB)) {
|
|
394
|
+
alternateBorder = printing;
|
|
395
|
+
}
|
|
396
|
+
if (treatments?.includes(Treatment.AT)) {
|
|
397
|
+
alternateText = printing;
|
|
398
|
+
}
|
|
399
|
+
if ((upperCaseImage.includes("_V2") || upperCaseImage.includes("-MV")) && treatments?.includes(Treatment.FA)) {
|
|
400
|
+
marvel = printing;
|
|
401
|
+
}
|
|
402
|
+
if (edition === ReleaseEdition.Alpha) {
|
|
403
|
+
alphaEdition = printing;
|
|
404
|
+
} else if (edition === ReleaseEdition.First) {
|
|
405
|
+
firstEdition = printing;
|
|
406
|
+
} else if (edition === ReleaseEdition.Promo) {
|
|
407
|
+
promoEdition = printing;
|
|
408
|
+
} else if (edition === ReleaseEdition.Unlimited) {
|
|
409
|
+
unlimitedEdition = printing;
|
|
410
|
+
}
|
|
411
|
+
if (foiling === Foiling.Cold) {
|
|
412
|
+
coldFoil = printing;
|
|
413
|
+
if (edition === ReleaseEdition.Promo) {
|
|
414
|
+
promoColdFoil = printing;
|
|
415
|
+
}
|
|
416
|
+
} else if (foiling === Foiling.Gold) {
|
|
417
|
+
goldFoil = printing;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
const finalFullArt = fullArtAlternateArt || coldFullArt2 || frontFullArt || backFullArt || coldFullArt || firstFullArt;
|
|
422
|
+
return goldFoil || finalFullArt || coldExtendedArt || marvel || promoColdFoil || promoExtendedArt || coldFoil || nonFoilExtendedArt || extendedArt || alternateBorder || alternativeArt || alternateText || alphaEdition || promoEdition || firstEdition || unlimitedEdition || firstImage;
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
export {
|
|
426
|
+
getBoomerPrinting,
|
|
427
|
+
getDefaultPrinting,
|
|
428
|
+
getMaxRarityPrinting,
|
|
429
|
+
getPrint,
|
|
430
|
+
getSpecialPrinting,
|
|
431
|
+
orderedFullSetBlackBorderIdentifiers
|
|
432
|
+
};
|