Newer
Older
/**
* Removes slave from the game
* @param {App.Entity.SlaveState} slave
*/
globalThis.removeSlave = function(slave) {
const AS_ID = slave.ID;
let LENGTH = V.slaves.length;
const INDEX = V.slaveIndices[AS_ID];
let missing = false;
WombChangeID(V.PC, AS_ID, V.missingParentID);
if (V.PC.pregSource === V.missingParentID) {
missing = true;
}
if (V.PC.mother === AS_ID) {
V.PC.mother = V.missingParentID;
missing = true;
}
if (V.PC.father === AS_ID) {
V.PC.father = V.missingParentID;
missing = true;
}
if (V.PC.sisters > 0) {
if (areSisters(V.PC, slave) > 0) {
V.PC.sisters--;
}
}
if (V.PC.daughters > 0) {
if (slave.father === -1 || slave.mother === -1) {
V.researchLab.tasks = V.researchLab.tasks.filter((t) => t.slaveID !== AS_ID);
if (INDEX >= 0 && INDEX < LENGTH) {
if (V.incubator > 0) {
V.tanks.forEach(child => {
if (AS_ID === child.mother) {
child.mother = V.missingParentID;
missing = true;
}
if (AS_ID === child.father) {
child.father = V.missingParentID;
missing = true;
}
});
}
if (V.nursery > 0) {
V.cribs.forEach(child => {
if (AS_ID === child.mother) {
child.mother = V.missingParentID;
missing = true;
}
if (AS_ID === child.father) {
child.father = V.missingParentID;
missing = true;
}
});
}
V.slaves.forEach(s => {
WombChangeID(s, AS_ID, V.missingParentID); /* This check is complex, should be done in JS now, all needed will be done here. */
WombChangeGeneID(s, AS_ID, V.missingParentID);
if (s.pregSource === V.missingParentID) {
if (slave.mother > 0 || slave.father > 0) {
if (slave.mother === s.ID || slave.father === s.ID) {
if (slave.sisters > 0) {
if (areSisters(slave, s) > 0) {
if (s.cumSource === AS_ID || s.milkSource === AS_ID) {
deflate(s);
}
/* moved to saDevotion as a discovery event
if (s.ID === slave.subTarget || slave.subTarget === s.ID) {
slave.subTarget = 0;
s.subTarget = 0;
});
/* remove from Pit fighters list, if needed */
/* remove from Coursing Association, if needed */
}
if (Array.isArray(V.personalAttention)) {
V.personalAttention.deleteWith(s => s.ID === AS_ID);
if (V.personalAttention.length === 0) {
/* Remove from facility array or leadership role, if needed */
removeJob(slave, slave.assignment);
missing = true; /* no exceptions, fetus system relies on this */
if (AS_ID === V.traitor.pregSource) {
V.traitor.pregSource = 0;
}
if (V.traitor.mother === AS_ID) {
V.traitor.mother = V.missingParentID;
}
if (V.traitor.father === AS_ID) {
V.traitor.father = V.missingParentID;
}
if (V.traitor.origBodyOwnerID === AS_ID) {
V.traitor.origBodyOwnerID = 0;
}
V.traitor.partners.delete(AS_ID);
V.traitor.partners.add(V.missingParentID);
missing = true;
if (AS_ID === V.boomerangSlave.pregSource) {
V.boomerangSlave.pregSource = 0;
}
if (V.boomerangSlave.mother === AS_ID) {
V.boomerangSlave.mother = V.missingParentID;
}
if (V.boomerangSlave.father === AS_ID) {
V.boomerangSlave.father = V.missingParentID;
}
if (V.boomerangSlave.origBodyOwnerID === AS_ID) {
V.boomerangSlave.partners.delete(AS_ID);
V.boomerangSlave.partners.add(V.missingParentID);
V.organs.deleteWith(s => s.ID === AS_ID);
V.completedOrgans.deleteWith(s => s.ID === AS_ID);
for (let _o = 0; _o < V.adjustProsthetics.length; _o++) {
if (V.adjustProsthetics[_o].ID === AS_ID) {
V.adjustProsthetics.deleteAt(_o);
V.adjustProstheticsCompleted--;
if (_geneIndex !== -1) {
let keep = false;
if (V.traitor !== 0) {
if (isImpregnatedBy(V.traitor, slave) || V.traitor.ID === AS_ID) {
/* did we impregnate the traitor, or are we the traitor? */
keep = true;
}
}
if (V.boomerangSlave !== 0) {
if (isImpregnatedBy(V.boomerangSlave, slave) || V.boomerangSlave.ID === AS_ID) {
/* did we impregnate the boomerang, or are we the boomerang? */
if (isImpregnatedBy(V.PC, slave)) {
if (!keep) {
/* avoid going through this loop if possible */
return (slave.ID !== AS_ID && isImpregnatedBy(slave, slave));
});
}
if (!keep) {
V.genePool.deleteAt(_geneIndex);
}
}
Object.values(V.missingTable).forEach(s => {
if (s.mother === slave.ID || s.father === slave.ID) {
slaveName: slave.slaveName,
slaveSurname: slave.slaveSurname,
fullName: SlaveFullName(slave),
dick: slave.dick,
vagina: slave.vagina,
mother: slave.mother,
father: slave.father,
inbreedingCoeff: slave.inbreedingCoeff
if (V.traitor && V.traitor.ID === slave.ID) {
} else if (V.boomerangSlave && V.boomerangSlave.ID === slave.ID) {
Object.values(V.missingTable).forEach(s => {
if (V.assignmentRecords[AS_ID]) {
delete V.assignmentRecords[AS_ID];
}
// remove slaves from V.rulesToApplyOnce if needed
removeFromRulesToApplyOnce(slave);
V.slaves.deleteAt(INDEX);
V.slaveIndices = slaves2indices();
V.JobIDMap = makeJobIdMap(); /* need to call this once more to update count of resting slaves*/