From c51d5f35b678afcfe2b8eaffc9b963066b8d0c20 Mon Sep 17 00:00:00 2001 From: pregmodfan <pregmodfan@cock.li> Date: Wed, 14 Nov 2018 03:05:25 +0200 Subject: [PATCH] more functions work and comments --- src/js/wombJS.tw | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/js/wombJS.tw b/src/js/wombJS.tw index b0771face5b..c44e21fc545 100644 --- a/src/js/wombJS.tw +++ b/src/js/wombJS.tw @@ -319,11 +319,13 @@ window.fetalSplit = function(actor) { WombNormalizePreg(actor); }; +//safe alternative to .womb.length. window.WombFetusCount(actor){ WombInit(actor); return actor.womb.length; } +//give reference to fetus object, but not remove fetus, use for manupulation in the womb. window.WombGetFetus = function(actor, fetusNum){ WombInit(actor); if (actor.womb.length >= fetusNum) @@ -332,6 +334,7 @@ window.WombGetFetus = function(actor, fetusNum){ return null; } +//give reference to fetus object, and remove it form the womb. window.WombRemoveFetus = function(actor, fetusNum){ WombInit(actor); if (actor.womb.length >= fetusNum){ @@ -343,6 +346,7 @@ window.WombRemoveFetus = function(actor, fetusNum){ return null; } +//to add fetus object in the womb. Be warned - you can add one single fetus to many wombs, or even add it many times to one womb. It's will not show error, but behavior become strange, as fetus object will be the same - it's reference, not full copies. If this not desired - use deepCopy on fetus before adding. window.WombAddFetus = function(actor, fetus) { WombInit(actor); @@ -350,6 +354,18 @@ window.WombAddFetus = function(actor, fetus) WombSort(actor); } +// change property for all fetuses. Like fetus.age = X. +window.WombChangeFetus = function(actor, propName, newValue){ + WombInit(actor); + actor.womb.forEach(ft => ft[propName] = newValue); +} + +// change genetic property of all fetuses. Like fetus.genetic.intelligence = X +window.WombChangeGene = function(actor, geneName, newValue){ + WombInit(actor); + actor.womb.forEach(ft => ft.genetic[geneName] = newValue); +} + /* alt window.fetalSplit = function(actor) { -- GitLab