diff --git a/src/js/womb.js b/src/js/womb.js index 032ef0fb95adc437a423808a5c0465282ee50e21..4525654c12cfbb1dc6f552cbe20d0546706b1de5 100644 --- a/src/js/womb.js +++ b/src/js/womb.js @@ -25,6 +25,7 @@ $slave.bellyPreg = WombGetWolume($slave) - return double, with current womb volu //Init womb system. window.WombInit = function(actor) { + let i; if (!Array.isArray(actor.womb)) { //alert("creating new womb"); //debugging @@ -51,7 +52,7 @@ window.WombInit = function(actor) { //backward compatibility setup. Fully accurate for normal pregnancy only. if (actor.womb.length > 0 && actor.womb[0].genetics == undefined && actor.eggType == "human") { - var i=0 + i=0; actor.womb.forEach(function(ft){ ft.genetics = generateGenetics(actor, actor.pregSource, i); i++; @@ -60,7 +61,7 @@ window.WombInit = function(actor) { WombImpregnate(actor, actor.pregType, actor.pregSource, actor.preg); } else if (actor.womb.length == 0 && actor.pregType > 0 && actor.broodmother > 0 && actor.broodmotherOnHold < 1) { //sorry but for already present broodmothers it's impossible to calculate fully, approximation used. - var i, pw = actor.preg, bCount, bLeft; + var pw = actor.preg, bCount, bLeft; if (pw > actor.pregData.normalBirth) pw = actor.pregData.normalBirth; //to avoid disaster. bCount = Math.floor(actor.pregType/pw); bLeft = actor.pregType - (bCount*pw); @@ -186,7 +187,6 @@ window.WombImpregnateClone = function(actor, fCount, mother, motherOriginal, age }; window.WombProgress = function(actor, ageToAdd) { - var i, ft; ageToAdd = Math.ceil(ageToAdd*10)/10; try { actor.womb.forEach(ft => ft.age += ageToAdd); @@ -220,7 +220,6 @@ window.WombFlush = function(actor) { }; window.WombBirthReady = function(actor, readyAge) { - var i, ft; var readyCnt = 0; try { readyCnt += actor.womb.filter(ft => ft.age >= readyAge).length; @@ -279,12 +278,11 @@ window.WombGetVolume = function(actor) { //most legacy code from pregJS.tw with } function getVolByLen(actor){ + let phi = 1.618; + let targetData, targetLen; + let wombSize = 0; - try { - - var phi = 1.618; - var targetData, targetLen; - var wombSize = 0; + try { actor.womb.forEach(ft => { @@ -502,7 +500,6 @@ window.WombSort = function(actor) { //now function work with chance. Literary we give it "one from X" as chance. window.fetalSplit = function(actor, chance) { - var i, ft; var nft; actor.womb.forEach(function(s){ @@ -536,7 +533,7 @@ window.WombFetusCount = function(actor) { WombInit(actor); return actor.womb.length; -} +}; //give reference to fetus object, but not remove fetus, use for manipulation in the womb. window.WombGetFetus = function(actor, fetusNum) @@ -546,7 +543,7 @@ window.WombGetFetus = function(actor, fetusNum) return actor.womb[fetusNum]; else return null; -} +}; //give reference to fetus object, and remove it form the womb. window.WombRemoveFetus = function(actor, fetusNum) @@ -561,7 +558,7 @@ window.WombRemoveFetus = function(actor, fetusNum) } 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 clone() on fetus before adding.*/ window.WombAddFetus = function(actor, fetus) @@ -569,21 +566,21 @@ window.WombAddFetus = function(actor, fetus) WombInit(actor); actor.womb.push(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.genetics[geneName] = newValue); -} +}; // replaces untraceable fatherIDs with missingParentID. Required for concurrent pregnancy to differentiate between siblings. window.MissingParentIDCorrection = function(actor) { @@ -592,7 +589,7 @@ window.MissingParentIDCorrection = function(actor) { .filter(ft => (ft.genetics.father === 0 || (ft.genetics.father < -1 && ft.genetics.father >= -20 && ft.genetics.father !== -3))) .forEach(ft => ft.genetics.father = State.variables.missingParentID); State.variables.missingParentID--; -} +}; window.WombCleanYYFetuses = function(actor) { @@ -616,7 +613,7 @@ window.WombCleanYYFetuses = function(actor) actor.pregType = actor.womb.length; return reserved; -} +}; window.FetusGlobalReserveCount = function(reserveType) { @@ -639,7 +636,7 @@ window.FetusGlobalReserveCount = function(reserveType) }); return cnt; -} +}; window.WombSetGenericReserve = function(actor, type, count) { @@ -654,14 +651,14 @@ window.WombSetGenericReserve = function(actor, type, count) } }); -} +}; window.WombAddToGenericReserve = function(actor, type, count) { WombSetGenericReserve(actor, type, (WombReserveCount(actor, type)+count)); -} +}; window.WombChangeReserveType = function(actor, oldType, newType) { @@ -677,7 +674,7 @@ window.WombChangeReserveType = function(actor, oldType, newType) }); return count; -} +}; window.WombCleanGenericReserve = function(actor, type, count) { @@ -691,7 +688,7 @@ window.WombCleanGenericReserve = function(actor, type, count) } }); -} +}; window.WombReserveCount = function(actor, type) { @@ -708,7 +705,7 @@ window.WombReserveCount = function(actor, type) }); return cnt; -} +}; window.WombGetReservedFetuses = function(actor, type) { @@ -724,7 +721,7 @@ window.WombGetReservedFetuses = function(actor, type) }); return reserved; -} +}; window.WombRemoveReservedFetuses = function(actor, type) { @@ -747,7 +744,7 @@ window.WombRemoveReservedFetuses = function(actor, type) } return reserved; -} +}; window.WombCleanAllReserve = function(actor) { @@ -756,7 +753,7 @@ window.WombCleanAllReserve = function(actor) ft.reserve = ""; }); -} +}; window.BCReserveInit = function() { @@ -768,22 +765,21 @@ window.BCReserveInit = function() { if (typeof ft.reserve != 'string') ft.reserve = ""; - if (typeof ft.motherID != 'number') //setting missing biological mother ID for fetus. - ft.motherID = slave.ID; - - if (ft.ID == undefined) - ft.ID = generateNewID(); - + if (typeof ft.motherID != 'number') //setting missing biological mother ID for fetus. + ft.motherID = slave.ID; + if (ft.ID == undefined) + ft.ID = generateNewID(); }); }); SV.PC.womb.forEach(function(ft){ if (typeof ft.reserve != 'string') ft.reserve = ""; + if (typeof ft.motherID !== 'number') ft.motherID = SV.PC.ID; - }); + }); -} +}; /* alt window.fetalSplit = function(actor, chance)