From 16161ee23340690d824919177bc36a1ebab8e772 Mon Sep 17 00:00:00 2001 From: FCGudder <-@-> Date: Thu, 8 Jun 2017 07:14:48 +0200 Subject: [PATCH] Making it so that the arcology's continent's nationalities get preferred picks when the mother's nationality's name pool is exhausted. --- src/init/setupVars.tw | 13 +++++++++++++ src/pregmod/widgets/pregmodWidgets.tw | 13 ++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/init/setupVars.tw b/src/init/setupVars.tw index 6924667cc6c..a973e2a9379 100644 --- a/src/init/setupVars.tw +++ b/src/init/setupVars.tw @@ -25,6 +25,19 @@ <<set setup.africaNationalities = ["Algerian", "Congolese", "Ethiopian", "Ghanan", "Kenyan", "Libyan", "Malian", "Moroccan", "Nigerian", "South African", "Sudanese", "Tanzanian", "Tunisian", "Ugandan", "Zimbabwean"]>> <<set setup.australiaNationalities = ["Australian", "a New Zealander"]>> + +/* Nationalities based on $continent value. Note that $continent can be undefined! */ +<<set setup.nationalityPoolSelector = { + "North America": setup.northamericaNationalities, + "South America": setup.southamericaNationalities, + "Europe": setup.europeNationalities, + "Asia": setup.asiaNationalities, + "the Middle East": setup.middleeastNationalities, + "Africa": setup.africaNationalities, + "Australia": setup.australiaNationalities, + "Japan": setup.asiaNationalities, + "Brazil": setup.southamericaNationalities, +}>> /* END Custom Nationalities region filter */ diff --git a/src/pregmod/widgets/pregmodWidgets.tw b/src/pregmod/widgets/pregmodWidgets.tw index a871d1db313..91504b61e9a 100644 --- a/src/pregmod/widgets/pregmodWidgets.tw +++ b/src/pregmod/widgets/pregmodWidgets.tw @@ -988,6 +988,17 @@ extremely pale -5 || setup.whiteAmericanSlaveNames) .filter(sn => !_currentSlaveNames.includes(sn))>> <<set _maxTries = 10>> +<<if _namePool.length <= 0 && setup.nationalityPoolSelector[$continent]>> + <<set _continentNationality = setup.nationalityPoolSelector[$continent].random()>> + <<for _namePool.length <= 0 && _maxTries > 5>> + <<set _namePool = + (setup.namePoolSelector[_continentNationality + "." + $args[1].race] + || setup.namePoolSelector[_continentNationality] + || [] + .filter(sn => !_currentSlaveNames.includes(sn))>> + <<set _maxTries -= 1>> + <</for>> +<</if>> <<for _namePool.length <= 0 && _maxTries > 0>> <<set _namePool = Object.values(setup.namePoolSelector).random().filter(sn => !_currentSlaveNames.includes(sn))>> <<set _maxTries -= 1>> @@ -996,7 +1007,7 @@ extremely pale -5 <<set _namePool = Object.values(setup.namePoolSelector).random()>> <</if>> <<set $args[1].slaveName = _namePool.random()>> -<<unset _currentSlaveNames, _namePool, _maxTries>> +<<unset _currentSlaveNames, _namePool, _maxTries, _continentNationality>> <</widget>> <<widget "seBirthToIncubator">> -- GitLab