diff --git a/src/components/PartDescription.tsx b/src/components/PartDescription.tsx
index 900c883..e4d6bc5 100644
--- a/src/components/PartDescription.tsx
+++ b/src/components/PartDescription.tsx
@@ -2,7 +2,7 @@ import { Box, Typography } from "@mui/material";
import { type Messages, useMessages } from "../i18n";
import type { CCComponent } from "../store/component";
import { definitionByComponentId } from "../store/intrinsics/definitions";
-import { truthTableOf } from "../store/intrinsics/truthTable";
+import { type TruthTable, truthTableOf } from "../store/intrinsics/truthTable";
import { TruthTableView } from "./TruthTableView";
type Summaries = Messages["parts"]["summaries"];
@@ -19,10 +19,25 @@ export function partSummary(
export function PartDescription({ component }: { component: CCComponent }) {
const messages = useMessages();
- const summary = partSummary(messages, component);
const definition = definitionByComponentId.get(component.id);
- const table = definition && truthTableOf(definition);
+ return (
+
+ );
+}
+export function PartDescriptionView({
+ name,
+ summary,
+ table,
+}: {
+ name: string;
+ summary: string | null;
+ table: TruthTable | null;
+}) {
return (
- {component.name}
+ {name}
{summary &&
{summary}}
{table && (
diff --git a/src/i18n/en.ts b/src/i18n/en.ts
index 726a0ef..1dad934 100644
--- a/src/i18n/en.ts
+++ b/src/i18n/en.ts
@@ -134,9 +134,13 @@ export const en = {
title: "Both switches",
goal: "Make the lamp Out light up only when both switches A and B are ON. Drag parts from the Parts list onto the editor, and drag from pin to pin to connect them. The play button at the bottom right lets you try the switches. When it works, press Check.",
},
+ "a-only": {
+ title: "Only switch A",
+ goal: "Make the lamp Out light up only when switch A is ON and B is OFF. This time, one part alone is not enough.",
+ },
xor: {
title: "Only one switch",
- goal: "Make the lamp Out light up when exactly one of the switches A and B is ON. It does not light up when both are ON.",
+ goal: 'Make the lamp Out light up when exactly one of the switches A and B is ON. It does not light up when both are ON. "Only switch A" is ready to use as a part.',
},
},
},
diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts
index aac3d55..aa26f47 100644
--- a/src/i18n/ja.ts
+++ b/src/i18n/ja.ts
@@ -124,9 +124,13 @@ export const ja: Messages = {
title: "両方のスイッチ",
goal: "スイッチ A と B が両方 ON のときだけ、ランプ Out がつくようにしましょう。「部品」の一覧から部品をエディタにドラッグして置き、ピンからピンへドラッグしてつなぎます。右下の再生ボタンで、スイッチを切り替えて試せます。できたら「確かめる」を押してください。",
},
+ "a-only": {
+ title: "A だけのスイッチ",
+ goal: "スイッチ A が ON で、B が OFF のときだけ、ランプ Out がつくようにしましょう。今度は、部品を1つ置くだけではできません。",
+ },
xor: {
title: "片方だけのスイッチ",
- goal: "スイッチ A と B のどちらか片方だけが ON のときに、ランプ Out がつくようにしましょう。両方 ON のときはつきません。",
+ goal: "スイッチ A と B のどちらか片方だけが ON のときに、ランプ Out がつくようにしましょう。両方 ON のときはつきません。「A だけのスイッチ」を部品として使えます。",
},
},
},
diff --git a/src/pages/tutorial/stage.tsx b/src/pages/tutorial/stage.tsx
index 26a0103..4909b1e 100644
--- a/src/pages/tutorial/stage.tsx
+++ b/src/pages/tutorial/stage.tsx
@@ -18,7 +18,10 @@ import {
} from "react-router";
import { valueLabel } from "../../common/bitLabel";
import { ConfirmDialog } from "../../components/ConfirmDialog";
-import { PartDescription } from "../../components/PartDescription";
+import {
+ PartDescription,
+ PartDescriptionView,
+} from "../../components/PartDescription";
import { TruthTableView } from "../../components/TruthTableView";
import { type Messages, useMessages } from "../../i18n";
import type CCStore from "../../store";
@@ -38,8 +41,10 @@ import {
} from "../../tutorial/stageStore";
import {
findTutorialStage,
+ isStageComponent,
isStagePart,
isStagePinNode,
+ type StageTitleOf,
type TutorialStage,
tutorialStages,
} from "../../tutorial/stages";
@@ -96,11 +101,11 @@ function StageView({ stage }: { stage: TutorialStage }) {
const navigate = useNavigate();
const stageIndex = tutorialStages.indexOf(stage);
const nextStage = tutorialStages[stageIndex + 1];
- const componentName = texts.stageTexts[stage.id].title;
+ const titleOf: StageTitleOf = (id) => texts.stageTexts[id].title;
const goalTable = truthTableOfCheck(stage.check);
const [store, setStore] = useState(() =>
- getTutorialStageStore(stage, componentName),
+ getTutorialStageStore(stage, titleOf),
);
const [editedComponentId, setEditedComponentId] = useState(stage.componentId);
const [result, setResult] = useState
(null);
@@ -129,7 +134,7 @@ function StageView({ stage }: { stage: TutorialStage }) {
const resetStage = () => {
setIsConfirmingReset(false);
try {
- setStore(resetTutorialStage(stage, componentName));
+ setStore(resetTutorialStage(stage, titleOf));
setResetCount((count) => count + 1);
setEditedComponentId(stage.componentId);
setResult(null);
@@ -217,6 +222,16 @@ function StageView({ stage }: { stage: TutorialStage }) {
}
/>
))}
+ {stage.givenParts.map((id) => (
+
+ ))}