This commit is contained in:
2026-01-24 18:13:06 -05:00
parent bcb10037c9
commit 4025850d6f

View File

@@ -529,7 +529,7 @@
<div id="steps-modal" class="modal"> <div id="steps-modal" class="modal">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
Assembly Instructions Synthesis Instructions
<button class="close-btn" onclick="closeSteps()">&times;</button> <button class="close-btn" onclick="closeSteps()">&times;</button>
</div> </div>
<div class="modal-body" id="steps-list"> <div class="modal-body" id="steps-list">
@@ -849,7 +849,8 @@
id: id, id: id,
recipe: recipe, recipe: recipe,
batches: batches, batches: batches,
amountProduced: batches * yieldAmt amountProduced: batches * yieldAmt,
depth: depth
}); });
// 5. Produce Byproducts // 5. Produce Byproducts
@@ -939,6 +940,12 @@
} }
}); });
// Sort by depth
merged.sort((a, b) => a.depth - b.depth);
// Reverse to get topological order (Dependencies first)
merged.reverse();
return merged; return merged;
} }
} }
@@ -1113,7 +1120,7 @@
const rIdx = selectedRecipes[node.id] !== undefined ? selectedRecipes[node.id] : 0; const rIdx = selectedRecipes[node.id] !== undefined ? selectedRecipes[node.id] : 0;
const hasRecipe = recipeList.length > 0 && rIdx !== -1 && node.type !== 'surplus'; const hasRecipe = recipeList.length > 0 && rIdx !== -1 && node.type !== 'surplus';
const currentRecipe = hasRecipe ? recipeList[rIdx] : null; const currentRecipe = hasRecipe ? recipeList[rIdx] : null;
console.log(node.id, recipeList, rIdx, hasRecipe, currentRecipe);
let content = ''; let content = '';
if (node.type === 'surplus') { if (node.type === 'surplus') {
content = `<div style="color: var(--accent-orange); font-size: 0.8rem;">[ FROM BYPRODUCTS ]</div>`; content = `<div style="color: var(--accent-orange); font-size: 0.8rem;">[ FROM BYPRODUCTS ]</div>`;
@@ -1133,8 +1140,18 @@
</div> </div>
`).join('')} `).join('')}
</div>`; </div>`;
} else { } else if (recipeList.length == 0) {
content = `<div style="color: var(--accent-cyan); font-size: 0.8rem; font-weight: bold;">[ RAW MATERIAL ]</div>`; content = `<div style="color: var(--accent-cyan); font-size: 0.8rem; font-weight: bold;">[ RAW MATERIAL ]</div>`;
} else {
content = `
<select class="recipe-select" onchange="changeRecipe('${node.id}', this.value)">
<option value="-1" ${rIdx == -1 ? 'selected' : ''}>[ Already Have ]</option>
${recipeList.map((r, i) => {
if (document.getElementById('hide-grind').checked && isGrindRecipe(r) && rIdx !== i) return '';
return `<option value="${i}" ${rIdx == i ? 'selected' : ''}>${r.id}</option>`;
}).join('')}
</select>
<div style="color: var(--accent-cyan); font-size: 0.8rem; font-weight: bold;">[ TREATED AS RAW MATERIAL ]</div>`;
} }
div.innerHTML = ` div.innerHTML = `