Skip to content

Commit 633a216

Browse files
authored
fix(types): match on class-category on weapons (#822)
1 parent 2346474 commit 633a216

File tree

13 files changed

+87
-114
lines changed

13 files changed

+87
-114
lines changed

build/parser.mjs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,12 +908,39 @@ class Parser {
908908
addAdditionalWikiaData(item, category, wikiaData) {
909909
if (!['weapons', 'warframes', 'mods', 'upgrades', 'sentinels'].includes(category.toLowerCase())) return;
910910

911+
const slots = [
912+
['Secondary'], // 0
913+
['Primary', 'Hound', 'Beast', 'Archgun', 'Robotic', 'Archgun (Atmosphere)', 'Amp'], // 1
914+
[], // 2
915+
[], // 3
916+
['Archgun'], // 4
917+
['Melee', 'Archmelee'], // 5
918+
[], // 6
919+
['Archgun (Atmosphere)', 'Exalted', 'Secondary', 'Primary', 'Melee', 'Archgun', 'Archmelee'], // 7
920+
[],
921+
[],
922+
[],
923+
[],
924+
[],
925+
[],
926+
['Railjack Turret'], // 14
927+
];
928+
911929
let wikiCategory = category.toLowerCase();
912930
if (category === 'Upgrades') wikiCategory = 'mods';
913931
if (item.category === 'Archwing') wikiCategory = 'archwings';
914932
if (category === 'Sentinels') wikiCategory = 'companions';
915933

916-
const wikiaItem = wikiaData[wikiCategory].filter((i) => i).find((i) => i.uniqueName === item.uniqueName);
934+
const wikiaItem = wikiaData[wikiCategory]
935+
.filter((i) => i)
936+
.find((i) => {
937+
const uMatch = i.uniqueName === item.uniqueName;
938+
let nMatch = true;
939+
if (category.toLowerCase() === 'weapons' && typeof item.slot !== 'undefined') {
940+
nMatch = slots[item.slot]?.includes(i.slot);
941+
}
942+
return uMatch && nMatch;
943+
});
917944
if (!wikiaItem) return;
918945
item.wikiAvailable = true;
919946

build/wikia/transformers/transformPolarity.mjs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ import POLARITIES from './polarities.mjs';
22

33
const transform = (field) => {
44
let output;
5-
if (field) {
6-
output = (POLARITIES[field] || field || '').toLowerCase();
7-
if (output && !output.length) output = undefined;
8-
if (output === 'none') output = undefined;
5+
try {
6+
if (field) {
7+
output = String(POLARITIES[field] ?? field ?? '').toLowerCase();
8+
if (output && !output.length) output = undefined;
9+
if (output === 'none') output = undefined;
10+
}
11+
} catch (error) {
12+
console.error('Error transforming polarity:', field, error);
913
}
14+
1015
return output;
1116
};
1217

build/wikia/transformers/transformWeapon.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ export default (oldWeapon, imageUrls, blueprints) => {
203203
Attack10,
204204
Attacks,
205205
InternalName,
206+
Slot,
206207
} = oldWeapon;
207208

208209
newWeapon = {
@@ -212,6 +213,7 @@ export default (oldWeapon, imageUrls, blueprints) => {
212213
url: `https://wiki.warframe.com/w/${encodeURIComponent(Name.replace(/\s/g, '_'))}`,
213214
mr: Mastery || 0,
214215
type: Class || Type,
216+
class: Class,
215217
riven_disposition: Disposition,
216218
...(ChargeAttack &&
217219
ChargeAttack.StatusChance && { status_chance: Number((Number(ChargeAttack.StatusChance) * 100).toFixed(2)) }),
@@ -223,6 +225,7 @@ export default (oldWeapon, imageUrls, blueprints) => {
223225
marketCost: blueprints[Name] && blueprints[Name].MarketCost,
224226
bpCost: blueprints[Name] && blueprints[Name].BPCost,
225227
thumbnail: imageUrls[Image] || imageUrls[Image.replace(/_/g, ' ')],
228+
slot: Slot,
226229
attacks: [
227230
NormalAttack && parseAttack(NormalAttack),
228231
Attack1 && parseAttack(Attack1),

config/itemTypes.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,10 @@
994994
"id": "/Mods/TransmuteCores",
995995
"name": "Transmutation Mod"
996996
},
997+
{
998+
"id": "/Upgrades/Mods/Antiques/",
999+
"name": "Tektolyst Artifact Mod"
1000+
},
9971001
{
9981002
"id": "Upgrades/Mods/.*Mod",
9991003
"regex": true,
@@ -1062,4 +1066,4 @@
10621066
"id": "Challenges/Seasons",
10631067
"name": "Nightwave Challenge"
10641068
}
1065-
]
1069+
]

0 commit comments

Comments
 (0)