-
Notifications
You must be signed in to change notification settings - Fork 54
/
tradable.mjs
62 lines (60 loc) 路 1.78 KB
/
tradable.mjs
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const builtUntradable = ['Warframe', 'Throwing', 'Shotgun', 'Rifle', 'Pistol', 'Melee', 'Sword And Shield'];
const tradableConditions = (item) => !(builtUntradable.includes(item.type) && item.name.match(/Prime/gi));
const tradableTypes = [
'Upgrades',
'Arcane',
'Fish',
'Focus Lens',
'Relic',
'Secondary Mod',
'Shotgun Mod',
'Warframe Mod',
'Companion Mod',
'Archwing Mod',
'K-Drive Mod',
'Melee Mod',
'Arch-Melee Mod',
'Necramech Mod',
'Cut Gem',
'Captura',
'Primary Mod',
'Sentinel Mod',
'Kubrow Mod',
'Kavat Mod',
];
const untradableTypes = [
'Skin',
'Medallion',
'Key',
'Extractor',
'Pets',
'Ship Decoration',
'Glyph',
'Sigil',
'Fur Color',
'Syandana',
'Fur Pattern',
'Color Palette',
'Node',
'Exalted Weapon',
];
const tradableRegex =
/(Prime|Vandal|Wraith\w|\wWraith|Rakta|Synoid|Sancti|Vaykor|Telos|Secura|Ayatan|Prisma|DamagedMech)(?!Derelict)/i;
const untradableRegex =
/(Glyph|Mandachord|Greater.*Lens|Sugatra|\[|SentinelWeapons|Toroid|Bait|([A-Za-z]+ (Relic)))|Umbral|Sacrificial/i;
/**
* Check if an item is tradable
* @param {module:warframe-items.Item} item Item to determine tradability
* @returns {boolean}
*/
export default (item) => {
const notFiltered =
!untradableTypes.includes(item.type) &&
!item.name.match(untradableRegex) &&
!item.uniqueName.match(untradableRegex) &&
(item.productCategory ? !item.productCategory.match(/(SpecialItems)/) : true);
const tradableByType = !!(tradableTypes.includes(item.type) && notFiltered);
const tradableByName = !!((item.uniqueName.match(tradableRegex) || item.name.match(tradableRegex)) && notFiltered);
const tradableByProp = !!(item.isAugment && notFiltered);
return (tradableByType || tradableByName || tradableByProp) && tradableConditions(item);
};