Skip to content

Commit

Permalink
Properly fix Mandachord/Necramech component images
Browse files Browse the repository at this point in the history
Fixes 53042a4
  • Loading branch information
DaPigGuy committed Oct 27, 2024
1 parent b3536f1 commit 90f1c59
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
16 changes: 2 additions & 14 deletions src/components/checklist/ItemComponent.jsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
import classNames from "classnames";
import PropTypes from "prop-types";
import { ingredientSuffixes } from "../../utils/items";
import { getComponentImageUrl } from "../../utils/items";

export default function ItemComponent({
itemName,
componentName,
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 (
<div className={classNames({ "item-subcomponent": isSubcomponent })}>
<img
className="component-image"
src={`https://cdn.warframestat.us/img/${imageName}.png`}
src={getComponentImageUrl(itemName, componentName, component.generic, component.hash)}
alt=""
width="24px"
/>
Expand Down
10 changes: 2 additions & 8 deletions src/components/foundry/MissingIngredients.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -43,14 +44,7 @@ function MissingIngredients() {
<div key={name}>
<img
className="component-image"
src={`https://cdn.warframestat.us/img/${
name
.toLowerCase()
.split(" ")
.join("-") +
"-" +
hash
}.png`}
src={getComponentImageUrl("", name, false, hash)}
alt=""
width="24px"
onDragStart={e => e.preventDefault()}
Expand Down
16 changes: 15 additions & 1 deletion src/utils/items.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from "prop-types";

export const ingredientSuffixes = [
const ingredientSuffixes = [
"Aegis",
"Barrel",
"Barrels",
Expand Down Expand Up @@ -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"];

Expand All @@ -76,3 +89,4 @@ export const itemShape = {
buildTime: PropTypes.number,
buildPrice: PropTypes.number
};

15 changes: 9 additions & 6 deletions updater/update_items.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,22 @@ 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;

const relics =
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)
Expand Down

0 comments on commit 90f1c59

Please sign in to comment.