diff --git a/src/js/generateGenetics.js b/src/js/generateGenetics.js index 51cda03ac36ac13139e3c342a983f4fa4bdc7ddb..343c9a3505d6f70db5b2d61d1a9e681a8983cb5a 100644 --- a/src/js/generateGenetics.js +++ b/src/js/generateGenetics.js @@ -1066,262 +1066,76 @@ window.generateChild = function(mother, ova, destination) { let pregUpgrade = V.pregnancyMonitoringUpgrade; let child = {}; - if (!destination) { // does extra work for the incubator if defined, otherwise builds a simple object - if (genes.gender === "XX") { - child.genes = "XX"; - child.slaveSurname = genes.surname; - if (!pregUpgrade) { - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveName = `Your clone`; - child.slaveSurname = V.PC.slaveSurname; - } else { - child.slaveName = `${genes.clone}'s clone`; - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed !== undefined) { - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } - } else if (genes.mother === -1) { - if (genes.father <= 0) { - child.slaveName = `Your daughter`; - } else { - child.slaveName = `Your and ${genes.fatherName}'s daughter`; - } - child.slaveSurname = V.PC.slaveSurname; - } else { - if (genes.father === -1) { - child.slaveName = `${genes.motherName}'s and your daughter`; - child.slaveSurname = V.PC.slaveSurname; - } else if (genes.father > 0) { - child.slaveName = `${genes.motherName} and ${genes.fatherName}'s daughter`; - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } else { - let currentFather = getSlave(genes.father); - if (currentFather !== undefined) { - if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") { - child.slaveSurname = currentFather.slaveSurname; - } - } - } - } else { - child.slaveName = `${genes.motherName}'s bastard daughter`; - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } - } - } + function setSurname() { + child.slaveSurname = genes.surname; + if (genes.clone) { + if (genes.cloneID === -1) { + child.slaveSurname = V.PC.slaveSurname; } else { - let childName = genes.name; - if (childName.indexOf("ovum") === 0) { - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveName = `Your clone`; - child.slaveSurname = V.PC.slaveSurname; - } else { - child.slaveName = `${genes.clone}'s clone`; - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed !== undefined) { - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } - } else if (genes.mother === -1) { - if (genes.father <= 0) { - child.slaveName = "Your son"; - } else { - child.slaveName = `Your and ${genes.fatherName}'s son`; - } - } else { - if (genes.father === -1) { - child.slaveName = `${genes.motherName}'s and your son`; - } else if (genes.father > 0) { - child.slaveName = `${genes.motherName} and ${genes.fatherName}'s son`; - } else { - child.slaveName = `${genes.motherName}'s bastard son`; - } + let cloneSeed = getSlave(genes.cloneID); + if (cloneSeed !== undefined) { + if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { + child.slaveSurname = cloneSeed.slaveSurname; } - } else { - child.slaveName = genes.name; } - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveSurname = V.PC.slaveSurname; - } else { - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed !== undefined) { - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } - } else if (genes.mother === -1) { - child.slaveSurname = V.PC.slaveSurname; - } else { - if (genes.father === -1) { - child.slaveSurname = V.PC.slaveSurname; - } else if (genes.father > 0) { - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } else { - let currentFather = getSlave(genes.father); - if (currentFather !== undefined) { - if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") { - child.slaveSurname = currentFather.slaveSurname; - } - } - } - } else { - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } + } + } else if (genes.mother === -1 || genes.father === -1) { + child.slaveSurname = V.PC.slaveSurname; + } else if (genes.father > 0) { + let currentMother = getSlave(genes.mother); + if (currentMother !== undefined) { + if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { + child.slaveSurname = currentMother.slaveSurname; + } + } else { + let currentFather = getSlave(genes.father); + if (currentFather !== undefined) { + if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") { + child.slaveSurname = currentFather.slaveSurname; } } } } else { - child.genes = "XY"; - child.slaveSurname = genes.surname; - if (!pregUpgrade) { - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveName = `Your clone`; - child.slaveSurname = V.PC.slaveSurname; - } else { - child.slaveName = `${genes.clone}'s clone`; - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed !== undefined) { - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } - } else if (genes.mother === -1) { - if (genes.father <= 0) { - child.slaveName = "Your son"; - } else { - child.slaveName = `Your and ${genes.fatherName}'s son`; - } - child.slaveSurname = V.PC.slaveSurname; - } else { - if (genes.father === -1) { - child.slaveName = `${genes.motherName}'s and your son`; - child.slaveSurname = V.PC.slaveSurname; - } else if (genes.father > 0) { - child.slaveName = `${genes.motherName} and ${genes.fatherName}'s son`; - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } else { - let currentFather = getSlave(genes.father); - if (currentFather !== undefined) { - if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") { - child.slaveSurname = currentFather.slaveSurname; - } - } - } - } else { - child.slaveName = `${genes.motherName}'s bastard son`; - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } - } + let currentMother = getSlave(genes.mother); + if (currentMother !== undefined) { + if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { + child.slaveSurname = currentMother.slaveSurname; } - } else { - let childName = genes.name; - if (childName.indexOf("ovum") === 0) { - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveName = `Your clone`; - child.slaveSurname = V.PC.slaveSurname; - } else { - child.slaveName = `${genes.clone}'s clone`; - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed !== undefined) { - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } - } else if (genes.mother === -1) { - if (genes.father <= 0) { - child.slaveName = "Your son"; - } else { - child.slaveName = `Your and ${genes.fatherName}'s son`; - } - } else { - if (genes.father === -1) { - child.slaveName = `${genes.motherName}'s and your son`; - } else if (genes.father > 0) { - child.slaveName = `${genes.motherName} and ${genes.fatherName}'s son`; - } else { - child.slaveName = `${genes.motherName}'s bastard son`; - } - } + } + } + } + + function setSlaveName() { + const relString = child.genes === "XX" ? "daughter" : "son"; + if (!pregUpgrade || genes.name.indexOf("ovum") === 0) { + if (genes.clone) { + if (genes.cloneID === -1) { + child.slaveName = `Your clone`; } else { - child.slaveName = genes.name; + child.slaveName = `${genes.clone}'s clone`; } - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveSurname = V.PC.slaveSurname; - } else { - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed !== undefined) { - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } - } else if (genes.mother === -1) { - child.slaveSurname = V.PC.slaveSurname; + } else if (genes.mother === -1) { + if (genes.father <= 0) { + child.slaveName = `Your ${relString}`; } else { - if (genes.father === -1) { - child.slaveSurname = V.PC.slaveSurname; - } else if (genes.father > 0) { - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } else { - let currentFather = getSlave(genes.father); - if (currentFather !== undefined) { - if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") { - child.slaveSurname = currentFather.slaveSurname; - } - } - } - } else { - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } - } + child.slaveName = `Your and ${genes.fatherName}'s ${relString}`; } + } else if (genes.father === -1) { + child.slaveName = `${genes.motherName}'s and your ${relString}`; + } else if (genes.father > 0) { + child.slaveName = `${genes.motherName} and ${genes.fatherName}'s ${relString}`; + } else { + child.slaveName = `${genes.motherName}'s bastard ${relString}`; } + } else { + child.slaveName = genes.name; } + } + + if (!destination) { // does extra work for the incubator if defined, otherwise builds a simple object + child.genes = genes.gender; + setSlaveName(); + setSurname(); child.mother = genes.mother; child.father = genes.father; @@ -1402,247 +1216,11 @@ window.generateChild = function(mother, ova, destination) { if (genes.gender === "XX") { child = GenerateNewSlave("XX", {mature: 0}); - child.slaveSurname = genes.surname; - if (!pregUpgrade) { - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveName = `Your clone`; - child.slaveSurname = V.PC.slaveSurname; - } else { - child.slaveName = `${genes.clone}'s clone`; - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } else if (genes.mother === -1) { - if (genes.father <= 0) { - child.slaveName = `Your daughter`; - } else { - child.slaveName = `Yours and ${genes.fatherName}'s daughter`; - } - child.slaveSurname = V.PC.slaveSurname; - } else { - if (genes.father === -1) { - child.slaveName = `Yours and ${genes.motherName}'s daughter`; - child.slaveSurname = V.PC.slaveSurname; - } else if (genes.father > 0) { - child.slaveName = `${genes.motherName} and ${genes.fatherName}'s daughter`; - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } else { - let currentFather = getSlave(genes.father); - if (currentFather !== undefined) { - if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") { - child.slaveSurname = currentFather.slaveSurname; - } - } - } - } else { - child.slaveName = `${genes.motherName}'s bastard daughter`; - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } - } - } - } else { - let childName = genes.name; - if (childName.indexOf("ovum") === 0) { - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveName = `Your clone`; - child.slaveSurname = V.PC.slaveSurname; - } else { - child.slaveName = `${genes.clone}'s clone`; - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } else if (genes.mother === -1) { - if (genes.father <= 0) { - child.slaveName = `Your daughter`; - } else { - child.slaveName = `Yours and ${genes.fatherName}'s daughter`; - } - } else { - if (genes.father === -1) { - child.slaveName = `Yours and ${genes.motherName}'s daughter`; - } else if (genes.father > 0) { - child.slaveName = `${genes.motherName} and ${genes.fatherName}'s daughter`; - } else { - child.slaveName = `${genes.motherName}'s bastard daughter`; - } - } - } else { - child.slaveName = genes.name; - } - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveSurname = V.PC.slaveSurname; - } else { - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } else if (genes.mother === -1) { - child.slaveSurname = V.PC.slaveSurname; - } else { - if (genes.father === -1) { - child.slaveSurname = V.PC.slaveSurname; - } else if (genes.father > 0) { - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } else { - let currentFather = getSlave(genes.father); - if (currentFather !== undefined) { - if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") { - child.slaveSurname = currentFather.slaveSurname; - } - } - } - } else { - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } - } - } - } } else { child = GenerateNewSlave("XY", {mature: 0}); - child.slaveSurname = genes.surname; - if (!pregUpgrade) { - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveName = `Your clone`; - child.slaveSurname = V.PC.slaveSurname; - } else { - child.slaveName = `${genes.clone}'s clone`; - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } else if (genes.mother === -1) { - if (genes.father <= 0) { - child.slaveName = "Your son"; - } else { - child.slaveName = `Your and ${genes.fatherName}'s son`; - } - child.slaveSurname = V.PC.slaveSurname; - } else { - if (genes.father === -1) { - child.slaveName = `${genes.motherName} and your son`; - child.slaveSurname = V.PC.slaveSurname; - } else if (genes.father > 0) { - child.slaveName = `${genes.motherName} and ${genes.fatherName}'s son`; - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } else { - let currentFather = getSlave(genes.father); - if (currentFather !== undefined) { - if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") { - child.slaveSurname = currentFather.slaveSurname; - } - } - } - } else { - child.slaveName = `${genes.motherName}'s bastard son`; - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } - } - } - } else { - let childName = genes.name; - if (childName.indexOf("ovum") === 0) { - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveName = `Your clone`; - child.slaveSurname = V.PC.slaveSurname; - } else { - child.slaveName = `${genes.clone}'s clone`; - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } else if (genes.mother === -1) { - if (genes.father <= 0) { - child.slaveName = "Your son"; - } else { - child.slaveName = `Your and ${genes.fatherName}'s son`; - } - } else { - if (genes.father === -1) { - child.slaveName = `${genes.motherName} and your son`; - } else if (genes.father > 0) { - child.slaveName = `${genes.motherName} and ${genes.fatherName}'s son`; - } else { - child.slaveName = `${genes.motherName}'s bastard son`; - } - } - } else { - child.slaveName = genes.name; - } - if (genes.clone) { - if (genes.cloneID === -1) { - child.slaveSurname = V.PC.slaveSurname; - } else { - let cloneSeed = getSlave(genes.cloneID); - if (cloneSeed.slaveSurname !== 0 && cloneSeed.slaveSurname !== "") { - child.slaveSurname = cloneSeed.slaveSurname; - } - } - } else if (genes.mother === -1) { - child.slaveSurname = V.PC.slaveSurname; - } else { - if (genes.father === -1) { - child.slaveSurname = V.PC.slaveSurname; - } else if (genes.father > 0) { - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } else { - let currentFather = getSlave(genes.father); - if (currentFather !== undefined) { - if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") { - child.slaveSurname = currentFather.slaveSurname; - } - } - } - } else { - let currentMother = getSlave(genes.mother); - if (currentMother !== undefined) { - if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") { - child.slaveSurname = currentMother.slaveSurname; - } - } - } - } - } } + setSlaveName(); + setSurname(); child.actualAge = 0; if (genes.clone !== undefined) {