diff --git a/src/js/pregJS.tw b/src/js/pregJS.tw index 363f3cdf084b6e80cee1d561c5c0f6032f6c92e6..1688a4707a2381a842433fb0bbcbc759819f902c 100644 --- a/src/js/pregJS.tw +++ b/src/js/pregJS.tw @@ -212,21 +212,13 @@ window.knockMeUp = function(target, chance, hole, fatherID, displayOverride) { } window.getIncubatorReserved = function(slaves) { - var count = 0; - slaves.forEach(function(s){ - if (s.reservedChildren > 0) - count += s.reservedChildren; - }); - return count; + + return WombGetGenericReserve("incubator"); } window.getNurseryReserved = function (slaves) { - var count = 0; - slaves.forEach(function (s) { - if (s.reservedChildrenNursery > 0) - count += s.reservedChildrenNursery; - }); - return count; + + return WombGetGenericReserve("nursery"); } /* not to be used until that last part is defined. It may become slave.boobWomb.volume or some shit */ diff --git a/src/js/wombJS.tw b/src/js/wombJS.tw index 36b0ab64856adb0a8d50400f95ef0738d9852606..1aa7b97e2dad1ae2c41ba29ad2de74dba519967e 100644 --- a/src/js/wombJS.tw +++ b/src/js/wombJS.tw @@ -414,6 +414,29 @@ window.WombSetGenericReserve = function(actor, type, count) }); } +window.WombAddToGenericReserve = function(actor, type, count) +{ + + WombSetGenericReserve(actor, type, WombGetGenericReserve(actor, type)+count); + +} + +window.WombChangeReserveType = function(actor, oldType, newType) +{ + + var count = 0; + + actor.womb.forEach(function(ft){ + if (ft.reserve == oldType) + { + ft.reserve = newType; + count++; + } + }); + + return count; +} + window.WombCleanGenericReserve = function(actor, type, count) { @@ -467,13 +490,17 @@ window.BCReserveInit = function() ft.reserved = ""; if (typeof ft.motherID != 'number') //setting missing biological mother ID for fetus. ft.motherID = slave.ID; - - if (slave.reservedChildren > 0) - WombSetGenericReserve(slave, "incubator", reservedChildren); - - if (slave.reservedChildrenNursery > 0) - WombSetGenericReserve(slave, "nursery", reservedChildren); - + try { + if (slave.reservedChildren > 0) + WombSetGenericReserve(slave, "incubator", reservedChildren); + + if (slave.reservedChildrenNursery > 0) + WombSetGenericReserve(slave, "nursery", reservedChildren); + } catch (err) { + + console.log (err + " slave ID: " + slave.ID + " slave name: " + slave.slaveName + " " + slave.slaveSurname); + slave.reservedChildren = 0; + } }); });