Skip to content

Commit dd6833f

Browse files
committed
chore: convert rewards to constant strings
1 parent 9397e80 commit dd6833f

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# UnderScript Changelog
22

3+
## Version 0.55.4 (2023-10-17)
4+
1. Fix quest reward bug
5+
36
## Version 0.55.3 (2023-10-16)
47
1. Fixed another quest bug
58

src/structures/quests/Reward.js

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { translateText } from '../../utils/translate.js';
2-
31
export default class Reward {
42
#reward;
53
#type;
@@ -37,7 +35,7 @@ function rewardType(el) {
3735
let temp = el.querySelector('[data-i18n-tips]');
3836
if (temp) { // Generic reward
3937
return {
40-
type: translateText(temp.dataset.i18nTips),
38+
type: getRewardType(temp.dataset.i18nTips),
4139
value: temp.parentElement.textContent.trim().substring(1),
4240
};
4341
}
@@ -73,35 +71,35 @@ function rewardType(el) {
7371
};
7472
}
7573

76-
temp = el.querySelector('.standard-skin');
74+
temp = el.querySelector('.avatar');
7775
if (temp) {
7876
return {
79-
type: 'card skin',
80-
value: getStyleUrl(temp),
77+
type: 'avatar',
78+
value: temp.src,
8179
};
8280
}
8381

84-
temp = el.querySelector('.full-skin');
82+
temp = el.querySelector('[src*="/profiles/"]');
8583
if (temp) {
8684
return {
87-
type: 'card skin full',
88-
value: getStyleUrl(temp),
85+
type: 'profile',
86+
value: temp.src,
8987
};
9088
}
9189

92-
temp = el.querySelector('.avatar');
90+
temp = el.querySelector('.standard-skin');
9391
if (temp) {
9492
return {
95-
type: 'avatar',
96-
value: temp.src,
93+
type: 'card skin',
94+
value: getStyleUrl(temp),
9795
};
9896
}
9997

100-
temp = el.querySelector('[src*="/profiles/"]');
98+
temp = el.querySelector('.full-skin');
10199
if (temp) {
102100
return {
103-
type: 'profile',
104-
value: temp.src,
101+
type: 'card skin full',
102+
value: getStyleUrl(temp),
105103
};
106104
}
107105

@@ -113,3 +111,17 @@ function getStyleUrl(el) {
113111
const style = img.currentStyle || window.getComputedStyle(img, true) || img.style;
114112
return style.backgroundImage.slice(4, -1).replace(/"/g, '');
115113
}
114+
115+
function getRewardType(string) {
116+
switch (string) {
117+
// TODO: Convert to constants
118+
case 'reward-gold': return 'Gold';
119+
case 'reward-shiny-pack': return 'Shiny Pack';
120+
case 'reward-pack': return 'Pack';
121+
case 'reward-dr-pack': return 'DR Pack';
122+
case 'reward-dust': return 'Dust';
123+
case 'reward-dt-fragment': return 'DT Fragment';
124+
// If anything new comes through
125+
default: return string;
126+
}
127+
}

0 commit comments

Comments
 (0)