diff --git a/src/js/pregJS.tw b/src/js/pregJS.tw index 8508cbfbf669ba0e322a9be5fcb4156d7e626717..7e17b5554ab6e643ed1176c5a535874f6bd07817 100644 --- a/src/js/pregJS.tw +++ b/src/js/pregJS.tw @@ -259,25 +259,36 @@ window.findFather = function(fatherID) { return father; } +window.adjustFatherProperty = function(actor, property, newValue) { + let father = findFather(actor.ID); + if (father) + father[property] = newValue; +} + +/* OLD window.adjustFatherProperty = function(actor, property, newValue) { let V = State.variables; - let fatherID; + let fatherIndex; - fatherID = V.slaves.findIndex(function(s) { return s.ID == actor.ID; }); - if (fatherID > 0) { - V.slaves[fatherID][property] = newValue; + fatherIndex = V.slaves.findIndex(function(s) { return s.ID == actor.ID; }); + if (fatherIndex > 0) { + V.slaves[fatherIndex][property] = newValue; } else if (V.incubator > 0) { - fatherID = V.tanks.findIndex(function(s) { return s.ID == actor.ID; }); - if (fatherID > 0) { - V.tanks[fatherID][property] = newValue; - } else if (V.nursery > 0) { - father = V.cribs.findIndex(function(s) { return s.ID == actor.ID; }); - if (fatherID !== -1) { - V.cribs[fatherID][property] = newValue; + fatherIndex = V.tanks.findIndex(function(s) { return s.ID == actor.ID; }); + if (fatherIndex > 0) { + V.tanks[fatherIndex][property] = newValue; + } + } + if (fatherIndex === -1) { + if (V.nursery > 0) { + fatherIndex = V.cribs.findIndex(function(s) { return s.ID == actor.ID; }); + if (fatherIndex !== -1) { + V.cribs[fatherIndex][property] = newValue; } } } } +*/ /* not to be used until that last part is defined. It may become slave.boobWomb.volume or some shit */ window.getBaseBoobs = function(slave) {