diff --git a/src/js/wombJS.tw b/src/js/wombJS.tw index 80648a7686700ebf311048702c410d7f5e019083..499bc78d679e8293f5631f19ccb26e6459aca8c3 100644 --- a/src/js/wombJS.tw +++ b/src/js/wombJS.tw @@ -85,6 +85,7 @@ window.WombImpregnate = function(actor, fCount, fatherID, age) { tf.volume = 1; //Initial, to create property. Updated with actual data after WombGetVolume call. tf.reserve = ""; //Initial, to create property. Used later to mark if this child is to be kept. tf.identical = 0; //Initial, to create property. Updated with actual data during fetalSplit call. + tf.splitted = 0; //marker for already splitted fetus. tf.genetics = generateGenetics(actor, fatherID, i+1); //Stored genetic information. try { @@ -310,26 +311,25 @@ window.WombSort = function(actor) { actor.womb.sort((a, b) => { return b.age - a.age; }); }; -window.fetalSplit = 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 = {}; - nft.age = actor.preg; - nft.fatherID = actor.pregSource; - nft.volume = 1; - nft.identical = 0; - nft.genetics = 0; - nft.reserve = ""; + var nft; actor.womb.forEach(function(s){ - if ((jsRandom(1,1000) >= 1000) && s.identical !== 1) + if ((jsRandom(1,chance) >= chance) && s.splitted !== 1) { nft = {}; nft.age = s.age; nft.fatherID = s.fatherID; + nft.motherID = s.motherID; nft.volume = s.volume; + nft.reserve = ""; //splitted fetus is new separate, reserve - it's not genetic to split. nft.genetics = deepCopy(s.genetics); + s.splitted = 1; //this is marker that this is already splitted fetus (to not split second time in loop), only source fetus needed it. + nft.identical = 1; //this is marker that this fetus has at least one twin. + s.identical = 1; //this is marker that this fetus has at least one twin. actor.womb.push(nft); - s.identical = 1; } }); WombNormalizePreg(actor); @@ -401,10 +401,12 @@ window.WombCleanYYFetuses = function(actor) { var reserved = []; - let i = actor.womb.length; + var i = actor.womb.length-1; + var ft; + while (i >= 0) { - let ft = actor.womb[i]; + ft = actor.womb[i]; if (ft.genetics.gender == "YY") { @@ -531,10 +533,12 @@ window.WombRemoveReservedFetuses = function(actor, type) { var reserved = []; - let i = actor.womb.length; + var i = actor.womb.length-1; + var ft; + while (i >= 0) { - let ft = actor.womb(i); + ft = actor.womb[i]; if (ft.reserve == type) { @@ -592,12 +596,12 @@ window.BCReserveInit = function() } /* alt -window.fetalSplit = function(actor) +window.fetalSplit = function(actor, chance) { var i, ft, nft; actor.womb.forEach(function(s){ - if ((jsRandom(1,1000) >= 1000) && s.identical !== 1) + if ((jsRandom(1,chance) >= chance) && s.identical !== 1) { nft = deepCopy(s); actor.womb.push(nft); diff --git a/src/pregmod/personalNotes.tw b/src/pregmod/personalNotes.tw index 34664075837081ae3b33aeac77122bbfc968c0d9..315165bb21f9e7fd0e27a111b3293e4d2ae87582 100644 --- a/src/pregmod/personalNotes.tw +++ b/src/pregmod/personalNotes.tw @@ -45,7 +45,7 @@ <<if $PC.preg > 0 <<set _oldCount = $PC.pregType>> <<if $PC.preg <= 2>> - <<run fetalSplit($PC)>> + <<run fetalSplit($PC, 1000)>> <<run WombCleanYYFetuses($PC)>> <</if>> <<if $pregnancyMonitoringUpgrade == 1>> diff --git a/src/uncategorized/saLongTermEffects.tw b/src/uncategorized/saLongTermEffects.tw index 87a979c9d14f4a4da7b4d4ea93f5eba71c8325c7..f8dd179c2a4f821207be80c3b04972afd8391e35 100644 --- a/src/uncategorized/saLongTermEffects.tw +++ b/src/uncategorized/saLongTermEffects.tw @@ -3021,7 +3021,7 @@ <<set _oldCount = $slaves[$i].pregType>> <<if $slaves[$i].preg <= 2 && $slaves[$i].broodmother == 0>> - <<run fetalSplit($slaves[$i])>> + <<run fetalSplit($slaves[$i], 1000)>> <<run WombCleanYYFetuses($slaves[$i])>> <</if>> <<if $pregnancyMonitoringUpgrade == 1>>