From b41f85c2f49ea831991eb43d82c9bad81c5235b4 Mon Sep 17 00:00:00 2001 From: pregmodfan <pregmodfan@cock.li> Date: Thu, 15 Nov 2018 18:58:06 +0200 Subject: [PATCH] some more syntax sugar for fetus reservation --- src/js/pregJS.tw | 16 ++++------------ src/js/wombJS.tw | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/js/pregJS.tw b/src/js/pregJS.tw index 363f3cdf084..1688a4707a2 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 36b0ab64856..1aa7b97e2da 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; + } }); }); -- GitLab