@juice789/tf2items 1.0.27 → 1.0.29
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/fromEconItem.js +51 -31
- package/package.json +1 -1
- package/schema.json +1 -1
- package/schemaHelper.json +145 -0
- package/sku.js +8 -2
- package/skuLinks.js +2 -2
package/fromEconItem.js
CHANGED
|
@@ -36,12 +36,16 @@ const {
|
|
|
36
36
|
path,
|
|
37
37
|
equals,
|
|
38
38
|
pick,
|
|
39
|
-
assocPath
|
|
39
|
+
assocPath,
|
|
40
|
+
isEmpty,
|
|
41
|
+
join,
|
|
42
|
+
filter,
|
|
43
|
+
omit
|
|
40
44
|
} = require('ramda')
|
|
41
45
|
|
|
42
46
|
const { safeItems: items } = require('./schemaItems.js')
|
|
43
47
|
const { particleEffects, textures } = require('./schema.json')
|
|
44
|
-
const { qualityNames, wears } = require('./schemaHelper.json')
|
|
48
|
+
const { qualityNames, wears, paintDefindex, spellDefindex } = require('./schemaHelper.json')
|
|
45
49
|
const { skuFromItem } = require('./sku.js')
|
|
46
50
|
const { renameKeys } = require('ramda-adjunct')
|
|
47
51
|
|
|
@@ -63,23 +67,15 @@ const findTag = uncurryN(2, (tagName) => compose(
|
|
|
63
67
|
propOr([], 'tags')
|
|
64
68
|
))
|
|
65
69
|
|
|
66
|
-
const old_id =
|
|
67
|
-
has('new_assetid'),
|
|
68
|
-
prop('assetid'),
|
|
69
|
-
always(null)
|
|
70
|
-
)
|
|
70
|
+
const old_id = ({ new_assetid, rollback_new_assetid, assetid }) => (new_assetid || rollback_new_assetid) ? assetid : null
|
|
71
71
|
|
|
72
|
-
const id =
|
|
73
|
-
propOr(__, 'new_assetid'),
|
|
74
|
-
prop('assetid')
|
|
75
|
-
)
|
|
72
|
+
const id = ({ new_assetid, rollback_new_assetid, assetid }) => new_assetid || rollback_new_assetid || assetid
|
|
76
73
|
|
|
77
74
|
const recipe = compose(
|
|
78
75
|
find(__, ['Fabricator', 'Strangifier Chemistry Set', 'Chemistry Set']),
|
|
79
76
|
flip(marketHashIncludes),
|
|
80
77
|
)
|
|
81
78
|
|
|
82
|
-
|
|
83
79
|
const series = ifElse(
|
|
84
80
|
compose(equals('Crate'), findTag('Type')),
|
|
85
81
|
ifElse(
|
|
@@ -185,6 +181,24 @@ const uncraftable = compose(
|
|
|
185
181
|
propOr([], 'descriptions')
|
|
186
182
|
)
|
|
187
183
|
|
|
184
|
+
const paintOptions = Object.keys(paintDefindex).map(paintName => `Paint Color: ${paintName}`)
|
|
185
|
+
|
|
186
|
+
const paintColor = compose(
|
|
187
|
+
when(Boolean, ({ value }) => paintDefindex[value.split('Paint Color: ')[1]]),
|
|
188
|
+
find(compose(includes(__, paintOptions), prop('value'))),
|
|
189
|
+
propOr([], 'descriptions')
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
const spellOptions = Object.keys(spellDefindex).map(spellName => `Halloween: ${spellName} (spell only active during event)`)
|
|
193
|
+
|
|
194
|
+
const halloweenSpell = compose(
|
|
195
|
+
when(isEmpty, always(null)),
|
|
196
|
+
join('_'),
|
|
197
|
+
map(({ value }) => spellDefindex[value.split('Halloween: ')[1].replace(' (spell only active during event)', '')]),
|
|
198
|
+
filter(compose(includes(__, spellOptions), prop('value'))),
|
|
199
|
+
propOr([], 'descriptions')
|
|
200
|
+
)
|
|
201
|
+
|
|
188
202
|
const market_hash_name = prop('market_hash_name')
|
|
189
203
|
|
|
190
204
|
const setQuality = when(
|
|
@@ -213,6 +227,8 @@ const propsTf2_1 = {
|
|
|
213
227
|
series,
|
|
214
228
|
craft,
|
|
215
229
|
recipe,
|
|
230
|
+
halloweenSpell,
|
|
231
|
+
paintColor,
|
|
216
232
|
id,
|
|
217
233
|
old_id
|
|
218
234
|
}
|
|
@@ -305,16 +321,12 @@ const keyRemap = when(
|
|
|
305
321
|
String,
|
|
306
322
|
prop('defindex')
|
|
307
323
|
),
|
|
308
|
-
|
|
309
|
-
assoc('defindex', '5021'),
|
|
310
|
-
assoc('uncraftable', false)
|
|
311
|
-
)
|
|
324
|
+
assoc('defindex', '5021')
|
|
312
325
|
)
|
|
313
326
|
|
|
314
|
-
|
|
315
|
-
const uncraftRemap = when(
|
|
327
|
+
const uncraftRemap = (uncraftRemapDefindex) => when(
|
|
316
328
|
compose(
|
|
317
|
-
includes(__,
|
|
329
|
+
includes(__, uncraftRemapDefindex),
|
|
318
330
|
String,
|
|
319
331
|
prop('defindex')
|
|
320
332
|
),
|
|
@@ -344,35 +356,43 @@ const otherRemap = when(
|
|
|
344
356
|
chain(assoc('defindex'), compose(prop(__, otherIndex), prop('defindex')))
|
|
345
357
|
)
|
|
346
358
|
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
otherRemap
|
|
352
|
-
)
|
|
359
|
+
const defaultOptions440 = {
|
|
360
|
+
omitProps: ['paintColor', 'halloweenSpell'],
|
|
361
|
+
uncraftRemapDefindex: ['5021']
|
|
362
|
+
}
|
|
353
363
|
|
|
354
|
-
const fromEconItem440 = compose(
|
|
364
|
+
const fromEconItem440 = ({ omitProps = [], uncraftRemapDefindex = [] } = defaultOptions440) => compose(
|
|
355
365
|
pick(['sku', 'id', 'old_id']),
|
|
356
366
|
chain(assoc('sku'), skuFromItem),
|
|
357
|
-
|
|
367
|
+
uncraftRemap(uncraftRemapDefindex),
|
|
368
|
+
kitRemap,
|
|
369
|
+
keyRemap,
|
|
370
|
+
otherRemap,
|
|
358
371
|
chain(mergeRight, compose(map(__, propsTf2_2), applyTo)),
|
|
359
|
-
map(__, propsTf2_1),
|
|
372
|
+
map(__, omit(omitProps, propsTf2_1)),
|
|
360
373
|
unary(applyTo),
|
|
361
374
|
setQuality
|
|
362
375
|
)
|
|
363
376
|
|
|
364
|
-
const fromEconItemOther = compose(
|
|
377
|
+
const fromEconItemOther = (options = {}) => compose(
|
|
365
378
|
map(__, propsOtherGame),
|
|
366
379
|
unary(applyTo)
|
|
367
380
|
)
|
|
368
381
|
|
|
369
382
|
const fromEconItem = ifElse(
|
|
370
383
|
propEq(440, 'appid'),
|
|
371
|
-
fromEconItem440,
|
|
372
|
-
fromEconItemOther
|
|
384
|
+
fromEconItem440(),
|
|
385
|
+
fromEconItemOther()
|
|
373
386
|
)
|
|
374
387
|
|
|
388
|
+
const fromEconItemOptions = curry((options, econItem) => ifElse(
|
|
389
|
+
propEq(440, 'appid'),
|
|
390
|
+
fromEconItem440(options),
|
|
391
|
+
fromEconItemOther(options)
|
|
392
|
+
)(econItem))
|
|
393
|
+
|
|
375
394
|
module.exports = {
|
|
376
395
|
fromEconItem,
|
|
396
|
+
fromEconItemOptions,
|
|
377
397
|
kitRemap
|
|
378
398
|
}
|