Skip to content

Commit

Permalink
Merge pull request #333 from xiv-gear-planner/materia-levels-fixes
Browse files Browse the repository at this point in the history
Make materia display logic more dynamic
  • Loading branch information
xpdota authored Sep 22, 2024
2 parents 1658592 + d16db85 commit f7d02e4
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions packages/core/src/sheet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ // TODO: get back to fixing this at some point
/* eslint-disable @typescript-eslint/no-explicit-any */ // TODO: get back to fixing this at some point
import {
CURRENT_MAX_LEVEL,
defaultItemDisplaySettings,
Expand Down Expand Up @@ -323,7 +323,7 @@ export class GearPlanSheet {
}
this._relevantMateria = this.dataManager.allMateria.filter(mat => {
return mat.materiaGrade <= lvlItemInfo.maxMateria
&& mat.materiaGrade >= lvlItemInfo.minMateria
// && mat.materiaGrade >= lvlItemInfo.minMateria
&& this.isStatRelevant(mat.primaryStat);
});
this._dmRelevantFood = this.dataManager.allFoodItems.filter(food => this.isStatRelevant(food.primarySubStat) || this.isStatRelevant(food.secondarySubStat));
Expand Down Expand Up @@ -772,7 +772,26 @@ export class GearPlanSheet {
}

getRelevantMateriaFor(slot: MeldableMateriaSlot) {
return this._relevantMateria.filter(mat => mat.ilvl <= slot.materiaSlot.ilvl);
const materia = this._relevantMateria.filter(mat => mat.ilvl <= slot.materiaSlot.ilvl);
// Sort materia from highest to lowest
materia.sort((left, right) => {
if (left.materiaGrade > right.materiaGrade) {
return -1;
}
else if (left.materiaGrade < right.materiaGrade) {
return 1;
}
return 0;
});
if (materia.length === 0) {
return [];
}
// Find highest grade materia
const maxGrade = materia[0].materiaGrade;
// Find lowest grade that we want to display - three grades lower. e.g. if the gear can support materia X,
// then we want to display X, IX for pentamelds, as well as IIX and VIII for budget sets.
const minDisplayGrade = maxGrade - 3;
return materia.filter(mat => mat.materiaGrade >= minDisplayGrade);
}

get partyBonus(): PartyBonusAmount {
Expand Down

0 comments on commit f7d02e4

Please sign in to comment.