From b687cd97f6a7501f7a9f39e1e76e6020707a44d6 Mon Sep 17 00:00:00 2001 From: Pregmodder <pregmodder@gmail.com> Date: Wed, 14 Nov 2018 22:05:51 -0500 Subject: [PATCH] resync --- devNotes/twine JS.txt | 124 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 114 insertions(+), 10 deletions(-) diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt index 43e39ad5125..e20304b29cc 100644 --- a/devNotes/twine JS.txt +++ b/devNotes/twine JS.txt @@ -10440,6 +10440,7 @@ $slave.bellyPreg = WombGetWolume($slave) - return double, with current womb volu //Init womb system. window.WombInit = function(actor) { + if (!Array.isArray(actor.womb)) { //alert("creating new womb"); //debugging actor.womb = []; @@ -10458,10 +10459,11 @@ window.WombInit = function(actor) { //backward compatibility setup. Fully accurate for normal pregnancy only. if (actor.womb.length > 0 && actor.broodmother == 0 && actor.womb[0].genetics == undefined) { - var i; - for (i=0; i<actor.womb.length; i++) { - ft.genetics = generateGenetics(actor.ID, actor.pregSource, i+1); - } + var i=0 + actor.womb.forEach(function(ft){ + ft.genetics = generateGenetics(actor.ID, actor.pregSource, i); + i++; + }); } else if (actor.womb.length == 0 && actor.pregType != 0 && actor.broodmother == 0) { WombImpregnate(actor, actor.pregType, actor.pregSource, actor.preg); } else if (actor.womb.length == 0 && actor.pregType != 0 && actor.broodmother > 0 && actor.broodmotherOnHold < 1) { @@ -10702,6 +10704,7 @@ window.WombChangeID = function(actor, fromID, toID) { WombNormalizePreg(actor); }; + /* Sorts the womb object by age with oldest and thus soonest to be born, first. This will be needed in the future once individual fertilization is a possibility.*/ window.WombSort = function(actor) { actor.womb.sort((a, b) => { return b.age - a.age; }); @@ -10733,13 +10736,15 @@ window.fetalSplit = function(actor) { }; //safe alternative to .womb.length. -window.WombFetusCount(actor){ +window.WombFetusCount = function(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){ +window.WombGetFetus = function(actor, fetusNum) +{ WombInit(actor); if (actor.womb.length >= fetusNum) return actor.womb[fetusNum]; @@ -10748,18 +10753,20 @@ window.WombGetFetus = function(actor, fetusNum){ } //give reference to fetus object, and remove it form the womb. -window.WombRemoveFetus = function(actor, fetusNum){ +window.WombRemoveFetus = function(actor, fetusNum) +{ WombInit(actor); if (actor.womb.length >= fetusNum){ ft = actor.womb[fetusNum]; actor.womb.splice(fetusNum, 1); WombSort(actor); + return ft; } else 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. +/*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); @@ -10768,17 +10775,114 @@ window.WombAddFetus = function(actor, fetus) } // change property for all fetuses. Like fetus.age = X. -window.WombChangeFetus = function(actor, propName, newValue){ +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){ +window.WombChangeGene = function(actor, geneName, newValue) +{ WombInit(actor); actor.womb.forEach(ft => ft.genetic[geneName] = newValue); } +window.FetusGlobalReserveCount = function(reserveType) +{ + var cnt = 0; + var SV = State.variables; + + if (typeof reserveType != 'string' ) + return 0; + + SV.slaves.forEach(function(slave){ + slave.womb.forEach(function(ft){ + if (ft.reserved == reserveType) + cnt++; + }); + }); + + SV.PC.womb.forEach(function(ft){ + if (ft.reserved == reserveType) + cnt++; + }); + + return cnt; +} + +window.WombSetGenericReserve = function(actor, type, count) +{ + + actor.womb.forEach(function(ft){ + + if ((ft.reserve == "" || ft.reserve == type) && count > 0) + { + ft.reserve = type; + count--; + } + + }); +} + +window.WombCleanGenericReserve = function(actor, type, count) +{ + + actor.womb.forEach(function(ft){ + + if (ft.reserve == type && count > 0) + { + ft.reserve = ""; + count--; + } + + }); +} + +window.WombReserveCount = function(actor, type) +{ + + var cnt; + + actor.womb.forEach(function(ft){ + + if (ft.reserve == type) + { + cnt++; + } + + }); + + return cnt; +} + + +window.WombCleanAllReserve = function(actor) +{ + + actor.womb.forEach(function(ft){ + ft.reserve = ""; + }); + +} + +window.BCReserveInit = function() +{ + var SV = State.variables; + + SV.slaves.forEach(function(slave){ + slave.womb.forEach(function(ft){ + if (typeof ft.reserved != 'string') + ft.reserved = ""; + }); + }); + + SV.PC.womb.forEach(function(ft){ + if (typeof ft.reserved != 'string') + ft.reserved = ""; + }); +} + /* alt window.fetalSplit = function(actor) { -- GitLab