diff --git a/src/facilities/nursery/utils/nurseryUtils.js b/src/facilities/nursery/utils/nurseryUtils.js index 5ead7a434f221fb0509efbf5f3730cd467fac6a1..704a719f8f2aecf7cfb3b9567a8b56f337994e03 100644 --- a/src/facilities/nursery/utils/nurseryUtils.js +++ b/src/facilities/nursery/utils/nurseryUtils.js @@ -404,25 +404,6 @@ App.Facilities.Nursery.nameChild = function nameChild(child) { } } - function parentNames(parent, child) { - const slaves = V.slaves; - - let currentSlaveNames = slaves.map(s => s.slaveName); - let continentNationality; - - child.slaveName = generateName(parent.nationality, parent.race, parent.genes === "XY", sn => !currentSlaveNames.includes(sn)); - - if (!child.slaveName) { - for (let i = 0; i < 10; i++) { - continentNationality = hashChoice(V.nationalities); - child.slaveName = generateName(continentNationality, child.race, child.genes === "XY", sn => !currentSlaveNames.includes(sn)); // jshint ignore: line - } - } - if (!child.slaveName) { - child.slaveName = generateName(parent.nationality, parent.race, parent.genes === "XY"); - } - } - r += `You can name the new child, if you so desire. `; r += `<br><<textbox "${child.slaveName}" ${child.slaveName}>>`; diff --git a/src/js/assayJS.js b/src/js/assayJS.js index af6f63c67d76bfa5bcc646fd00de394718dfbf8c..ed35411dddaece5c2dd9db63ebaeaf28f925880f 100644 --- a/src/js/assayJS.js +++ b/src/js/assayJS.js @@ -1189,6 +1189,26 @@ globalThis.PaternalistName = function(slave) { } }; +globalThis.parentNames = function(parent, child) { + const slaves = V.slaves; + + let currentSlaveNames = slaves.map(s => s.slaveName); + let continentNationality; + const useMaleName = (child.genes === "XY" && V.allowMaleSlaveNames === true); + + child.slaveName = generateName(parent.nationality, child.race, useMaleName, sn => !currentSlaveNames.includes(sn)); + + if (!child.slaveName) { + for (let i = 0; i < 10; i++) { + continentNationality = hashChoice(V.nationalities); + child.slaveName = generateName(continentNationality, child.race, useMaleName, sn => !currentSlaveNames.includes(sn)); // jshint ignore: line + } + } + if (!child.slaveName) { + child.slaveName = generateName(parent.nationality, child.race, useMaleName); + } +}; + globalThis.SlaveSort = function() { const effectivePreg = (slave) => { // slave.preg is only *mostly* usable for sorting diff --git a/src/npc/generate/newChildIntro.js b/src/npc/generate/newChildIntro.js index 17b7749c466772903b99f592ca513a4dcc4ad35d..7a57b3f661a74476c499e883e63d4b176e5d478c 100644 --- a/src/npc/generate/newChildIntro.js +++ b/src/npc/generate/newChildIntro.js @@ -249,7 +249,7 @@ App.UI.newChildIntro = function(slave) { App.UI.DOM.link( `Permit your Concubine to name ${his2} ${daughter}`, () => { - // <<ParentNames parent slave>> + parentNames(parent, slave); slave.birthName = slave.slaveName; jQuery("#naming").empty().append(`After some careful consideration, ${parent.slaveName} picks a name ${he2} thinks you might find attractive; from now on ${his2} ${daughter} will be known as "${slave.slaveName}".`); const slaveName = document.createElement("span"); @@ -266,7 +266,7 @@ App.UI.newChildIntro = function(slave) { App.UI.DOM.link( `Permit your ${wife2} to name ${his2} ${daughter}`, () => { - // <<ParentNames parent slave>> + parentNames(parent, slave); slave.birthName = slave.slaveName; jQuery("#naming").empty().append(`After some careful consideration,${parent.slaveName} picks a name suitable for your ${daughter}; from now on ${he2} will be known as "${slave.slaveName}".`); const slaveName = document.createElement("span"); @@ -283,7 +283,7 @@ App.UI.newChildIntro = function(slave) { App.UI.DOM.link( `Permit your bodyguard to name ${his2} ${daughter}`, () => { - // <<ParentNames parent slave>> + parentNames(parent, slave); slave.birthName = slave.slaveName; jQuery("#naming").empty().append(`After some careful consideration,${parent.slaveName} decides on "${slave.slaveName}" for ${his2} daughter. ${He2} hopes you'll find it fitting ${his} station.`); const slaveName = document.createElement("span"); @@ -300,7 +300,7 @@ App.UI.newChildIntro = function(slave) { App.UI.DOM.link( `Permit your Head Girl to name ${his2} ${daughter}`, () => { - // <<ParentNames parent slave>> + parentNames(parent, slave); slave.birthName = slave.slaveName; jQuery("#naming").empty().append(`After some careful consideration,${parent.slaveName} decides on "${slave.slaveName}" for ${his2} daughter, and hopes it will be a name your other slaves will learn to respect.`); const slaveName = document.createElement("span"); @@ -317,9 +317,9 @@ App.UI.newChildIntro = function(slave) { App.UI.DOM.link( `Permit ${his} devoted mother to name ${his2} ${daughter}`, () => { - // <<ParentNames parent slave>> + parentNames(parent, slave); slave.birthName = slave.slaveName; - jQuery("#naming").empty().append(`After some careful consideration,${tempMom.slaveName} picks a name ${he2} hopes you'll like; from now on ${his2} ${daughter} will be known as "${slave.slaveName}".`); + jQuery("#naming").empty().append(`After some careful consideration, ${tempMom.slaveName} picks a name ${he2} hopes you'll like; from now on ${his2} ${daughter} will be known as "${slave.slaveName}".`); const slaveName = document.createElement("span"); slaveName.classList.add('slave-name'); slaveName.append(slave.slaveName); diff --git a/src/pregmod/widgets/pregmodWidgets.tw b/src/pregmod/widgets/pregmodWidgets.tw index 7c09e278c80940e8852cf15e01908939648d6a24..54f8aa76a4aedb17a8c8796c27f5df8f848e1d75 100644 --- a/src/pregmod/widgets/pregmodWidgets.tw +++ b/src/pregmod/widgets/pregmodWidgets.tw @@ -170,44 +170,6 @@ <</replace>> <</widget>> -<<widget "ParentNames">> -<<set _currentSlaveNames = $slaves.map(s => s.slaveName)>> -<<if $allowMaleSlaveNames>> - <<set _sanityCheck = '>>', /* to appease sanityCheck */ - $args[1].slaveName = generateName($args[0].nationality, $args[1].race, $args[1].genes === "XY", sn => !_currentSlaveNames.includes(sn))>> - <<if !$args[1].slaveName>> - /* we ran out of names ... How? */ - <<set _maxTries = 10>> - <<for _maxTries > 0 && !$args[1].slaveName>> - <<set _continentNationality = hashChoice($nationalities)>> - <<set _sanityCheck = '>>', /* to appease sanityCheck */ - $args[1].slaveName = generateName(_continentNationality, $args[1].race, $args[1].genes === "XY", sn => !_currentSlaveNames.includes(sn))>> - <</for>> - <</if>> - <<if !$args[1].slaveName>> - /* give up, duplicate name is fine I guess */ - <<set $args[1].slaveName = generateName($args[0].nationality, $args[1].race, $args[1].genes === "XY")>> - <</if>> -<<else>> - <<set _sanityCheck = '>>', /* to appease sanityCheck */ - $args[1].slaveName = generateName($args[0].nationality, $args[1].race, false, sn => !_currentSlaveNames.includes(sn))>> - <<if !$args[1].slaveName>> - /* we ran out of names ... How? */ - <<set _maxTries = 10>> - <<for _maxTries > 0 && !$args[1].slaveName>> - <<set _continentNationality = hashChoice($nationalities)>> - <<set _sanityCheck = '>>', /* to appease sanityCheck */ - $args[1].slaveName = generateName(_continentNationality, $args[1].race, false, sn => !_currentSlaveNames.includes(sn))>> - <</for>> - <</if>> - <<if !$args[1].slaveName>> - /* give up, duplicate name is fine I guess */ - <<set $args[1].slaveName = generateName($args[0].nationality, $args[1].race, false)>> - <</if>> -<</if>> -<<unset _currentSlaveNames, _maxTries, _continentNationality>> -<</widget>> - <<widget "AgePCEffects">> <<switch $PC.actualAge>> <<case 3>>