@juice789/tf2items 1.0.39 → 2.0.1
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/api.js +4 -10
- package/app.js +34 -48
- package/blanket.js +32 -107
- package/browser.js +13 -0
- package/fetchAppDataInventory.js +32 -31
- package/fetchItemsApi.js +12 -20
- package/fetchItemsGame.js +5 -4
- package/fetchParticleEffects.js +12 -16
- package/fetchTextures.js +13 -15
- package/fetchTfEnglish.js +9 -8
- package/fromEconItem.js +238 -337
- package/fromListingV1.js +109 -244
- package/fromListingV2.js +28 -60
- package/getCollections.js +16 -32
- package/getItems.js +30 -37
- package/package.json +12 -4
- package/sagaHelpers.js +3 -9
- package/sagas.js +6 -15
- package/saveSchema.js +4 -18
- package/schema.json +1 -1
- package/schemaHelper.json +601 -0
- package/schemaItems.js +3 -7
- package/sku.js +33 -46
- package/sku753.js +2 -7
- package/skuBp.js +14 -30
- package/skuLinks.js +22 -45
- package/transformItems.js +58 -86
- package/utils.js +17 -0
- package/toSearchParams.js +0 -99
- package/todo.txt +0 -24
package/fromEconItem.js
CHANGED
|
@@ -1,74 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
concat,
|
|
36
|
-
path,
|
|
37
|
-
equals,
|
|
38
|
-
pick,
|
|
39
|
-
assocPath,
|
|
40
|
-
isEmpty,
|
|
41
|
-
join,
|
|
42
|
-
filter,
|
|
43
|
-
omit,
|
|
44
|
-
last,
|
|
45
|
-
defaultTo,
|
|
46
|
-
renameKeys
|
|
47
|
-
} = require('ramda')
|
|
48
|
-
|
|
49
|
-
const { safeItems: items } = require('./schemaItems.js')
|
|
50
|
-
const { particleEffects, textures } = require('./schema.json')
|
|
51
|
-
const { qualityNames, wears, paintDefindex, spellDefindex } = require('./schemaHelper.json')
|
|
52
|
-
const { skuFromItem } = require('./sku.js')
|
|
53
|
-
const { skuFromItem753 } = require('./sku753.js')
|
|
54
|
-
|
|
55
|
-
const marketHashIncludes = curry((string, { market_hash_name }) => market_hash_name.indexOf(string) !== -1)
|
|
56
|
-
|
|
57
|
-
const removeStrings = curry((string, strings) => compose(
|
|
58
|
-
trim,
|
|
59
|
-
replace(/\s\s+/g, ' '),
|
|
60
|
-
reduce((all, curr) => replace(curr, '', all), string || '')
|
|
61
|
-
)(strings))
|
|
62
|
-
|
|
63
|
-
const findTag = uncurryN(3, (tagName, displayProp) => compose(
|
|
64
|
-
prop(displayProp),
|
|
65
|
-
find(propEq(tagName, 'category_name')),
|
|
66
|
-
map(renameKeys({
|
|
67
|
-
localized_category_name: 'category_name',
|
|
68
|
-
localized_tag_name: 'name'
|
|
69
|
-
})),
|
|
70
|
-
propOr([], 'tags')
|
|
71
|
-
))
|
|
1
|
+
import { safeItems as items } from './schemaItems.js'
|
|
2
|
+
import schema from './schema.json' with { type: 'json' }
|
|
3
|
+
import schemaHelper from './schemaHelper.json' with { type: 'json' }
|
|
4
|
+
const { particleEffects, textures } = schema
|
|
5
|
+
const { qualityNames, wears, paintDefindex, spellDefindex, rchDefindex } = schemaHelper
|
|
6
|
+
import { skuFromItem } from './sku.js'
|
|
7
|
+
import { skuFromItem753 } from './sku753.js'
|
|
8
|
+
|
|
9
|
+
const invertObj = obj => Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k]))
|
|
10
|
+
|
|
11
|
+
const wearsInv = invertObj(wears)
|
|
12
|
+
const texturesInv = invertObj(textures)
|
|
13
|
+
const particleEffectsInv = invertObj(particleEffects)
|
|
14
|
+
const qualityNamesInv = invertObj(qualityNames)
|
|
15
|
+
const rchSet = new Set(rchDefindex)
|
|
16
|
+
|
|
17
|
+
function removeStrings(string, strings) {
|
|
18
|
+
return strings
|
|
19
|
+
.reduce((acc, curr) => acc.replace(curr, ''), string || '')
|
|
20
|
+
.replace(/\s\s+/g, ' ')
|
|
21
|
+
.trim()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function findTag(tagName, displayProp, item) {
|
|
25
|
+
const tag = (item.tags ?? [])
|
|
26
|
+
.map(t => {
|
|
27
|
+
const out = { ...t }
|
|
28
|
+
if ('localized_category_name' in out) { out.category_name = out.localized_category_name; delete out.localized_category_name }
|
|
29
|
+
if ('localized_tag_name' in out) { out.name = out.localized_tag_name; delete out.localized_tag_name }
|
|
30
|
+
return out
|
|
31
|
+
})
|
|
32
|
+
.find(t => t.category_name === tagName)
|
|
33
|
+
return tag?.[displayProp]
|
|
34
|
+
}
|
|
72
35
|
|
|
73
36
|
const old_id = ({ new_assetid, rollback_new_assetid, assetid }) => (new_assetid || rollback_new_assetid) ? assetid : null
|
|
74
37
|
|
|
@@ -78,148 +41,111 @@ const old_contextid = ({ new_contextid, rollback_new_contextid, contextid }) =>
|
|
|
78
41
|
|
|
79
42
|
const contextid = ({ new_contextid, rollback_new_contextid, contextid }) => new_contextid || rollback_new_contextid || contextid || null
|
|
80
43
|
|
|
81
|
-
const appid =
|
|
82
|
-
|
|
83
|
-
const recipe =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
]
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const uncraftable = compose(
|
|
188
|
-
Boolean,
|
|
189
|
-
find(propEq('( Not Usable in Crafting )', 'value')),
|
|
190
|
-
propOr([], 'descriptions')
|
|
191
|
-
)
|
|
192
|
-
|
|
193
|
-
const paintOptions = Object.keys(paintDefindex).map(paintName => `Paint Color: ${paintName}`)
|
|
194
|
-
|
|
195
|
-
const paintColor = compose(
|
|
196
|
-
when(Boolean, ({ value }) => paintDefindex[value.split('Paint Color: ')[1]]),
|
|
197
|
-
find(compose(includes(__, paintOptions), prop('value'))),
|
|
198
|
-
propOr([], 'descriptions')
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
const spellOptions = Object.keys(spellDefindex).map(spellName => `Halloween: ${spellName} (spell only active during event)`)
|
|
202
|
-
|
|
203
|
-
const halloweenSpell = compose(
|
|
204
|
-
when(isEmpty, always(null)),
|
|
205
|
-
join('_'),
|
|
206
|
-
map(({ value }) => spellDefindex[value.split('Halloween: ')[1].replace(' (spell only active during event)', '')]),
|
|
207
|
-
filter(compose(includes(__, spellOptions), prop('value'))),
|
|
208
|
-
propOr([], 'descriptions')
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
const market_hash_name = prop('market_hash_name')
|
|
212
|
-
|
|
213
|
-
const setQuality = when(
|
|
214
|
-
compose(complement(Boolean), path(['app_data', 'quality'])),
|
|
215
|
-
chain(
|
|
216
|
-
assocPath(['app_data', 'quality']),
|
|
217
|
-
compose(prop(__, invertObj(qualityNames)), findTag('Quality', 'name'))
|
|
218
|
-
)
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
const quality = pathOr('-1', ['app_data', 'quality'])
|
|
222
|
-
const defindex = pathOr('-1', ['app_data', 'def_index'])
|
|
44
|
+
const appid = item => item.appid
|
|
45
|
+
|
|
46
|
+
const recipe = item =>
|
|
47
|
+
['Fabricator', 'Strangifier Chemistry Set', 'Chemistry Set']
|
|
48
|
+
.find(s => item.market_hash_name.indexOf(s) !== -1) || null
|
|
49
|
+
|
|
50
|
+
function series(item) {
|
|
51
|
+
if (findTag('Type', 'name', item) !== 'Crate') return null
|
|
52
|
+
if (item.market_hash_name.indexOf('#') !== -1) return item.market_hash_name.split('#')[1]
|
|
53
|
+
return (items[item?.app_data?.def_index]?.series ?? [])[0]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const craft = item =>
|
|
57
|
+
item.name?.includes('#') && !item.market_hash_name?.includes('#')
|
|
58
|
+
? item.name.split('#')[1]
|
|
59
|
+
: null
|
|
60
|
+
|
|
61
|
+
const australium = item =>
|
|
62
|
+
item?.app_data?.quality === '11' && item.market_hash_name.indexOf('Australium') !== -1
|
|
63
|
+
|
|
64
|
+
const wear = item => {
|
|
65
|
+
const wearName = findTag('Exterior', 'name', item)
|
|
66
|
+
if (!wearName) return undefined
|
|
67
|
+
return wearsInv[removeStrings(wearName, ['(', ')'])]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function texture(item) {
|
|
71
|
+
if (!findTag('Exterior', 'name', item)) return null
|
|
72
|
+
const name = removeStrings(item.market_hash_name, [
|
|
73
|
+
'Specialized Killstreak',
|
|
74
|
+
'Professional Killstreak',
|
|
75
|
+
'Killstreak',
|
|
76
|
+
'(Field-Tested)',
|
|
77
|
+
'(Well-Worn)',
|
|
78
|
+
'(Battle Scarred)',
|
|
79
|
+
'(Minimal Wear)',
|
|
80
|
+
'(Factory New)',
|
|
81
|
+
'Festivized',
|
|
82
|
+
'Strange',
|
|
83
|
+
qualityNames[item.app_data.quality],
|
|
84
|
+
items[item.app_data.def_index].item_name
|
|
85
|
+
])
|
|
86
|
+
return texturesInv[name] ?? '-1'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const festivized = item => item.market_hash_name.indexOf('Festivized') !== -1
|
|
90
|
+
|
|
91
|
+
const ksMap = {
|
|
92
|
+
'Professional Killstreak': '3',
|
|
93
|
+
'Specialized Killstreak': '2',
|
|
94
|
+
'Killstreak': '1'
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const killstreakTier = item => {
|
|
98
|
+
const ks = ['Professional Killstreak', 'Specialized Killstreak', 'Killstreak']
|
|
99
|
+
.find(s => item.market_hash_name.indexOf(s) !== -1)
|
|
100
|
+
return ks ? ksMap[ks] : undefined
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function effect(item) {
|
|
104
|
+
if (item?.app_data?.quality !== '5') return null
|
|
105
|
+
const desc = (item.descriptions || []).find(d => d.color === 'ffd700')
|
|
106
|
+
if (!desc) return null
|
|
107
|
+
return particleEffectsInv[desc.value.replace('★ Unusual Effect: ', '')] ?? '-1'
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const elevated = item =>
|
|
111
|
+
item?.app_data?.quality !== '11' &&
|
|
112
|
+
item.market_hash_name
|
|
113
|
+
.replace(items[item.app_data?.def_index]?.item_name ?? '', '')
|
|
114
|
+
.includes('Strange')
|
|
115
|
+
|
|
116
|
+
const uncraftable = item =>
|
|
117
|
+
Boolean((item.descriptions || []).find(d => d.value === '( Not Usable in Crafting )'))
|
|
118
|
+
|
|
119
|
+
const paintOptions = Object.keys(paintDefindex).map(name => `Paint Color: ${name}`)
|
|
120
|
+
|
|
121
|
+
const paintColor = item => {
|
|
122
|
+
const desc = (item.descriptions || []).find(d => paintOptions.includes(d.value))
|
|
123
|
+
if (!desc) return desc
|
|
124
|
+
return paintDefindex[desc.value.split('Paint Color: ')[1]]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const spellOptions = Object.keys(spellDefindex).map(name => `Halloween: ${name} (spell only active during event)`)
|
|
128
|
+
|
|
129
|
+
const halloweenSpell = item => {
|
|
130
|
+
const spells = (item.descriptions || [])
|
|
131
|
+
.filter(d => spellOptions.includes(d.value))
|
|
132
|
+
.map(d => spellDefindex[d.value.split('Halloween: ')[1].replace(' (spell only active during event)', '')])
|
|
133
|
+
return spells.length === 0 ? null : spells.join('_')
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const rch = item => item?.app_data?.quality === '6' && !uncraftable(item) && rchSet.has(item?.app_data?.def_index) && item?.app_data?.def_index
|
|
137
|
+
|
|
138
|
+
const market_hash_name = item => item.market_hash_name
|
|
139
|
+
|
|
140
|
+
function setQuality(item) {
|
|
141
|
+
if (item?.app_data?.quality) return item
|
|
142
|
+
const qualityName = findTag('Quality', 'name', item)
|
|
143
|
+
const qualityId = qualityNamesInv[qualityName]
|
|
144
|
+
return { ...item, app_data: { ...(item.app_data ?? {}), quality: qualityId } }
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const quality = item => item?.app_data?.quality ?? '-1'
|
|
148
|
+
const defindex = item => item?.app_data?.def_index ?? '-1'
|
|
223
149
|
|
|
224
150
|
const propsTf2_1 = {
|
|
225
151
|
defindex,
|
|
@@ -238,6 +164,7 @@ const propsTf2_1 = {
|
|
|
238
164
|
recipe,
|
|
239
165
|
halloweenSpell,
|
|
240
166
|
paintColor,
|
|
167
|
+
rch,
|
|
241
168
|
id,
|
|
242
169
|
old_id,
|
|
243
170
|
contextid,
|
|
@@ -245,74 +172,59 @@ const propsTf2_1 = {
|
|
|
245
172
|
appid
|
|
246
173
|
}
|
|
247
174
|
|
|
248
|
-
const isTarget =
|
|
249
|
-
|
|
250
|
-
find(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
175
|
+
const isTarget = item =>
|
|
176
|
+
['Strangifier', 'Fabricator', 'Strangifier Chemistry Set', 'Unusualifier']
|
|
177
|
+
.find(s => item.market_hash_name.indexOf(s) !== -1) ||
|
|
178
|
+
(item.market_hash_name.indexOf('Kit') !== -1 && item.market_hash_name.indexOf('Killstreak') !== -1)
|
|
179
|
+
|
|
180
|
+
function target(item) {
|
|
181
|
+
if (!isTarget(item)) return null
|
|
182
|
+
const cleanName = removeStrings(item.market_hash_name, [
|
|
183
|
+
'Strangifier',
|
|
184
|
+
'Unusual',
|
|
185
|
+
'Unusualifier',
|
|
186
|
+
items[item.defindex].item_name,
|
|
187
|
+
'Specialized Killstreak',
|
|
188
|
+
'Professional Killstreak',
|
|
189
|
+
'Killstreak',
|
|
190
|
+
"Collector's",
|
|
191
|
+
'Series',
|
|
192
|
+
'Kit',
|
|
193
|
+
'Fabricator',
|
|
194
|
+
'Chemistry Set',
|
|
195
|
+
'#1',
|
|
196
|
+
'#2',
|
|
197
|
+
'#3'
|
|
256
198
|
])
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
compose(
|
|
262
|
-
propOr('-1', 'defindex'),
|
|
263
|
-
find(__, values(items)),
|
|
264
|
-
allPass,
|
|
265
|
-
concat([propSatisfies(complement(includes)(__, [0, 15]), 'item_quality')]),
|
|
266
|
-
Array.of,
|
|
267
|
-
propEq(__, 'item_name'),
|
|
268
|
-
({ market_hash_name, defindex }) => removeStrings(market_hash_name, [
|
|
269
|
-
'Strangifier',
|
|
270
|
-
'Unusual',
|
|
271
|
-
'Unusualifier',
|
|
272
|
-
items[defindex].item_name,
|
|
273
|
-
'Specialized Killstreak',
|
|
274
|
-
'Professional Killstreak',
|
|
275
|
-
'Killstreak',
|
|
276
|
-
"Collector's",
|
|
277
|
-
'Series',
|
|
278
|
-
'Kit',
|
|
279
|
-
'Fabricator',
|
|
280
|
-
'Chemistry Set',
|
|
281
|
-
'#1',
|
|
282
|
-
'#2',
|
|
283
|
-
'#3'
|
|
284
|
-
])
|
|
285
|
-
),
|
|
286
|
-
always(null)
|
|
287
|
-
)
|
|
199
|
+
return Object.values(items).find(
|
|
200
|
+
si => ![0, 15].includes(si.item_quality) && si.item_name === cleanName
|
|
201
|
+
)?.defindex ?? '-1'
|
|
202
|
+
}
|
|
288
203
|
|
|
289
204
|
const output = ({ recipe, market_hash_name, killstreakTier }) => {
|
|
290
205
|
switch (recipe) {
|
|
291
|
-
case 'Fabricator':
|
|
206
|
+
case 'Fabricator': {
|
|
292
207
|
const ktMap = {
|
|
293
208
|
'2': '6523',
|
|
294
209
|
'3': '6526'
|
|
295
210
|
}
|
|
296
211
|
return ktMap[killstreakTier]
|
|
212
|
+
}
|
|
297
213
|
case 'Strangifier Chemistry Set':
|
|
298
214
|
return '6522'
|
|
299
|
-
case 'Chemistry Set':
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
Array.of,
|
|
306
|
-
propEq(__, 'item_name'),
|
|
307
|
-
removeStrings(__, ['Chemistry Set', "Collector's"])
|
|
308
|
-
)(market_hash_name)
|
|
215
|
+
case 'Chemistry Set': {
|
|
216
|
+
const cleanName = removeStrings(market_hash_name, ['Chemistry Set', "Collector's"])
|
|
217
|
+
return Object.values(items).find(
|
|
218
|
+
si => ![0, 15].includes(si.item_quality) && si.item_name === cleanName
|
|
219
|
+
)?.defindex ?? '-1'
|
|
220
|
+
}
|
|
309
221
|
default:
|
|
310
222
|
return null
|
|
311
223
|
}
|
|
312
224
|
}
|
|
313
225
|
|
|
314
226
|
const oq = ({ market_hash_name, recipe }) => recipe
|
|
315
|
-
? includes("Collector's"
|
|
227
|
+
? market_hash_name.includes("Collector's") ? '14' : '6'
|
|
316
228
|
: null
|
|
317
229
|
|
|
318
230
|
const propsTf2_2 = {
|
|
@@ -329,10 +241,10 @@ const propsOtherGame = {
|
|
|
329
241
|
}
|
|
330
242
|
|
|
331
243
|
const props753 = {
|
|
332
|
-
market_hash_name:
|
|
333
|
-
border:
|
|
334
|
-
game:
|
|
335
|
-
type: ({ tags = [] }) =>
|
|
244
|
+
market_hash_name: item => item.market_hash_name,
|
|
245
|
+
border: item => (findTag('Card Border', 'internal_name', item) ?? '').at(-1),
|
|
246
|
+
game: item => findTag('Game', 'internal_name', item)?.split('_')[1],
|
|
247
|
+
type: ({ tags = [] }) => (tags.find(tag => tag.category === 'item_class')?.internal_name || 'x').at(-1),
|
|
336
248
|
id,
|
|
337
249
|
old_id,
|
|
338
250
|
contextid,
|
|
@@ -340,88 +252,77 @@ const props753 = {
|
|
|
340
252
|
appid
|
|
341
253
|
}
|
|
342
254
|
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
)
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
),
|
|
358
|
-
assoc('uncraftable', false)
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
const kitRemap = when(
|
|
362
|
-
compose(
|
|
363
|
-
includes('Killstreakifier Basic'),
|
|
364
|
-
propOr('', 'name'),
|
|
365
|
-
prop(__, items),
|
|
366
|
-
prop('defindex')
|
|
367
|
-
),
|
|
368
|
-
assoc('defindex', '6527')
|
|
369
|
-
)
|
|
255
|
+
const oldKeyDefindexes = ['5021', '5049', '5067', '5072', '5073', '5079', '5081', '5628', '5631', '5632', '5713', '5716', '5717', '5762', '5791', '5792']
|
|
256
|
+
|
|
257
|
+
const keyRemap = item => oldKeyDefindexes.includes(String(item.defindex))
|
|
258
|
+
? { ...item, defindex: '5021' }
|
|
259
|
+
: item
|
|
260
|
+
|
|
261
|
+
const uncraftRemap = uncraftRemapDefindex => item =>
|
|
262
|
+
uncraftRemapDefindex.includes(String(item.defindex))
|
|
263
|
+
? { ...item, uncraftable: false }
|
|
264
|
+
: item
|
|
265
|
+
|
|
266
|
+
export const kitRemap = item => (items[item.defindex]?.name ?? '').includes('Killstreakifier Basic')
|
|
267
|
+
? { ...item, defindex: '6527' }
|
|
268
|
+
: item
|
|
370
269
|
|
|
371
270
|
const otherIndex = {
|
|
372
|
-
5844: '5710', //fall acorns key
|
|
373
|
-
5845: '5720', //strongbox key
|
|
374
|
-
5846: '5740', //stockpile key
|
|
375
|
-
5847: '5827', //gargoyle key
|
|
376
|
-
5738: '5737', //stockpile crate
|
|
271
|
+
5844: '5710', // fall acorns key
|
|
272
|
+
5845: '5720', // strongbox key
|
|
273
|
+
5846: '5740', // stockpile key
|
|
274
|
+
5847: '5827', // gargoyle key
|
|
275
|
+
5738: '5737', // stockpile crate
|
|
377
276
|
}
|
|
378
277
|
|
|
379
|
-
const otherRemap =
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
)
|
|
278
|
+
const otherRemap = item => item.defindex in otherIndex
|
|
279
|
+
? { ...item, defindex: otherIndex[item.defindex] }
|
|
280
|
+
: item
|
|
383
281
|
|
|
384
282
|
const defaultOptions440 = {
|
|
385
|
-
omitProps: ['paintColor', 'halloweenSpell'],
|
|
283
|
+
omitProps: ['paintColor', 'halloweenSpell', 'rch'],
|
|
386
284
|
uncraftRemapDefindex: ['5021']
|
|
387
285
|
}
|
|
388
286
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
)
|
|
401
|
-
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
287
|
+
function applyFns(fns, item) {
|
|
288
|
+
return Object.fromEntries(Object.entries(fns).map(([k, fn]) => [k, fn(item)]))
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function fromEconItem440({ omitProps = [], uncraftRemapDefindex = [] } = defaultOptions440) {
|
|
292
|
+
return function (econItem) {
|
|
293
|
+
const item = setQuality(econItem)
|
|
294
|
+
const filteredProps = omitProps.length
|
|
295
|
+
? Object.fromEntries(Object.entries(propsTf2_1).filter(([k]) => !omitProps.includes(k)))
|
|
296
|
+
: propsTf2_1
|
|
297
|
+
const mapped = applyFns(filteredProps, item)
|
|
298
|
+
const merged = { ...mapped, ...applyFns(propsTf2_2, mapped) }
|
|
299
|
+
const remapped = uncraftRemap(uncraftRemapDefindex)(kitRemap(keyRemap(otherRemap(merged))))
|
|
300
|
+
const withSku = { ...remapped, sku: skuFromItem(remapped) }
|
|
301
|
+
const { sku, id, old_id, contextid, old_contextid, appid } = withSku
|
|
302
|
+
return { sku, id, old_id, contextid, old_contextid, appid }
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function fromEconItem753() {
|
|
307
|
+
return function (econItem) {
|
|
308
|
+
const mapped = applyFns(props753, econItem)
|
|
309
|
+
const withSku = { ...mapped, sku: skuFromItem753(mapped) }
|
|
310
|
+
const { sku, id, old_id, contextid, old_contextid, appid } = withSku
|
|
311
|
+
return { sku, id, old_id, contextid, old_contextid, appid }
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function fromEconItemOther() {
|
|
316
|
+
return function (econItem) {
|
|
317
|
+
return applyFns(propsOtherGame, econItem)
|
|
318
|
+
}
|
|
319
|
+
}
|
|
413
320
|
|
|
414
321
|
const mainFns = {
|
|
415
322
|
440: fromEconItem440,
|
|
416
323
|
753: fromEconItem753
|
|
417
324
|
}
|
|
418
325
|
|
|
419
|
-
const fromEconItem =
|
|
420
|
-
|
|
421
|
-
const fromEconItemOptions = curry((options, econItem) => (mainFns[econItem.appid] || fromEconItemOther)(options)(econItem))
|
|
326
|
+
export const fromEconItem = econItem => (mainFns[econItem.appid] || fromEconItemOther)()(econItem)
|
|
422
327
|
|
|
423
|
-
|
|
424
|
-
fromEconItem,
|
|
425
|
-
fromEconItemOptions,
|
|
426
|
-
kitRemap
|
|
427
|
-
}
|
|
328
|
+
export const fromEconItemOptions = options => econItem => (mainFns[econItem.appid] || fromEconItemOther)(options)(econItem)
|