Skip to content

Commit

Permalink
fix: masterable check for modular parts and Pets (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
SlayerOrnstein authored Dec 4, 2024
1 parent 36b397e commit 51ef3d5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
7 changes: 6 additions & 1 deletion build/parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,12 @@ class Parser {
* @param {Item} item the item to add the attribute to
*/
applyMasterable(item) {
item.masterable = masterableCategories.includes(item.category);
item.masterable = masterableCategories.categories.includes(item.category);

if (item.type?.includes('Component') || item.category === 'Pets') {
const regex = new RegExp(masterableCategories.regex);
item.masterable = regex.test(item.uniqueName);
}
}

addResistanceData(item, category) {
Expand Down
23 changes: 13 additions & 10 deletions config/masterableCategories.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[
"Archwing",
"Arch-Melee",
"Arch-Gun",
"Melee",
"Primary",
"Secondary",
"Sentinels",
"Warframes"
]
{
"regex": "^((?=.*Amp)|(?=.*Modular))(?=.*Barrel).*$|^(?=.*Pet)(?=.*Head).*$|PetPowerSuit|PvPVariantTip|^(?=.*Hoverboard)(?=.*Deck).*$",
"categories": [
"Archwing",
"Arch-Melee",
"Arch-Gun",
"Melee",
"Primary",
"Secondary",
"Sentinels",
"Warframes"
]
}
12 changes: 10 additions & 2 deletions test/index.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,18 @@ for (const base of ['index.js', 'index.mjs']) {
it('items should be marked masterable correctly ', async () => {
const items = await wrapConstr({ ignoreEnemies: true });
items.forEach((item) => {
const masterable = masterableCategories.includes(item.category);
const masterable = (category, type, uniqueName) => {
if (type?.includes('Component') || category === 'Pets') {
const regex = new RegExp(masterableCategories.regex);
return regex.test(uniqueName);
}

return masterableCategories.categories.includes(category);
};

assert.equal(
item.masterable,
masterable,
masterable(item.category, item.type, item.uniqueName),
`${item.name} should be marked as ${!masterable ? 'not ' : ''}masterable`
);
});
Expand Down

0 comments on commit 51ef3d5

Please sign in to comment.