diff --git a/src/js/wombJS.tw b/src/js/wombJS.tw index 62f04539963b8149a846742a8c65df9e70768e16..8b0c639de997549c273fb544aa6c03b6898b47cc 100644 --- a/src/js/wombJS.tw +++ b/src/js/wombJS.tw @@ -28,6 +28,13 @@ $slave.bellyPreg = WombGetWolume($slave) - return double, with current womb volu //Init womb system. window.WombInit = function(actor) { + + if (typeof actor != "object") + { + console.log("WombInit - actor is not object!"); + return; + } + if (!Array.isArray(actor.womb)) { //alert("creating new womb"); //debugging actor.womb = []; @@ -322,13 +329,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]; @@ -337,7 +346,8 @@ 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]; @@ -348,7 +358,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. +/*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); @@ -357,17 +367,59 @@ 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.FetusReserveCount = 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.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) { diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw index a2341cfa3c4b2ecf2b56081d06f53cc1777920d4..8810b528d98a648065bf189ed52b23ae87266806 100644 --- a/src/uncategorized/BackwardsCompatibility.tw +++ b/src/uncategorized/BackwardsCompatibility.tw @@ -366,6 +366,7 @@ <</if>> <</if>> <<run PCDatatypeCleanup()>> +<<run BCReserveInit()>> <<if ndef $universalRulesImmobileSlavesMaintainMuscles>> <<set $universalRulesImmobileSlavesMaintainMuscles = 0>>