From 9d7ee4269fdf772c01b1861c6f5ff0d2dee45bd4 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Sat, 22 Feb 2020 23:11:30 -0800 Subject: [PATCH] 1. Add a new function to introduce a slave based on their relationship to an already on-screen actor (i.e. "her husband John" or "your daughter and lover Alice"). 2. Add a function to return the PC relationship term (lover/wife/husband) for slaves in a relationship with the PC, and use it in the slave summary. --- devNotes/Useful JS Function Documentation.txt | 10 ++++ src/js/relationshipChecks.js | 55 +++++++++++++++++++ src/js/slaveSummaryWidgets.js | 21 ++----- 3 files changed, 71 insertions(+), 15 deletions(-) diff --git a/devNotes/Useful JS Function Documentation.txt b/devNotes/Useful JS Function Documentation.txt index b51924b0d31..e42c5767a48 100644 --- a/devNotes/Useful JS Function Documentation.txt +++ b/devNotes/Useful JS Function Documentation.txt @@ -173,6 +173,16 @@ relationshipChecks [script] All work as expected with <<if X.rivalryTarget == $s relationshipTermShort(id) Prints the short form of the above. e.g. line 321 of slaveInteract. `"Fuck $him with $his <<print relationshipTermShort($activeSlave)>> <<= SlaveFullName($slaves[_si])>>"` Would print 'Fuck $him with $his BFF <<= SlaveFullName($slaves[_si])>>' + + PCrelationshipTerm(id) Prints the relationship term for the input (relative to the PC) if the relationship is < -1. + <<if $slaves[$i].relationship < -1>> + $He loves being your <<print PCrelationshipTerm($slaves[$i])>>. + Would print '$He loves being your wife.' + + contextualIntro(context, actor, insertComma=false) - Introduces an actor by using any meaningful relationship(s) with an already on-screen actor, and their name. + Returns strings like: "your husband John", "his mother and growing rival Alice", or "her twin sister and best friend Carla". + If there is no known relationship between them, retuns the name alone. If insertComma is true, it will generate "her father, Dave" instead of "her father Dave". + Use this function instead of just printing the slave's name when you'd like to let the player to know if two actors are related, even though it's not going to have any mechanical impact on the scene. bellyAdjective(slave) - Returns a string describing her belly size. diff --git a/src/js/relationshipChecks.js b/src/js/relationshipChecks.js index 284e052c667..54ec0490609 100644 --- a/src/js/relationshipChecks.js +++ b/src/js/relationshipChecks.js @@ -47,3 +47,58 @@ window.relationshipTermShort = function(id) { return `${getPronouns(id).wife}`; } }; + +/** + * @param {{ relationship: number; }} id + * @returns {string} + */ +window.PCrelationshipTerm = function(id) { + if (id.relationship === -2) { + return "lover"; + } else if (id.relationship === -3) { + return `${getPronouns(id).wife}`; + } +}; + +/** + * Introduces an actor by using any meaningful relationship(s) with an already on-screen actor, and their name. + * Returns strings like: "your husband John", "his mother and growing rival Alice", or "her twin sister and best friend Carla". + * If there is no known relationship between them, retuns the name alone. + * Use this function instead of just printing the slave's name when you'd like to let the player to know if two actors are related, + * even though it's not going to have any mechanical impact on the scene. + * @param {App.Entity.SlaveState|App.Entity.PlayerState} context + * @param {App.Entity.SlaveState|App.Entity.PlayerState} actor + * @param {boolean} [insertComma=false] - when true, if a relationship is found, it will be separated from the actor's name by a comma ("her father, Dave" instead of "her father Dave") + * @returns {string} + */ +window.contextualIntro = function(context, actor, insertComma=false) { + let first = true; + let r = ``; + const firstPreamble = (context === V.PC) ? "your" : getPronouns(context).possessive; + let preamble = () => { + let s = first ? `${firstPreamble} ` : ` and `; + first = false; + return s; + }; + + const _relative = relativeTerm(context, actor); + if (_relative) { + r += preamble() + _relative; + } + + if (context.relationship > 0 && context.relationshipTarget === actor.ID) { + r += preamble() + relationshipTerm(context); + } else if (context === V.PC && actor.relationship < -1) { + r += preamble() + PCrelationshipTerm(actor); + } else if (actor === V.PC && context.relationship < -1) { + r += preamble() + PCrelationshipTerm(context); + } else if (context.rivalry > 0 && context.rivalryTarget === actor.ID) { + r += preamble() + rivalryTerm(context); + } + + if (r !== ``) { + r += (insertComma || actor === V.PC) ? ", " : " "; + } + r += actor === V.PC ? "you" : actor.slaveName; + return r; +}; diff --git a/src/js/slaveSummaryWidgets.js b/src/js/slaveSummaryWidgets.js index 8d7236d2f77..48258a7302a 100644 --- a/src/js/slaveSummaryWidgets.js +++ b/src/js/slaveSummaryWidgets.js @@ -3831,11 +3831,8 @@ window.SlaveSummaryUncached = (function() { } } else if (slave.mother === -1) { addText(block, `Your `); - if (slave.relationship === -3) { - makeSpan(block, `${getPronouns(slave).daughter} and ${getPronouns(slave).wife}.`, "lightgreen"); - handled = 1; - } else if (slave.relationship === -2) { - makeSpan(block, `${getPronouns(slave).daughter} and lover.`, "lightgreen"); + if (slave.relationship < -1) { + makeSpan(block, `${getPronouns(slave).daughter} and ${PCrelationshipTerm(slave)}.`, "lightgreen"); handled = 1; } else { makeSpan(block, `${getPronouns(slave).daughter}.`, "lightgreen"); @@ -3858,11 +3855,8 @@ window.SlaveSummaryUncached = (function() { } } else if (slave.father === -1 && slave.father !== slave.mother) { addText(block, `Your `); - if (slave.relationship === -3) { - makeSpan(block, `${getPronouns(slave).daughter} and ${getPronouns(slave).wife}.`, "lightgreen"); - handled = 1; - } else if (slave.relationship === -2) { - makeSpan(block, `${getPronouns(slave).daughter} and lover.`, "lightgreen"); + if (slave.relationship < -1) { + makeSpan(block, `${getPronouns(slave).daughter} and ${PCrelationshipTerm(slave)}.`, "lightgreen"); handled = 1; } else { makeSpan(block, `${getPronouns(slave).daughter}.`, "lightgreen"); @@ -3873,11 +3867,8 @@ window.SlaveSummaryUncached = (function() { } if (areSisters(V.PC, slave) > 0) { addText(block, `Your `); - if (slave.relationship === -3) { - makeSpan(block, `${relativeTerm(V.PC, slave)} and ${getPronouns(slave).wife}.`, "lightgreen"); - handled = 1; - } else if (slave.relationship === -2) { - makeSpan(block, `${relativeTerm(V.PC, slave)} and lover.`, "lightgreen"); + if (slave.relationship < -1) { + makeSpan(block, `${relativeTerm(V.PC, slave)} and ${PCrelationshipTerm(slave)}.`, "lightgreen"); handled = 1; } else { makeSpan(block, `${relativeTerm(V.PC, slave)}.`, "lightgreen"); -- GitLab