Skip to content

Commit

Permalink
Check solution based on recipe[solution].output
Browse files Browse the repository at this point in the history
  • Loading branch information
zachpmanson committed Feb 22, 2024
1 parent dc94d84 commit 997a5a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/components/CraftingTable.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function CraftingTable({
colorTables,
setColorTables,
setGameState,
recipes,
options: { highContrast },
} = useGlobal();

Expand Down Expand Up @@ -111,7 +112,11 @@ export default function CraftingTable({
};

const processGuess = () => {
if (currentRecipe?.replace("minecraft:", "") === solution) {
console.log("processGuess", currentRecipe, solution);
if (
currentRecipe?.replace("minecraft:", "") ===
recipes[solution].output.replace("minecraft:", "")
) {
setColorTable([
[2, 2, 2],
[2, 2, 2],
Expand Down
8 changes: 4 additions & 4 deletions src/components/Popup.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default function Popup({
craftingTables,
colorTables,
userId,
recipes,
items,
options: { highContrast },
resetGame,
} = useGlobal();
Expand Down Expand Up @@ -65,9 +67,7 @@ export default function Popup({
};

// get name of solution item for label
const { items } = useGlobal();
const solutionName =
"minecraft:" + solution ? items["minecraft:" + solution]?.name : undefined;
const solutionName = items[recipes[solution].output].name;

return (
<>
Expand Down Expand Up @@ -98,7 +98,7 @@ export default function Popup({
>
<Dialog.Panel className="w-full max-w-sm transform overflow-hidden rounded-2xl inv-background text-left align-middle shadow-xl transition-all">
<div className="flex flex-col items-center gap-2">
<Slot item={`minecraft:${solution}`} clickable={false} />
<Slot item={recipes[solution].output} clickable={false} />
<Dialog.Description className="text-med font-medium leading-6 text-gray-900">
{`Solution: ` + solutionName}
</Dialog.Description>
Expand Down

0 comments on commit 997a5a7

Please sign in to comment.