diff --git a/src/descriptions/arcologyDescription.js b/src/descriptions/arcologyDescription.js index a554299ecaeca119512ea7a5bab05e3e15b467cb..3e7816b63e7f4672e3b257439424817f19cc6edf 100644 --- a/src/descriptions/arcologyDescription.js +++ b/src/descriptions/arcologyDescription.js @@ -898,7 +898,7 @@ App.Desc.playerArcology = function(lastElement) { } else if (A.FSEgyptianRevivalistIncestPolicy === 1) { buffer.push(`Close relationships between citizens, slaves and siblings are common.`); } - if (A.FSSubjugationistLawME === 1) { + if (A.FSSubjugationistLawME === 1 && typeof A.FSSubjugationistRace === "string") { buffer.push(`${capFirstChar(A.FSSubjugationistRace)} subhumans form a majority of the slaves.`); } if (A.FSChattelReligionistLaw === 1) { diff --git a/src/interaction/siFinancial.js b/src/interaction/siFinancial.js index b6f19c6efa20221677a7bddcd16f83f29bcd4839..ab933946cde9fa6e5a0b92bd8ff733d6481847b3 100644 --- a/src/interaction/siFinancial.js +++ b/src/interaction/siFinancial.js @@ -11,7 +11,7 @@ App.UI.SlaveInteract.financial = function(slave) { slave.porn.spending = Math.clamp(Math.ceil(slave.porn.spending / 1000) * 1000, 0, 5000); if (slave.porn.prestige === 3) { - App.UI.DOM.appendNewElement("div", el, `${He} is so prestigious in the realm of ${slave.porn.fameType} porn that ${his} fame is self-sustaining.`, "note") + App.UI.DOM.appendNewElement("div", el, `${He} is so prestigious in the realm of ${slave.porn.fameType} porn that ${his} fame is self-sustaining.`, "note"); } else if (slave.porn.feed === 0) { r = []; r.push(`The media hub is not releasing highlights of ${his} sex life.`); diff --git a/src/js/futureSocietyJS.js b/src/js/futureSocietyJS.js index 32c14eda04df65e2079520f2083ba66aa2bb653c..e96505c2a2fcc7e35d2a594dbb24b6f2ade510fa 100644 --- a/src/js/futureSocietyJS.js +++ b/src/js/futureSocietyJS.js @@ -58,7 +58,7 @@ globalThis.FutureSocieties = (function() { [ "FSPetiteAdmiration", "FSStatuesqueGlorification"] ]; - /** @type {Record<FC.FutureSociety, {noun: FC.FutureSocietyNoun, adj: FC.FutureSocietyAdj}} */ + /** @type {Record<FC.FutureSociety, {noun: FC.FutureSocietyNoun, adj: FC.FutureSocietyAdj}>} */ const DisplayName = { FSSupremacist: {noun: "Racial Supremacism", adj: "Supremacist"}, FSSubjugationist: {noun: "Racial Subjugationism", adj: "Subjugationist"}, diff --git a/src/js/ibcJS.js b/src/js/ibcJS.js index 654765c6b8e240538b43e58de1a9dfcce7d93916..a97f19d8f7b04620596874d3d778e63bdfdcb0f1 100644 --- a/src/js/ibcJS.js +++ b/src/js/ibcJS.js @@ -20,7 +20,9 @@ globalThis.ibc = (() => { /** The player's old master is a known parent, but we don't normally have a slavelike object * for him. We use this one instead, wherever necessary. * @type {IBCRelative} */ - const oldMaster = {ID: -3, mother: 0, father: 0, inbreedingCoeff: 0}; + const oldMaster = { + ID: -3, mother: 0, father: 0, inbreedingCoeff: 0 + }; /** Create a node for the given ID * @param {number} id @@ -38,9 +40,8 @@ globalThis.ibc = (() => { // Determine the length of the shared prefix between the two NodeCode parameters let prefix_len = (nca, ncb) => { let i = 0; - for (i=0; i<Math.min(nca.length, ncb.length); i++) { - if (nca[i] !== ncb[i]) - break; + for (i = 0; i < Math.min(nca.length, ncb.length); i++) { + if (nca[i] !== ncb[i]) { break; } } return i; }; @@ -53,8 +54,7 @@ globalThis.ibc = (() => { let match = false; b.nodecodes.forEach(ncb => { let l = prefix_len(nca, ncb); - if (l === 0 && match) - return; + if (l === 0 && match) { return; } if (l > 0) { match = true; @@ -79,10 +79,8 @@ globalThis.ibc = (() => { } let ret = null; - if (n.mother !== null) - ret = find_nc(nc, n.mother); - if (n.father !== null && ret === null) - ret = find_nc(nc, n.father); + if (n.mother !== null) { ret = find_nc(nc, n.mother); } + if (n.father !== null && ret === null) { ret = find_nc(nc, n.father); } return ret; }; @@ -100,15 +98,13 @@ globalThis.ibc = (() => { ret.nodecodes.forEach(nc => { let i = pfx_s.indexOf(nc.join(';')); - if (i === -1) - return; + if (i === -1) { return; } pfx.pop(i); pfx_s.pop(i); }); - if (anc.findIndex(s => (s[0] == ret)) === -1) - anc.push([ret, p]); + if (anc.findIndex(s => (s[0] == ret)) === -1) { anc.push([ret, p]); } } return anc; @@ -137,11 +133,7 @@ globalThis.ibc = (() => { let kinship = (mother, father) => { let _coeff = 0; - if (!mother || !father) - _coeff = 0; - else if (mother === father) - _coeff = 0.5 * (1 + coeff(mother)); - else { + if (!mother || !father) { _coeff = 0; } else if (mother === father) { _coeff = 0.5 * (1 + coeff(mother)); } else { let cf = 0; let cmn = common(mother, father); @@ -155,14 +147,12 @@ globalThis.ibc = (() => { cmn.forEach(el2 => { let co = el2[0]; - if (co == c) - return; + if (co == c) { return; } let m_pp = []; let f_pp = []; co.nodecodes.forEach(nc => { - if (nc.slice(0, p.length).join(';') != p_s) - return; + if (nc.slice(0, p.length).join(';') != p_s) { return; } m_pp = m_pp.concat(mps(mother, nc)); f_pp = f_pp.concat(mps(father, nc)); @@ -172,8 +162,7 @@ globalThis.ibc = (() => { f_pp.forEach(fp => { let mf_s = [mp.join(';'), fp.join(';')].join(','); let i = paths_s.indexOf(mf_s); - if (i === -1) - return; + if (i === -1) { return; } paths_s.pop(i); paths.pop(i); }); @@ -182,7 +171,7 @@ globalThis.ibc = (() => { paths.forEach(p => { let pfx = prefix_len(p[0], p[1]); - cf += 0.5**(p[0].length + p[1].length+1 - 2*pfx) * (1 + coeff(c)); + cf += 0.5 ** (p[0].length + p[1].length + 1 - 2 * pfx) * (1 + coeff(c)); }); }); @@ -194,8 +183,7 @@ globalThis.ibc = (() => { // Determine the coefficient of inbreeding of a node `n` let coeff = n => { - if (n._coeff === null) - n._coeff = kinship(n.mother, n.father); + if (n._coeff === null) { n._coeff = kinship(n.mother, n.father); } return n._coeff; }; @@ -230,8 +218,7 @@ globalThis.ibc = (() => { let seen = []; let curid = 0; Object.values(nodes).forEach(n => { - if (n.mother !== null || n.father !== null) - return; + if (n.mother !== null || n.father !== null) { return; } n.nodecodes.push([curid]); curid += 1; seen.push(n.id); @@ -241,18 +228,19 @@ globalThis.ibc = (() => { let oldSeenLength = -1; while (seen.length !== total) { oldSeenLength = seen.length; - Object.keys(nodes).forEach(s=> { + Object.keys(nodes).forEach(s => { let n = nodes[s]; - if (seen.includes(+s)) // We've already done this + if (seen.includes(+s)) { // We've already done this return; - else if ((n.mother !== null && n.mother.nodecodes.length === 0) || (n.father !== null && n.father.nodecodes.length === 0)) // Too soon, we haven't done its parents + } else if ((n.mother !== null && n.mother.nodecodes.length === 0) || (n.father !== null && n.father.nodecodes.length === 0)) { // Too soon, we haven't done its parents return; + } seen.push(n.id); // Compute the NodeCodes from its parents [n.mother, n.father].forEach((a, i) => { if (a === null || (n.mother === n.father && i === 1)) // Ignore missing parents/repeated - return; + { return; } a.nodecodes.forEach(nc => { // Copy the NodeCode, push the child number, then add it @@ -270,7 +258,7 @@ globalThis.ibc = (() => { // dump all the nodes participating in or descended from the cycle and let the player figure it out if (oldSeenLength === seen.length) { const badSlaveIDs = Object.keys(nodes).filter(s => !seen.includes(+s)).map(k => nodes[k].id); - throw(`Inbreeding calculation: heritance cycle detected. Check slave IDs: ${badSlaveIDs}`); + throw (`Inbreeding calculation: heritance cycle detected. Check slave IDs: ${badSlaveIDs}`); } } @@ -285,7 +273,7 @@ globalThis.ibc = (() => { * @param {boolean} [ignore_coeffs=false] * @returns {Object.<number, IBCNode>|{}} */ - let nodes_slaves = (slaves, ignore_coeffs=false) => { + let nodes_slaves = (slaves, ignore_coeffs = false) => { let nodes = {}; /** Recursively create the nodes we need, moving upwards from the given slave @@ -346,7 +334,7 @@ globalThis.ibc = (() => { * @param {boolean} [ignore_coeffs=false] * @returns {Object.<number, number>} */ - let coeff_slaves = (slaves, ignore_coeffs=false) => { + let coeff_slaves = (slaves, ignore_coeffs = false) => { /** @type {Object.<number, number>} */ let ret = {}; if (!ignore_coeffs) { @@ -379,7 +367,7 @@ globalThis.ibc = (() => { * @param {boolean} [ignore_coeffs=false] * @returns {number} */ - let kinship_slaves = (a, b, ignore_coeffs=false) => { + let kinship_slaves = (a, b, ignore_coeffs = false) => { if (!a || !b) { return 0; } @@ -392,13 +380,11 @@ globalThis.ibc = (() => { * @param {boolean} [ignore_coeffs=false] * @returns {number} */ - let coeff_slave = (slave, ignore_coeffs=false) => { - if (!ignore_coeffs && "inbreedingCoeff" in slave && slave.inbreedingCoeff !== -1) - return slave.inbreedingCoeff; + let coeff_slave = (slave, ignore_coeffs = false) => { + if (!ignore_coeffs && "inbreedingCoeff" in slave && slave.inbreedingCoeff !== -1) { return slave.inbreedingCoeff; } let gp = find_gp(slave.ID); - if (!ignore_coeffs && gp !== null && "inbreedingCoeff" in gp && gp.inbreedingCoeff !== -1) - return gp.inbreedingCoeff; + if (!ignore_coeffs && gp !== null && "inbreedingCoeff" in gp && gp.inbreedingCoeff !== -1) { return gp.inbreedingCoeff; } return coeff_slaves([slave], ignore_coeffs)[slave.ID]; }; @@ -410,7 +396,7 @@ globalThis.ibc = (() => { * @param {boolean} [ignore_coeffs=false] * @returns {Object.<number, number>} */ - let kinship_one_many = (a, others, ignore_coeffs=false) => { + let kinship_one_many = (a, others, ignore_coeffs = false) => { let nodes = nodes_slaves(others.concat([a]), ignore_coeffs); let ks = {0: 0}; @@ -433,12 +419,9 @@ globalThis.ibc = (() => { // occurrences of the COI for the affected slaves /** @type {IBCRelative[]} */ let all_slave_like = V.slaves.concat(V.genePool).concat(V.cribs).concat(V.tanks).concat(Object.values(V.missingTable)); - if (V.boomerangSlave !== 0) - all_slave_like.push(V.boomerangSlave); - if (V.traitor !== 0) - all_slave_like.push(V.traitor); - if (V.activeSlave !== 0) - all_slave_like.push(V.activeSlave); + if (V.boomerangSlave !== 0) { all_slave_like.push(V.boomerangSlave); } + if (V.traitor !== 0) { all_slave_like.push(V.traitor); } + if (V.activeSlave !== 0) { all_slave_like.push(V.activeSlave); } all_slave_like.push(V.PC); // Add a fake entry for the PC's old master all_slave_like.push(oldMaster); @@ -457,10 +440,8 @@ globalThis.ibc = (() => { // Add fetuses all_fetuses.filter(f => (f.father === id || f.mother === id)).forEach(f => { // We may have to manually add the parents later - if (specificCharacterID(f.father)) - cur_fetus_parents.add(f.father); - if (specificCharacterID(f.mother)) - cur_fetus_parents.add(f.mother); + if (specificCharacterID(f.father)) { cur_fetus_parents.add(f.father); } + if (specificCharacterID(f.mother)) { cur_fetus_parents.add(f.mother); } cur_fetuses.add(f); }); @@ -509,8 +490,7 @@ globalThis.ibc = (() => { // Use a string of the form "parent;parent" to store the cache value; since kinship is // commutative, the minimum parent ID will be first let kinship_str = Math.min(f.mother, f.father) + ';' + Math.max(f.mother, f.father); - if (!kinship_cache.has(kinship_str)) - kinship_cache.set(kinship_str, kinship(nodes[f.mother], nodes[f.father])); + if (!kinship_cache.has(kinship_str)) { kinship_cache.set(kinship_str, kinship(nodes[f.mother], nodes[f.father])); } f.inbreedingCoeff = kinship_cache.get(kinship_str); }); diff --git a/src/js/statsChecker/eyeChecker.js b/src/js/statsChecker/eyeChecker.js index afd7bfa80946ea64770e8b30e19f381c739cbcba..7014da62b7795bf87b7c6b899a76f2d49f28e18c 100644 --- a/src/js/statsChecker/eyeChecker.js +++ b/src/js/statsChecker/eyeChecker.js @@ -266,7 +266,7 @@ globalThis.getGeneticEyeColor = function(playerOrSlave, side) { if (side !== "left" && side !== "right") { return "ERROR:" + side; } if (playerOrSlave.geneticQuirks.albinism === 2) { - const slave = (/** @type App.Entity.SlaveState */(playerOrSlave)); + const slave = (/** @type {App.Entity.SlaveState} */(playerOrSlave)); return slave.albinismOverride && slave.albinismOverride.eyeColor; } else { if (side === "left" && typeof playerOrSlave.geneticQuirks.heterochromia === "string") {