Skip to content

Commit

Permalink
Checks for unneeded higher-level items of a similar name
Browse files Browse the repository at this point in the history
Adds another filter to the fodder check that assumes an item is needed if a higher quality item of the same name is needed. For example, 3* Kira's Pistol (which is unneeded on its own for any crew on my roster) will no longer be listed because it's similar in name to 4* Kira's Pistol (which is needed on my roster by an unequipped Decoy Kira).

This will lead to some false positives (e.g. some 2* items are not actually building blocks of their equivalent 3* builds), but that's okay because it's better to be too conservative in recommendations than the alternative. Plus, the false positives will resolve themselves when the relevant crew become fully equipped.

Unfortunately, the tool still cannot account for partial builds by different names, e.g. 3* Tuvix's Uniform needs 2* Starfleet Security Uniform (VOY), in which case the latter might still be listed as fodder even if Tuvix is unequipped. This is also the case first raised in #285 about Yar's Phaser being a building block of Armus' Skin. To reduce the chances of this, lower quality equipment (i.e. 0* and 1*) remain ignored by the final tier of recommendations (Other Equipment). The new disclaimer is hopefully enough to warn users of this possibility.

If DataCore's items.json template gets updated with an incremental recipe tree, the `needsHigherQuality` function can be replaced with one that properly checks higher-level recipes for needed building blocks.

Made small changes to some variable names and the disclaimer for clarity.
  • Loading branch information
ussjohnjay committed Apr 3, 2022
1 parent 37ece9f commit ee3eeca
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions src/components/unneededitems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ class UnneededItems extends Component<UnneededItemsProps, UnneededItemsState> {
return b.rarity - a.rarity;
});

// Calculate all replicator fodder
let equipmentAlreadyOnCrew = new Set();
let equipmentNeededByCrew = new Set();

// Only consider equipment of fully-equipped crew as fodder
// Only consider equipment of fully-equipped crew as potential fodder
// Assume all equipment items of other crew are still needed
let equipmentEquipped = new Set();
let equipmentNeeded = new Set();
// Handle dupes as either all fully-equipped or as all needing items
let crewBySymbol = [];
playerData.player.character.crew.forEach(crew => {
if (crewBySymbol.indexOf(crew.symbol) == -1) crewBySymbol.push(crew.symbol);
Expand All @@ -77,15 +77,16 @@ class UnneededItems extends Component<UnneededItemsProps, UnneededItemsState> {
const crew = crewList[0];
crew.equipment_slots.forEach(equipment => {
if (allFullyEquipped)
equipmentAlreadyOnCrew.add(equipment.symbol);
equipmentEquipped.add(equipment.symbol);
else
equipmentNeededByCrew.add(equipment.symbol);
equipmentNeeded.add(equipment.symbol);
});
});

// Calculate all replicator fodder
let fuellist = items.filter(
item => equipmentAlreadyOnCrew.has(item.symbol) &&
!equipmentNeededByCrew.has(item.symbol)
item => equipmentEquipped.has(item.symbol) &&
!equipmentNeeded.has(item.symbol)
).sort((a, b) => {
if (a.rarity == b.rarity)
return a.name.localeCompare(b.name);
Expand All @@ -100,16 +101,29 @@ class UnneededItems extends Component<UnneededItemsProps, UnneededItemsState> {
name.indexOf("’s ") > 0 ||
name.indexOf("s’ ") > 0;

// Assume needed if a higher quality item of same name is needed
const needsHigherQuality = (symbol, rarity) => {
let needsHigher = false;
for (let i = rarity + 1; i <= 5; i++) {
if (equipmentNeeded.has(symbol.replace(/quality\d/, 'quality'+i))) {
needsHigher = true;
break;
}
}
return needsHigher;
};

// Filter crew-specific items
let fuelspecific = fuellist.filter(
item => isSpecificItem(item.name)
item => isSpecificItem(item.name) && !needsHigherQuality(item.symbol, item.rarity)
);

// Filter generic items
let fuelgeneric = fuellist.filter(
item =>
item.quantity === 1 && item.rarity > 1 &&
!isSpecificItem(item.name)
!isSpecificItem(item.name) &&
!needsHigherQuality(item.symbol, item.rarity)
);

this.setState({ fuelschematics, fuelspecific, fuelgeneric });
Expand Down Expand Up @@ -158,7 +172,7 @@ class UnneededItems extends Component<UnneededItemsProps, UnneededItemsState> {
{this.state.fuelspecific.length > 0 && (
<React.Fragment>
<Header as='h4'>Crew-Specific Equipment ({this.state.fuelspecific.length})</Header>
<p>The following equipment items are good candidates to discard as they are used to equip <b>specific crew you have already fully equipped</b>. Note: some items listed here might be useful for crew who are not on your current roster, or as partial builds of other needed equipment. Click an item name to consult the wiki for more information about the equipment.</p>
<p>The following equipment items are good candidates to discard as they are used to equip <b>specific crew you have already fully equipped</b>. Note: some items listed here might be useful for crew who are not on your current roster, or as building blocks of other needed equipment. Click an item name to consult the wiki for more information about the equipment.</p>
<Grid columns={5} centered padded>
{this.state.fuelspecific.map((item, idx) => (
<Grid.Column key={idx} rel={item.archetype_id} textAlign='center'>
Expand All @@ -178,7 +192,7 @@ class UnneededItems extends Component<UnneededItemsProps, UnneededItemsState> {
{this.state.fuelgeneric.length > 0 && (
<React.Fragment>
<Header as='h4'>Other Equipment ({this.state.fuelgeneric.length})</Header>
<p>The following equipment items are good candidates to discard as they are <b>not needed for any crew on your current roster</b>. Note: some items listed here might be useful for crew who are not on your current roster, or as partial builds of other needed equipment. Click an item name to consult the wiki for more information about the equipment.</p>
<p>The following equipment items are other candidates to discard as they are <b>no longer needed for any crew on your current roster</b>. Note: some items listed here might be useful for crew who are not on your current roster, or as building blocks of other needed equipment. Click an item name to consult the wiki for more information about the equipment.</p>
<Grid columns={5} centered padded>
{this.state.fuelgeneric.map((item, idx) => (
<Grid.Column key={idx} rel={item.archetype_id} textAlign='center'>
Expand Down

0 comments on commit ee3eeca

Please sign in to comment.