From 299aa0ca6861cea04e2cf100b0ccc43bbf3a486e Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:47:40 +0500 Subject: [PATCH] fixed bug w random pronoun picking at start --- src/components/np-picker/NPPicker.tsx | 4 +-- .../phrase-builder/PhraseBuilder.tsx | 2 ++ src/components/phrase-builder/VPDisplay.tsx | 32 ++++++++--------- src/lib/np-tools.ts | 35 ++++++++++--------- 4 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/components/np-picker/NPPicker.tsx b/src/components/np-picker/NPPicker.tsx index f473d90..4a85aa1 100644 --- a/src/components/np-picker/NPPicker.tsx +++ b/src/components/np-picker/NPPicker.tsx @@ -19,9 +19,7 @@ function NPPicker({ np, onChange, counterPart, asObject }: { onChange: (nps: NPS } function handleNPTypeChange(ntp: NPType) { if (ntp === "pronoun") { - const person = ((typeof counterPart === "object") && (counterPart.type === "pronoun")) - ? randomPerson({ counterPart: counterPart.person }) - : randomPerson(); + const person = randomPerson({ counterPart }); const pronoun: PronounSelection = { type: "pronoun", person, diff --git a/src/components/phrase-builder/PhraseBuilder.tsx b/src/components/phrase-builder/PhraseBuilder.tsx index 70c5473..012334a 100644 --- a/src/components/phrase-builder/PhraseBuilder.tsx +++ b/src/components/phrase-builder/PhraseBuilder.tsx @@ -54,6 +54,7 @@ export function PhraseBuilder() { const [subject, setSubject] = useState(undefined); const [verb, setVerb] = useState(undefined); function handleSubjectChange(subject: NPSelection | undefined) { + // check for pronoun conflict const objPronoun = (typeof verb?.object === "object" && verb.object.type === "pronoun") ? verb.object.person : undefined; @@ -71,6 +72,7 @@ export function PhraseBuilder() { function handleObjectChange(object: NPSelection | undefined) { if (!verb) return; if ((verb.object === "none") || (typeof verb.object === "number")) return; + // check for pronoun conflict if (object?.type === "pronoun" && subject?.type === "pronoun" && isInvalidSubjObjCombo(object.person, subject.person)) { alert("That combination of pronouns is not allowed"); return; diff --git a/src/components/phrase-builder/VPDisplay.tsx b/src/components/phrase-builder/VPDisplay.tsx index 9b04a3d..14c3e0b 100644 --- a/src/components/phrase-builder/VPDisplay.tsx +++ b/src/components/phrase-builder/VPDisplay.tsx @@ -21,23 +21,12 @@ function VPDisplay({ VP }: { VP: VPSelection }) { const [form, setForm] = useState({ removeKing: false, shrinkServant: false }); // TODO: Possibly put the servant shrinking in here after the render const result = compileVP(renderVP(VP), form); - // const servantShrinkable = VP.object && VP.object !== "none"; - // const toggleForm = (f: "removeKing" | "shrinkServant") => () => { - // setForm(oForm => ({ - // ...oForm, - // [f]: !oForm[f], - // })); - // } - const adjustable = VP.verb.transitivity === "transitive" - ? "both" - : VP.verb.transitivity === "intransitive" - ? "king" - // grammTrans - : isPastTense(VP.verb.tense) - ? "servant" - : "king"; return
- + {/*