From 90f1c590f77128902e9e739a9d665ae75c2c1bab Mon Sep 17 00:00:00 2001 From: DaPigGuy Date: Sat, 26 Oct 2024 21:07:28 -0700 Subject: [PATCH] Properly fix Mandachord/Necramech component images Fixes 53042a4907fa25b5b5c63d3bbc28948ac21b37c9 --- src/components/checklist/ItemComponent.jsx | 16 ++-------------- src/components/foundry/MissingIngredients.jsx | 10 ++-------- src/utils/items.js | 16 +++++++++++++++- updater/update_items.mjs | 15 +++++++++------ 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/components/checklist/ItemComponent.jsx b/src/components/checklist/ItemComponent.jsx index 5cb4eb8..e0ac038 100644 --- a/src/components/checklist/ItemComponent.jsx +++ b/src/components/checklist/ItemComponent.jsx @@ -1,6 +1,6 @@ import classNames from "classnames"; import PropTypes from "prop-types"; -import { ingredientSuffixes } from "../../utils/items"; +import { getComponentImageUrl } from "../../utils/items"; export default function ItemComponent({ itemName, @@ -8,23 +8,11 @@ export default function ItemComponent({ component, isSubcomponent }) { - const imageName = ( - component.generic - ? (componentName.includes(" Prime ") ? "prime-" : "") + - ingredientSuffixes.find(suffix => - componentName.endsWith(suffix) - ) ?? componentName.replace(`${itemName} `, "") - : componentName + "-" + component.hash - ) - .split(" ") - .join("-") - .toLowerCase(); - return (
diff --git a/src/components/foundry/MissingIngredients.jsx b/src/components/foundry/MissingIngredients.jsx index 59dd626..7dfa3ce 100644 --- a/src/components/foundry/MissingIngredients.jsx +++ b/src/components/foundry/MissingIngredients.jsx @@ -2,6 +2,7 @@ import { useState } from "react"; import Masonry from "react-masonry-css"; import { useStore } from "../../hooks/useStore"; import { LabeledToggle } from "../Toggle"; +import { getComponentImageUrl } from "../../utils/items"; function MissingIngredients() { const [visible, setVisible] = useState(false); @@ -43,14 +44,7 @@ function MissingIngredients() {
e.preventDefault()} diff --git a/src/utils/items.js b/src/utils/items.js index 1e1136e..c51eeee 100644 --- a/src/utils/items.js +++ b/src/utils/items.js @@ -1,6 +1,6 @@ import PropTypes from "prop-types"; -export const ingredientSuffixes = [ +const ingredientSuffixes = [ "Aegis", "Barrel", "Barrels", @@ -50,6 +50,19 @@ export const ingredientSuffixes = [ ]; export const foundersItems = ["Excalibur Prime", "Skana Prime", "Lato Prime"]; +export function getComponentImageUrl(itemName, componentName, generic, hash) { + return `https://cdn.warframestat.us/img/${(generic + ? (componentName.includes(" Prime ") ? "prime-" : "") + + ingredientSuffixes.find(suffix => + componentName.endsWith(suffix) + ) ?? componentName.replace(`${itemName} `, "") + : componentName + (hash ? "-" + hash : "") + ) + .split(" ") + .join("-") + .toLowerCase()}.png`; +} + export const relicTiers = ["Lith", "Meso", "Neo", "Axi", "Requiem"]; export const relicRarity = ["Common", "Uncommon", "Rare"]; @@ -76,3 +89,4 @@ export const itemShape = { buildTime: PropTypes.number, buildPrice: PropTypes.number }; + diff --git a/updater/update_items.mjs b/updater/update_items.mjs index 44e0581..48f5136 100644 --- a/updater/update_items.mjs +++ b/updater/update_items.mjs @@ -183,12 +183,8 @@ class ItemUpdater { ingredientRawName.includes("WeaponParts") || ingredientRawName.includes("WarframeRecipes") || ingredientRawName.includes("NecromechPart") || - - // WFCD warframe-items does not include a hash for these despite being unique from other generic component images - ingredientRawName.includes("DamagedMechPart") || - ingredientName.startsWith("Cortege") || - ingredientName.startsWith("Morgha") || - ingredientName.startsWith("BardQuestSequencerPart") + // WFCD warframe-items considers Mandachord components as generic despite there being no other variations of these components + ingredientRawName.includes("BardQuestSequencerPart") ) { ingredientData.generic = true; @@ -196,6 +192,13 @@ class ItemUpdater { this.relics[ingredientRawName] || this.relics[ingredientRawName.replace("Component", "Blueprint")]; if (relics && item.relics) item.relics[ingredientName] = relics; + } else if ( + // WFCD warframe-items does not include a hash for these components despite them being unique from other generic components + ingredientRawName.includes("DamagedMechPart") || + ingredientName.startsWith("Cortege") || + ingredientName.startsWith("Morgha") + ) { + ingredientData.hash = null; } else { const hash = createHash("sha256") .update(ingredient.ItemType)