diff --git a/src/endWeek/saDevotion.js b/src/endWeek/saDevotion.js index 72238362d3a9b51f4cb505bdc7d160092af42b86..700a5eb1e6425bc63660334a5f7c3d1144ace209 100644 --- a/src/endWeek/saDevotion.js +++ b/src/endWeek/saDevotion.js @@ -305,7 +305,7 @@ App.SlaveAssignment.devotion = (function() { * */ function bodySwapThoughts(slave) { - if (V.slaveIndices[slave.origBodyOwnerID] === undefined) { + if (getSlave(slave.origBodyOwnerID) === undefined) { slave.origBodyOwnerID = 0; if (slave.devotion > 20) { r.push(`${slave.slaveName} is somewhat saddened to see ${his} body leave forever.`); diff --git a/src/facilities/nursery/utils/nurseryUtils.js b/src/facilities/nursery/utils/nurseryUtils.js index 0fb1ad3e8665480fdb2feb1224f6311caccdafe9..b31bcfe02d56dd34320e56daf2c25b05460425f7 100644 --- a/src/facilities/nursery/utils/nurseryUtils.js +++ b/src/facilities/nursery/utils/nurseryUtils.js @@ -751,9 +751,9 @@ App.Facilities.Nursery.nurserySort = function nurserySort() { if (slave.preg <= 5) { r += `someone's, though it is too early to tell whose,`; } else { - let t = V.slaveIndices[slave.pregSource]; - if (jsDef(t)) { - r += `${V.slaves[t].slaveName}'s`; + let source = getSlave(slave.pregSource); + if (source !== undefined) { + r += `${source.slaveName}'s`; } } break; diff --git a/src/js/pregJS.js b/src/js/pregJS.js index 37a43d9378fde86db687d47cf19c4c072cbe118f..4447999dbbb2477629026f3fed4bce8dc4c29342 100644 --- a/src/js/pregJS.js +++ b/src/js/pregJS.js @@ -524,7 +524,7 @@ globalThis.getNurseryReserved = function( /* slaves */ ) { globalThis.findFather = function(fatherID) { let father; - father = V.slaves[V.slaveIndices[fatherID]]; + father = getSlave(fatherID); if (father === undefined) { if (V.incubator > 0) { father = V.tanks.find(s => s.ID === fatherID); diff --git a/src/npc/children/longChildDescription.js b/src/npc/children/longChildDescription.js index 9d25f7664b8a8b422787297c243d6dde3217ae18..725e764ec10dd99feed3a90b544c7292c0f7a187 100644 --- a/src/npc/children/longChildDescription.js +++ b/src/npc/children/longChildDescription.js @@ -7214,15 +7214,15 @@ App.Facilities.Nursery.LongChildDescription = function(child, {market = 0, event } if (child.rivalry) { - let lcd = V.slaveIndices[child.rivalryTarget]; - if (jsDef(lcd)) { + const rival = getSlave(child.rivalryTarget); + if (rival !== undefined) { r += `${He} `; if (child.rivalry <= 1) { - r += `<span class="lightsalmon">dislikes</span> ${SlaveFullName(slaves[lcd])}. `; + r += `<span class="lightsalmon">dislikes</span> ${SlaveFullName(rival)}. `; } else if (child.rivalry <= 2) { - r += `is ${SlaveFullName(slaves[lcd])}>>'s <span class="lightsalmon">rival.</span> `; + r += `is ${SlaveFullName(rival)}>>'s <span class="lightsalmon">rival.</span> `; } else { - r += `<span class="lightsalmon">bitterly hates</span> ${SlaveFullName(slaves[lcd])}>>. `; + r += `<span class="lightsalmon">bitterly hates</span> ${SlaveFullName(rival)}>>. `; } } } diff --git a/src/npc/descriptions/longSlave.js b/src/npc/descriptions/longSlave.js index 01f26a70524432d448f80ac1d22fc49058837f37..62c85d62c1c9eedc60eec697be271fe81a9c54e2 100644 --- a/src/npc/descriptions/longSlave.js +++ b/src/npc/descriptions/longSlave.js @@ -240,9 +240,9 @@ App.Desc.longSlave = function(slave, {market = 0, eventDescription = false, pris r.push(`${He} currently possesses ${slave.origBodyOwner}'s body.`); } if (slave.fetish !== "mindbroken" && slave.fuckdoll === 0 && slave.origBodyOwnerID > 0) { - let lsd = V.slaveIndices[slave.origBodyOwnerID]; - if (lsd) { - r.push(`${He} is fully aware that ${SlaveFullName(V.slaves[lsd])} is in ${his} old body.`); + const owner = getSlave(slave.origBodyOwnerID); + if (owner !== undefined) { + r.push(`${He} is fully aware that ${SlaveFullName(owner)} is in ${his} old body.`); } } } diff --git a/src/npc/generate/generateGenetics.js b/src/npc/generate/generateGenetics.js index 710bb4afc6a7ba61a8049a96c298f6602e6a3292..f87d49ed3dc6ff3eb951f2b49b0004c1a14fb0f6 100644 --- a/src/npc/generate/generateGenetics.js +++ b/src/npc/generate/generateGenetics.js @@ -57,7 +57,7 @@ globalThis.generateGenetics = (function() { if (mother === undefined) { mother = actor1; } - activeMother = V.slaves[V.slaveIndices[actor1.ID]]; + activeMother = getSlave(actor1.ID); if (activeMother === undefined) { activeMother = actor1; } @@ -67,7 +67,7 @@ globalThis.generateGenetics = (function() { } if (actor2 > 0) { father = V.genePool.find(s => s.ID === actor2); - activeFather = V.slaves[V.slaveIndices[actor2]]; + activeFather = getSlave(actor2); if (father === undefined) { father = activeFather; } diff --git a/src/npc/surgery/organFarm.js b/src/npc/surgery/organFarm.js index 7294c990068158e73cb30238a2893e46284ccbc0..b5f8925104ae658a8662ba74139ef402a3209786 100644 --- a/src/npc/surgery/organFarm.js +++ b/src/npc/surgery/organFarm.js @@ -267,9 +267,9 @@ App.Medicine.OrganFarm.currentlyGrowing = function() { let finishLines = []; V.organs.forEach(o => { - const index = V.slaveIndices[o.ID]; - if (index !== undefined) { - growLines.push(`${V.slaves[index].slaveName}'s ${App.Medicine.OrganFarm.Organs[o.type].name}, ${ + const slave = getSlave(o.ID); + if (slave !== undefined) { + growLines.push(`${slave.slaveName}'s ${App.Medicine.OrganFarm.Organs[o.type].name}, ${ weeksToCompletion(o.weeksToCompletion)} week(s) left.`); } else { growLines.push(`<span class="error">ERROR: No slave with ID ${o.ID} found.</span>`); @@ -290,9 +290,9 @@ App.Medicine.OrganFarm.currentlyGrowing = function() { }); V.completedOrgans.forEach(o => { - const index = V.slaveIndices[o.ID]; - if (index !== undefined) { - finishLines.push(`${V.slaves[index].slaveName}'s ${App.Medicine.OrganFarm.Organs[o.type].name}.`); + const slave = getSlave(o.ID); + if (slave !== undefined) { + finishLines.push(`${slave.slaveName}'s ${App.Medicine.OrganFarm.Organs[o.type].name}.`); } else { finishLines.push(`<span class="error">ERROR: No slave with ID ${o.ID} found.</span>`); }