diff --git a/src/js/wombJS.js b/src/js/wombJS.js index 46663f1bbcd3f43b9fcb2747add54457a7d1a8bd..6d4022a699cf5bf612e6b388f6ace11ef7c155a2 100644 --- a/src/js/wombJS.js +++ b/src/js/wombJS.js @@ -12,7 +12,7 @@ WombInit($slave) - before first pregnancy, at slave creation, of as backward com WombImpregnate($slave, $fetus_count, $fatherID, $initial_age) - should be added after normal impregnation code, with already calculated fetus count. ID of father - can be used in future for processing children from different fathers in one pregnancy. Initial age normally 1 (as .preg normally set to 1), but can be raised if needed. Also should be called at time as broodmother implant add another fetus(es), or if new fetuses added from other sources in future (transplanting maybe?) -WombProgress($slave, $time_to_add_to_fetuses) - after code that update $slave.preg, time to add should be the same. +WombProgress($slave, $time_to_add_to_fetuses, $real_time_to_add_to_fetuses) - after code that update $slave.preg, time to add should be the same. $isReady = WombBirthReady($slave, $birth_ready_age) - how many children ready to be birthed if their time to be ready is $birth_ready_age (40 is for normal length pregnancy). Return int - count of ready to birth children, or 0 if no ready exists. @@ -86,6 +86,7 @@ window.WombImpregnate = function(actor, fCount, fatherID, age, surrogate) { for (i=0; i<fCount; i++) { tf = {}; //new Object tf.age = age; //initial age + tf.realAge = 1; //initial real age (first week in mother) tf.fatherID = fatherID; //We can store who is father too. 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. @@ -130,6 +131,7 @@ window.WombImpregnateClone = function(actor, fCount, mother, motherOriginal, age for (i=0; i<fCount; i++) { tf = {}; //new Object tf.age = age; //initial age + tf.realAge = 1; //initial real age (first week in mother) tf.fatherID = mother.ID; //We can store who is father too. 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. @@ -187,10 +189,12 @@ window.WombImpregnateClone = function(actor, fCount, mother, motherOriginal, age } }; -window.WombProgress = function(actor, ageToAdd) { +// Should be used to set biological age for fetus (ageToAdd), AND chronological (realAgeToAdd). Speed up or slow down gestation drugs should affect ONLY biological. +window.WombProgress = function(actor, ageToAdd, realAgeToAdd) { ageToAdd = Math.ceil(ageToAdd*10)/10; + realAgeToAdd = Math.ceil(realAgeToAdd*10)/10; try { - actor.womb.forEach(ft => ft.age += ageToAdd); + actor.womb.forEach(ft => ft.age += ageToAdd, ft.realAge += realAgeToAdd ); } catch(err){ WombInit(actor); alert("WombProgress warning - " + actor.slaveName+" "+err); @@ -437,7 +441,7 @@ window.WombNormalizePreg = function(actor) actor.pregWeek = 1; if (max < actor.preg) { - WombProgress(actor, actor.preg - max); + WombProgress(actor, actor.preg - max, actor.preg - max); // console.log("progressin womb"); } else if ( max > actor.preg) { @@ -765,6 +769,53 @@ window.WombCleanAllReserve = function(actor) }; +/* +Function return object with data about litters in actor womb. This data can be used for descriptions of pregnancy with complicated structure. What it contain: + +data.litters.length = summary count of separate litters in the womb. +data.litters[x] = age (.realAge) of litter "x". +data.countLitter[x] = count of fetuses in "x" litter. + +data.litterData[x] = contain array with actual fetuses that belong to a litter "x". Can be used to check anyithing related to fetus. (This is not copy, but reference to actual fetuses, so be careful with changes of this array). + +Sample of usage in SugarScript: +--- +<<set _wd = WombGetLitterData($activeSlave)>> +She is _wd.litters[0] weeks pregnant with her first set of _wd.countLitter[0] children<<if _wd.litters > 1>>, _wd.litters[1] weeks along with her second set<</if>><<if _wd.litters > 2>>, _wd.litters[2] and _wd.litters[2] weeks along with her third<</if>>. +In summary she carry _wd.litters.length separate sets of children. Her most progressed fetus of second pregnancy is already reached _wd.litterData[1][0].age biological week of gestation. +--- +*/ +window.WombGetLittersData = function(actor) +{ + var data = {}; + var unicLiters = []; //array with realAges of separate litters. + var countLitter = []; + var litterData = []; + var tmp; + + //in first place we need to know how many litters here (Assuming that unique litter is have similar .realAge). Also we will know their ages. + actor.womb.forEach(function(ft) + { + if (!unicLiters.includes(Math.ceil(ft.realAge))) + unicLiters.push(Math.ceil(ft.realAge)); + + }); + + //now we should find and store separate litters data (count of fetuses): + unicLiters.forEach(function(litter, i) + { + tmp = actor.womb.filter(ft => Math.ceil(ft.realAge) == litter); + countLitter.push(tmp.length); + litterData.push(tmp); + }); + + data.litters = unicLiters; + data.countLitter = countLitter; + data.litterData = litterData; + + return data; +} + window.BCReserveInit = function() { var SV = State.variables; @@ -779,6 +830,8 @@ window.BCReserveInit = function() ft.motherID = slave.ID; if (ft.ID === undefined) ft.ID = generateNewID(); + if (typeof ft.realAge !== 'number') //setting missing chronological age + ft.realAge = ft.age; }); }); @@ -787,6 +840,8 @@ window.BCReserveInit = function() ft.reserve = ""; if (typeof ft.motherID !== 'number') ft.motherID = SV.PC.ID; + if (typeof ft.realAge !== 'number') //setting missing chronological age + ft.realAge = ft.age; }); }; diff --git a/src/uncategorized/endWeek.tw b/src/uncategorized/endWeek.tw index 51155d1610a83924a20c4a28da56085974ea4f46..b2eca7d13868c4150100a5f9a44c38ca7de5d0e5 100644 --- a/src/uncategorized/endWeek.tw +++ b/src/uncategorized/endWeek.tw @@ -212,7 +212,7 @@ <<set $PC.sexualEnergy += 2>> <</if>> <<if $PC.preg > 0>> - <<set WombProgress($PC, 1)>> + <<set WombProgress($PC, 1, 1)>> <<set WombNormalizePreg($PC), $PC.pregWeek = $PC.preg>> <<set _newBelly = WombGetVolume($PC)>> <<if _newBelly >= $PC.belly>> diff --git a/src/uncategorized/pCoupAttempt.tw b/src/uncategorized/pCoupAttempt.tw index 6ab1eb70388c16ff8890695daa62989bc6ea5c3e..e946956c9f0d97b377743e14612b4f3c55a2325d 100644 --- a/src/uncategorized/pCoupAttempt.tw +++ b/src/uncategorized/pCoupAttempt.tw @@ -5,7 +5,7 @@ <<if $traitor != 0>> <<set _weeks = $taitorWeeks, _pregWeeks = $taitorWeeks, $taitorWeeks = 0>> - <<set WombProgress($traitor, _pregWeeks)>> /* In all cases should be done */ + <<set WombProgress($traitor, _pregWeeks, _pregWeeks)>> /* In all cases should be done */ <<set WombUpdatePregVars($traitor)>> <<if WombBirthReady($traitor, $traitor.pregData.normalBirth) > 0 >> /* normal birth case, partial birthers not supported*/ <<set $traitor.preg = -1, $traitor.birthsTotal += WombBirthReady($traitor, $traitor.pregData.normalBirth), $traitor.pregType = 0, $traitor.pregSource = 0, $traitor.pregWeek = 0, $traitor.pregKnown = 0>> diff --git a/src/uncategorized/pCoupCollaboration.tw b/src/uncategorized/pCoupCollaboration.tw index 3d103a18375fed763985b3e2c05d26d9e1706d68..dd366d2b606caa4733a75df84e18e052f84b7c2d 100644 --- a/src/uncategorized/pCoupCollaboration.tw +++ b/src/uncategorized/pCoupCollaboration.tw @@ -4,7 +4,7 @@ <<setLocalPronouns $traitor>> <<run Enunciate($traitor)>> -<<set WombProgress($traitor, _pregWeeks)>> /* In all cases should be done */ +<<set WombProgress($traitor, _pregWeeks, _pregWeeks)>> /* In all cases should be done */ <<set WombUpdatePregVars($traitor)>> <<if WombBirthReady($traitor, $traitor.pregData.normalBirth) > 0 >> /* normal birth case, partial birthers not supported*/ <<set $traitor.preg = -1, $traitor.birthsTotal += WombBirthReady($traitor, $traitor.pregData.normalBirth), $traitor.pregType = 0, $traitor.pregSource = 0, $traitor.pregWeek = 0, $traitor.pregKnown = 0>> diff --git a/src/uncategorized/pCoupLoss.tw b/src/uncategorized/pCoupLoss.tw index 9dad05ae2fd0d50d3247ed70397469afc7378fae..7bddf6422a20c2a08aa6346ea5169c3d3982fba1 100644 --- a/src/uncategorized/pCoupLoss.tw +++ b/src/uncategorized/pCoupLoss.tw @@ -3,7 +3,7 @@ <<set _weeks = $taitorWeeks, _pregWeeks = $taitorWeeks, $taitorWeeks = 0>> <<setLocalPronouns $traitor>> -<<set WombProgress($traitor, _pregWeeks)>> /* In all cases should be done */ +<<set WombProgress($traitor, _pregWeeks, _pregWeeks)>> /* In all cases should be done */ <<set WombUpdatePregVars($traitor)>> <<if WombBirthReady($traitor, $traitor.pregData.normalBirth) > 0 >> /* normal birth case, partial birthers not supported*/ <<set $traitor.preg = -1, $traitor.birthsTotal += WombBirthReady($traitor, $traitor.pregData.normalBirth), $traitor.pregType = 0, $traitor.pregSource = 0, $traitor.pregWeek = 0, $traitor.pregKnown = 0>> diff --git a/src/uncategorized/pTraitorMessage.tw b/src/uncategorized/pTraitorMessage.tw index 0783ef9bbbf5b4f16bf4f60cf768a83d39252539..0aa2efae86b0040c7cd81d97d72e7aceec2b1b2b 100644 --- a/src/uncategorized/pTraitorMessage.tw +++ b/src/uncategorized/pTraitorMessage.tw @@ -12,7 +12,7 @@ <<set _wasPreg = 0>> <</if>> -<<set WombProgress($traitor, _pregWeeks)>> /* In all cases should be done */ +<<set WombProgress($traitor, _pregWeeks, _pregWeeks)>> /* In all cases should be done */ <<set WombUpdatePregVars($traitor)>> <<if $traitor.broodmother > 0>> /* Broodmother implant is assumed as removed.*/ <<set $traitor.preg = -1, $traitor.birthsTotal += WombBirthReady($traitor, 37), $traitor.pregType = 0, $traitor.pregSource = 0, $traitor.pregWeek = 0, $traitor.pregKnown = 0, $traitor.broodmother == 0, $traitor.broodmotherFetuses = 0>> diff --git a/src/uncategorized/reBoomerang.tw b/src/uncategorized/reBoomerang.tw index 701d5ab4bc1af474e9b2b0de263cda783748dfab..6ace48d8284f365b6175472184c14d8ee53e7a34 100644 --- a/src/uncategorized/reBoomerang.tw +++ b/src/uncategorized/reBoomerang.tw @@ -23,7 +23,7 @@ brings up the relevant feeds. There's a naked body crumpled pathetically against /* ------------------ pregnancy setup start here----------------- */ -<<set WombProgress($activeSlave, _pregWeeks)>> /* In all cases should be done */ +<<set WombProgress($activeSlave, _pregWeeks, _pregWeeks)>> /* In all cases should be done */ <<set WombUpdatePregVars($activeSlave)>> <<if $activeSlave.broodmother > 0>> /* Broodmother implant is assumed as removed.*/ <<set $activeSlave.preg = -1, $activeSlave.birthsTotal += WombBirthReady($activeSlave, 37), $activeSlave.pregType = 0, $activeSlave.pregSource = 0, $activeSlave.pregWeek = 0, $activeSlave.pregKnown = 0, $activeSlave.broodmother == 0, $activeSlave.broodmotherFetuses = 0>> diff --git a/src/uncategorized/slaveAssignmentsReport.tw b/src/uncategorized/slaveAssignmentsReport.tw index ceae715c6cc32b20f4e8bbcc2af6b1cee7ecb074..2331a5906160474c02144ffc76dfcaca0311f7d3 100644 --- a/src/uncategorized/slaveAssignmentsReport.tw +++ b/src/uncategorized/slaveAssignmentsReport.tw @@ -407,7 +407,7 @@ <</if>> <</if>> - <<set WombProgress($slaves[$i], _pregSpeed)>> + <<set WombProgress($slaves[$i], _pregSpeed, 1)>> /* drugs can affect speed of gestation, but not a real time */ <<set $slaves[$i].pregKnown = 1>> <<set $slaves[$i].pregWeek++>>