Skip to content

Commit 29f53c5

Browse files
committed
fix: DT can be crafted now
1 parent 6001294 commit 29f53c5

File tree

3 files changed

+60
-9
lines changed

3 files changed

+60
-9
lines changed

src/base/library/craft/borders.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ onPage('Crafting', function craftableCards() {
2525
);
2626

2727
function highlight(el) {
28-
const rarity = cardHelper.rarity(el);
29-
const set = !setting.value() &&
30-
rarity !== 'DETERMINATION' &&
31-
cardHelper.quantity(el) < cardHelper.max(rarity) &&
32-
cardHelper.dustCost(el) <= cardHelper.totalDust();
28+
const set = !setting.value() && cardHelper.craftable(el);
3329
el.classList.toggle('craftable', set);
3430
}
3531

src/base/library/filter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ filters.push(
199199
case 'unowned': return card.quantity > 0;
200200
case 'maxed': return card.quantity < max(card.rarity);
201201
case 'surplus': return card.quantity <= max(card.rarity);
202-
case 'craftable': return card.quantity >= max(card.rarity) || card.rarity === 'DETERMINATION';
202+
case 'craftable': return card.quantity >= max(card.rarity);
203203
case 'all':
204204
default: break;
205205
}

src/utils/cardHelper.js

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,61 @@ export function totalDust() {
5858
return parseInt(document.querySelector('span#dust').textContent, 10);
5959
}
6060

61+
export function craftable(el) {
62+
const r = rarity(el);
63+
if (quantity(el) >= max(r)) {
64+
return false;
65+
}
66+
const s = isShiny(el);
67+
switch (r) {
68+
case 'DETERMINATION': return fragCost(r, s) <= totalFrags();
69+
case 'LEGENDARY':
70+
case 'EPIC':
71+
case 'RARE':
72+
case 'COMMON':
73+
case 'BASE': {
74+
const dust = dustCost(r, s);
75+
return dust !== null && dust <= totalDust();
76+
}
77+
case 'TOKEN':
78+
case 'GENERATED': return false;
79+
default: {
80+
debug(`Unknown Rarity: ${r}`);
81+
return false;
82+
}
83+
}
84+
}
85+
86+
export function totalFrags() {
87+
return Number(document.querySelector('span#nbDTFragments').textContent);
88+
}
89+
90+
export function fragCost(r, s) {
91+
if (typeof r === 'object') {
92+
if (typeof s !== 'boolean') {
93+
s = isShiny(r);
94+
}
95+
r = rarity(r);
96+
}
97+
switch (r) {
98+
case 'DETERMINATION': return s ? 8 : 4;
99+
default: return null;
100+
}
101+
}
102+
103+
export function fragGain(r, s) {
104+
if (typeof r === 'object') {
105+
if (typeof s !== 'boolean') {
106+
s = isShiny(r);
107+
}
108+
r = rarity(r);
109+
}
110+
switch (r) {
111+
case 'DETERMINATION': return s ? 4 : 2;
112+
default: return null;
113+
}
114+
}
115+
61116
export function dustCost(r, s) {
62117
if (typeof r === 'object') {
63118
if (typeof s !== 'boolean') {
@@ -86,15 +141,15 @@ export function dustGain(r, s) {
86141
switch (r) {
87142
case 'TOKEN':
88143
case 'GENERATED': // You can't craft this, but I don't want an error
89-
case 'DETERMINATION': return undefined;
144+
case 'DETERMINATION': return null;
90145
case 'LEGENDARY': return s ? 1600 : 400;
91146
case 'EPIC': return s ? 400 : 100;
92147
case 'RARE': return s ? 100 : 20;
93148
case 'COMMON': return s ? 40 : 5;
94-
case 'BASE': return s ? 40 : 0;
149+
case 'BASE': return s ? 40 : null;
95150
default: {
96151
debug(`Unknown Rarity: ${r}`);
97-
return undefined;
152+
return null;
98153
}
99154
}
100155
}

0 commit comments

Comments
 (0)