From 5da6aa1dd63a7f946c46981be58d0daeb88e98ac Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Wed, 6 May 2020 17:21:12 -0700 Subject: [PATCH] Rework explicit enunciation for javascript passages --- src/events/RESS/hotPC.js | 6 +- src/events/RESS/lazyEvening.js | 6 +- src/events/RESS/waistlineWoes.js | 3 +- src/facilities/nursery/nurseryWidgets.js | 13 +- src/js/assayJS.js | 226 +++++++++++++---------- src/js/modification.js | 8 +- 6 files changed, 136 insertions(+), 126 deletions(-) diff --git a/src/events/RESS/hotPC.js b/src/events/RESS/hotPC.js index f31d4645ba7..ae3b365f08e 100644 --- a/src/events/RESS/hotPC.js +++ b/src/events/RESS/hotPC.js @@ -28,11 +28,7 @@ App.Events.RESSHotPC = class RESSHotPC extends App.Events.BaseEvent { const { He, he, His, his, hers, him, himself, girl } = getPronouns(eventSlave); - Enunciate(eventSlave); - const s = V.sEnunciate; - const S = V.SEnunciate; - const ss = V.ssEnunciate; - const Master = V.titleEnunciate; + const {s, S, ss, title: Master} = getEnunciation(eventSlave); /** @type {App.Entity.PlayerState} */ let PC = V.PC; diff --git a/src/events/RESS/lazyEvening.js b/src/events/RESS/lazyEvening.js index 462ba575832..4244b247d1f 100644 --- a/src/events/RESS/lazyEvening.js +++ b/src/events/RESS/lazyEvening.js @@ -20,7 +20,7 @@ App.Events.RESSLazyEvening = class RESSLazyEvening extends App.Events.BaseEvent const { He, he, His, his, hers, him, himself, girl, woman } = getPronouns(eventSlave); - Enunciate(eventSlave); + const {s, title} = getEnunciation(eventSlave); V.nextLink = "Next Week"; @@ -60,9 +60,9 @@ App.Events.RESSLazyEvening = class RESSLazyEvening extends App.Events.BaseEvent if (!canTalk(eventSlave)) { t.push(`asks with a gesture that carries just the right mixture of submission and exaggerated casualness if you'd like to 'hang out.'`); } else if (SlaveStatsChecker.checkForLisp(eventSlave)) { - t.push(`lisps with exaggerated casualness, "Let'${V.sEnunciate} hang out, ${V.titleEnunciate}?"`); + t.push(`lisps with exaggerated casualness, "Let'${s} hang out, ${title}?"`); } else { - t.push(`asks with exaggerated casualness, "Want to hang out, ${V.titleEnunciate}?"`); + t.push(`asks with exaggerated casualness, "Want to hang out, ${title}?"`); } App.Events.addParagraph(node, t); diff --git a/src/events/RESS/waistlineWoes.js b/src/events/RESS/waistlineWoes.js index 442e70bdc2c..9cec258f2d1 100644 --- a/src/events/RESS/waistlineWoes.js +++ b/src/events/RESS/waistlineWoes.js @@ -22,8 +22,7 @@ App.Events.RESSWaistlineWoes = class RESSWaistlineWoes extends App.Events.BaseEv const { He, he, His, his, hers, him, himself, girl } = getPronouns(eventSlave); - Enunciate(eventSlave); - const Master = V.titleEnunciate; + const {title: Master} = getEnunciation(eventSlave); V.nextLink = "Next Week"; diff --git a/src/facilities/nursery/nurseryWidgets.js b/src/facilities/nursery/nurseryWidgets.js index 5b9b90fb6f4..77b51dcf7f7 100644 --- a/src/facilities/nursery/nurseryWidgets.js +++ b/src/facilities/nursery/nurseryWidgets.js @@ -10298,18 +10298,7 @@ App.Facilities.Nursery.LongChildDescription = function(child) { } function master(child) { - let - r = ``; - - if (jsDef(child)) { - Enunciate(child); - } else if (!jsDef(V.titleEnunciate)) { - Enunciate(child); - } - - r += `${V.titleEnunciate}`; - - return r; + return getEnunciation(child).title; } function mouth(child) { diff --git a/src/js/assayJS.js b/src/js/assayJS.js index 6bcff58fde6..1610d9c37ed 100644 --- a/src/js/assayJS.js +++ b/src/js/assayJS.js @@ -410,66 +410,95 @@ globalThis.getNonlocalPronouns = function(dickRatio) { return getPronouns(slave); }; -/** +/** Get the written title for a given slave, without messing with global state. * @param {App.Entity.SlaveState} slave * @returns {string} */ +globalThis.getWrittenTitle = function(slave) { + if (slave.custom.title !== undefined && slave.custom.title !== "" && slave.rudeTitle === 0) { + return slave.custom.title; + } + if (V.PC.customTitle !== undefined) { + return V.PC.customTitle; + } else if (V.PC.title !== 0) { + return "Master"; + } else { + return "Mistress"; + } +}; + +/** Get the written title for a given slave, or for the most recently enunciated slave, write it into global state, and return it. + * @param {App.Entity.SlaveState} [slave] + * @returns {string} + */ globalThis.WrittenMaster = function(slave) { if (slave !== undefined) { - Enunciate(slave); - } else if (V.titleEnunciate === undefined) { - Enunciate(V.activeSlave); + V.writtenTitle = getWrittenTitle(slave); + } else if (V.writtenTitle === undefined) { + V.writtenTitle = getWrittenTitle(V.activeSlave); } return V.writtenTitle; }; -/** +/** Get all the enunciations used by a particular slave as a destructurable object. * @param {App.Entity.SlaveState} slave + * @returns {{title: string, say: string, + * s: string, S: string, ss: string, + * c: string, C: string, cc: string, + * z: string, Z: string, zz: string, + * ch: string, Ch: string, + * ps: string, Ps: string, + * sh: string, Sh: string, + * sc: string, Sc: string, + * sch: string, Sch: string, + * x: string, X: string}} */ -globalThis.Enunciate = function(slave) { +globalThis.getEnunciation = function(slave) { + let ret = {}; + if (SlaveStatsChecker.checkForLisp(slave)) { if (V.PC.customTitleLisp !== undefined) { - V.titleEnunciate = V.PC.customTitleLisp; + ret.title = V.PC.customTitleLisp; } else if (V.PC.title !== 0) { - V.titleEnunciate = "Mathter"; + ret.title = "Mathter"; } else { - V.titleEnunciate = "Mithtreth"; + ret.title = "Mithtreth"; } if (V.allowFamilyTitles === 1) { if (slave.father === -1) { if (slave.actualAge < 4 && slave.physicalAge < 4) { - V.titleEnunciate = "Dadda"; + ret.title = "Dadda"; } else if (slave.actualAge < 9) { - V.titleEnunciate = "Daddy"; + ret.title = "Daddy"; } else { - V.titleEnunciate = "Dad"; + ret.title = "Dad"; } } else if (slave.mother === -1) { if (slave.actualAge < 4 && slave.physicalAge < 4) { - V.titleEnunciate = "Mama"; + ret.title = "Mama"; } else if (slave.actualAge < 9) { - V.titleEnunciate = "Mommy"; + ret.title = "Mommy"; } else { - V.titleEnunciate = "Mom"; + ret.title = "Mom"; } } else if (V.PC.mother === slave.ID || V.PC.father === slave.ID) { if (V.PC.title === 1) { - V.titleEnunciate = "Thon"; + ret.title = "Thon"; } else if (V.PC.title === 0) { - V.titleEnunciate = "Daughter"; + ret.title = "Daughter"; } } else if (areSisters(slave, V.PC) > 0) { if (V.PC.title === 1) { if (slave.actualAge < 18) { - V.titleEnunciate = "Bro"; + ret.title = "Bro"; } else { - V.titleEnunciate = "Brother"; + ret.title = "Brother"; } } else if (V.PC.title === 0) { if (slave.actualAge < 18) { - V.titleEnunciate = "Thith"; + ret.title = "Thith"; } else { - V.titleEnunciate = "Thithter"; + ret.title = "Thithter"; } } } @@ -477,77 +506,77 @@ globalThis.Enunciate = function(slave) { if (slave.custom.titleLisp !== undefined && slave.custom.titleLisp !== "") { if (slave.rudeTitle === 1) { if (slave.trust > 20) { - V.titleEnunciate = slave.custom.titleLisp; + ret.title = slave.custom.titleLisp; } } else { - V.titleEnunciate = slave.custom.titleLisp; + ret.title = slave.custom.titleLisp; } } - V.sayEnunciate = "lisp"; - V.sEnunciate = "th"; - V.SEnunciate = "Th"; - V.ssEnunciate = "th"; - V.cEnunciate = "th"; - V.CEnunciate = "Th"; - V.ccEnunciate = "kth"; - V.zEnunciate = "th"; - V.ZEnunciate = "Th"; - V.zzEnunciate = "th"; - V.chEnunciate = "th"; - V.ChEnunciate = "Th"; - V.psEnunciate = "th"; - V.PsEnunciate = "Th"; - V.shEnunciate = "th"; - V.ShEnunciate = "Th"; - V.scEnunciate = "th"; - V.ScEnunciate = "Th"; - V.schEnunciate = "th"; - V.SchEnunciate = "Th"; - V.xEnunciate = "kth"; - V.XEnunciate = "Th"; + ret.say = "lisp"; + ret.s = "th"; + ret.S = "Th"; + ret.ss = "th"; + ret.c = "th"; + ret.C = "Th"; + ret.cc = "kth"; + ret.z = "th"; + ret.Z = "Th"; + ret.zz = "th"; + ret.ch = "th"; + ret.Ch = "Th"; + ret.ps = "th"; + ret.Ps = "Th"; + ret.sh = "th"; + ret.Sh = "Th"; + ret.sc = "th"; + ret.Sc = "Th"; + ret.sch = "th"; + ret.Sch = "Th"; + ret.x = "kth"; + ret.X = "Th"; } else { if (V.PC.customTitle !== undefined) { - V.titleEnunciate = V.PC.customTitle; + ret.title = V.PC.customTitle; } else if (V.PC.title !== 0) { - V.titleEnunciate = "Master"; + ret.title = "Master"; } else { - V.titleEnunciate = "Mistress"; + ret.title = "Mistress"; } if (V.allowFamilyTitles === 1) { if (slave.father === -1) { if (slave.actualAge < 4 && slave.physicalAge < 4) { - V.titleEnunciate = "Dadda"; + ret.title = "Dadda"; } else if (slave.actualAge < 9) { - V.titleEnunciate = "Daddy"; + ret.title = "Daddy"; } else { - V.titleEnunciate = "Dad"; + ret.title = "Dad"; } } else if (slave.mother === -1) { if (slave.actualAge < 4 && slave.physicalAge < 4) { - V.titleEnunciate = "Mama"; + ret.title = "Mama"; } else if (slave.actualAge < 9) { - V.titleEnunciate = "Mommy"; + ret.title = "Mommy"; } else { - V.titleEnunciate = "Mom"; + ret.title = "Mom"; } } else if (V.PC.mother === slave.ID || V.PC.father === slave.ID) { if (V.PC.title === 1) { - V.titleEnunciate = "Son"; + ret.title = "Son"; } else if (V.PC.title === 0) { - V.titleEnunciate = "Daughter"; + ret.title = "Daughter"; } } else if (areSisters(slave, V.PC) > 0) { if (V.PC.title === 1) { if (slave.actualAge < 18) { - V.titleEnunciate = "Bro"; + ret.title = "Bro"; } else { - V.titleEnunciate = "Brother"; + ret.title = "Brother"; } } else if (V.PC.title === 0) { if (slave.actualAge < 18) { - V.titleEnunciate = "Sis"; + ret.title = "Sis"; } else { - V.titleEnunciate = "Sister"; + ret.title = "Sister"; } } } @@ -555,46 +584,50 @@ globalThis.Enunciate = function(slave) { if (slave.custom.title !== undefined && slave.custom.title !== "") { if (slave.rudeTitle === 1) { if (slave.trust > 20) { - V.titleEnunciate = slave.custom.title; + ret.title = slave.custom.title; } } else { - V.titleEnunciate = slave.custom.title; + ret.title = slave.custom.title; } } - V.sayEnunciate = "say"; - V.sEnunciate = "s"; - V.SEnunciate = "S"; - V.ssEnunciate = "ss"; - V.cEnunciate = "c"; - V.CEnunciate = "C"; - V.ccEnunciate = "cc"; - V.zEnunciate = "z"; - V.ZEnunciate = "Z"; - V.zzEnunciate = "zz"; - V.chEnunciate = "ch"; - V.ChEnunciate = "Ch"; - V.psEnunciate = "ps"; - V.PsEnunciate = "Ps"; - V.shEnunciate = "sh"; - V.ShEnunciate = "Sh"; - V.scEnunciate = "sc"; - V.ScEnunciate = "Sc"; - V.schEnunciate = "sch"; - V.SchEnunciate = "Sch"; - V.xEnunciate = "x"; - V.XEnunciate = "X"; - } - // writtenTitle should be defined outside of the lispCheck. - if (V.PC.customTitle !== undefined) { - V.writtenTitle = V.PC.customTitle; - } else if (V.PC.title !== 0) { - V.writtenTitle = "Master"; - } else { - V.writtenTitle = "Mistress"; + ret.say = "say"; + ret.s = "s"; + ret.S = "S"; + ret.ss = "ss"; + ret.c = "c"; + ret.C = "C"; + ret.cc = "cc"; + ret.z = "z"; + ret.Z = "Z"; + ret.zz = "zz"; + ret.ch = "ch"; + ret.Ch = "Ch"; + ret.ps = "ps"; + ret.Ps = "Ps"; + ret.sh = "sh"; + ret.Sh = "Sh"; + ret.sc = "sc"; + ret.Sc = "Sc"; + ret.sch = "sch"; + ret.Sch = "Sch"; + ret.x = "x"; + ret.X = "X"; } - if (slave.custom.title !== undefined && slave.custom.title !== "" && slave.rudeTitle === 0) { - V.writtenTitle = slave.custom.title; + + return ret; +}; + +/** Write all of the enunciations used by a slave into global state data for use by sugarcube macros. + * @param {App.Entity.SlaveState} slave + */ +globalThis.Enunciate = function(slave) { + const enunc = getEnunciation(slave); + + for (const e in enunc) { + V[`${e}Enunciate`] = enunc[e]; } + + V.writtenTitle = getWrittenTitle(slave); }; /** @@ -671,8 +704,7 @@ globalThis.SlaveFullBirthName = function(slave) { */ globalThis.PoliteRudeTitle = function(slave) { const PC = V.PC; - const s = V.sEnunciate; - const ss = V.ssEnunciate; + const {s, ss, title} = getEnunciation(slave); let r = ""; if (slave.nationality === "Japanese") { @@ -683,7 +715,7 @@ globalThis.PoliteRudeTitle = function(slave) { } } else { if (slave.intelligence + slave.intelligenceImplant < -95) { - r += V.titleEnunciate; + r += title; } else if (slave.intelligence + slave.intelligenceImplant > 50) { r += (PC.title > 0 ? `Ma${s}ter` : `Mi${s}tre${ss}`); } else if (slave.trust > 0) { diff --git a/src/js/modification.js b/src/js/modification.js index 22ebcb17430..25be7b72c5a 100644 --- a/src/js/modification.js +++ b/src/js/modification.js @@ -336,13 +336,7 @@ App.Medicine.Modification.setTattoo = function(slave, location, design) { // reaction const {He, he, His, his, him} = getPronouns(slave); - Enunciate(slave); // TODO: it'd be nice to return a deconstructable object from Enunciate like we do from getPronouns... - const s = V.sEnunciate; - const ss = V.sEnunciate; - const x = V.xEnunciate; - const c = V.cEnunciate; - const Master = V.titleEnunciate; - const say = V.sayEnunciate; + const {s, ss, x, c, say, title: Master} = getEnunciation(slave); let r = ` `; if (location === "anus" && design !== 0) { if (canSee(slave) && canTalk(slave)) { -- GitLab