diff --git a/src/descriptions/officeDescription.js b/src/descriptions/officeDescription.js index 38eb166d4a4c571e2fe452cd3a573d05ebf05118..2ff0ae434436d052d4680f1e91c36055b6ac4196 100644 --- a/src/descriptions/officeDescription.js +++ b/src/descriptions/officeDescription.js @@ -464,13 +464,13 @@ App.Desc.officeDescription = function(lastElement) { function printTrinkets() { const frag = new DocumentFragment(); - /** @type {Array<HTMLElement>} */ + /** @type {Array<string|HTMLElement>} */ let trinketElements = []; let plurals = false; for (const [trinketDesc, value] of V.trinkets) { if ((typeof value === "number" && value === 1) || (Array.isArray(value) && value.length === 0)) { - trinketElements.push(App.UI.DOM.makeElement("li", capFirstChar(trinketDesc))); + trinketElements.push(capFirstChar(trinketDesc)); } else { trinketElements.push(trinketPluralReplacer(trinketDesc, value)); plurals = true; @@ -498,131 +498,132 @@ App.Desc.officeDescription = function(lastElement) { /** * * @param {string} desc - * @param {Array} array + * @param {number|FC.TrinketData[]} value * @returns {HTMLElement} */ - function trinketPluralReplacer(desc, array) { - const his = (array && array[0] && array[0].id && getSlave(array[0].id) ? getPronouns(getSlave(array[0].id)).possessive : "their"); - const he = (array && array[0] && array[0].id && getSlave(array[0].id) ? getPronouns(getSlave(array[0].id)).pronoun : "they"); + function trinketPluralReplacer(desc, value) { + const isArray = Array.isArray(value) && value.length > 0; + const his = (isArray && value[0].id && getSlave(value[0].id) ? getPronouns(getSlave(value[0].id)).possessive : "their"); + const he = (isArray && value[0].id && getSlave(value[0].id) ? getPronouns(getSlave(value[0].id)).pronoun : "they"); switch (desc) { case "best in show balls": - if (array.length > 0) { + if (isArray) { const el = document.createElement("span"); - if (array.length === 1) { - App.Events.addNode(el, [`A best in show ribbon awarded to`, slaveSentence(array), `for ${his} balls`]); + if (value.length === 1) { + App.Events.addNode(el, [`A best in show ribbon awarded to`, slaveSentence(value), `for ${his} balls`]); } else { - App.Events.addNode(el, [`Best in show ribbons awarded to`, slaveSentence(array), `for their balls`]); + App.Events.addNode(el, [`Best in show ribbons awarded to`, slaveSentence(value), `for their balls`]); } return el; } else { return null; } case "best in show milk cow": - if (array.length > 0) { + if (isArray) { const el = document.createElement("span"); - if (array.length === 1) { - App.Events.addNode(el, [`A best in show ribbon awarded to`, slaveSentence(array), `as a milk cow`]); + if (value.length === 1) { + App.Events.addNode(el, [`A best in show ribbon awarded to`, slaveSentence(value), `as a milk cow`]); } else { - App.Events.addNode(el, [`Best in show ribbons awarded to`, slaveSentence(array), `as milk cows`]); + App.Events.addNode(el, [`Best in show ribbons awarded to`, slaveSentence(value), `as milk cows`]); } return el; } else { return null; } case "best in show breeder": - if (array.length > 0) { + if (isArray) { const el = document.createElement("span"); - if (array.length === 1) { - App.Events.addNode(el, [`A best in show ribbon awarded to`, slaveSentence(array), `as a breeder`]); + if (value.length === 1) { + App.Events.addNode(el, [`A best in show ribbon awarded to`, slaveSentence(value), `as a breeder`]); } else { - App.Events.addNode(el, [`Best in show ribbons awarded to`, slaveSentence(array), `as breeders`]); + App.Events.addNode(el, [`Best in show ribbons awarded to`, slaveSentence(value), `as breeders`]); } return el; } else { return null; } case "famous courtesan": - if (array.length > 0) { + if (isArray) { const el = document.createElement("span"); - if (array.length === 1) { - App.Events.addNode(el, [`A framed article written about`, slaveSentence(array), `when ${he} debuted as a famous courtesan`]); + if (value.length === 1) { + App.Events.addNode(el, [`A framed article written about`, slaveSentence(value), `when ${he} debuted as a famous courtesan`]); } else { - App.Events.addNode(el, [`Framed articles written about`, slaveSentence(array), `when they debuted as famous courtesans`]); + App.Events.addNode(el, [`Framed articles written about`, slaveSentence(value), `when they debuted as famous courtesans`]); } return el; } else { return null; } case "famous whore": - if (array.length > 0) { + if (isArray) { const el = document.createElement("span"); - if (array.length === 1) { - App.Events.addNode(el, [`A framed pornographic advertisement for`, slaveSentence(array), `from the week ${he} became a famous whore`]); + if (value.length === 1) { + App.Events.addNode(el, [`A framed pornographic advertisement for`, slaveSentence(value), `from the week ${he} became a famous whore`]); } else { - App.Events.addNode(el, [`Framed pornographic advertisements from`, slaveSentence(array), `from the weeks they became famous whores`]); + App.Events.addNode(el, [`Framed pornographic advertisements from`, slaveSentence(value), `from the weeks they became famous whores`]); } return el; } else { return null; } case "catgirl icon": - if (array.length > 0) { + if (isArray) { const el = document.createElement("span"); - if (array.length === 1) { - App.Events.addNode(el, [`A gorgeous quasi-religious icon made by`, slaveSentence(array), `showing you creating the catgirl race`]); + if (value.length === 1) { + App.Events.addNode(el, [`A gorgeous quasi-religious icon made by`, slaveSentence(value), `showing you creating the catgirl race`]); } else { - App.Events.addNode(el, [`Gorgeous quasi-religious icons made by`, slaveSentence(array), `showing you creating the catgirl race`]); + App.Events.addNode(el, [`Gorgeous quasi-religious icons made by`, slaveSentence(value), `showing you creating the catgirl race`]); } return el; } else { return null; } case "cat clay sculpture": - if (array.length > 0) { + if (isArray) { const el = document.createElement("span"); - if (array.length === 1) { - App.Events.addNode(el, [`A small, elegant clay sculpture made by`, slaveSentence(array), `showing you surrounded by happy catgirl slaves`]); + if (value.length === 1) { + App.Events.addNode(el, [`A small, elegant clay sculpture made by`, slaveSentence(value), `showing you surrounded by happy catgirl slaves`]); } else { - App.Events.addNode(el, [`Small, elegant clay sculptures made by`, slaveSentence(array), `showing you surrounded by happy catgirl slaves`]); + App.Events.addNode(el, [`Small, elegant clay sculptures made by`, slaveSentence(value), `showing you surrounded by happy catgirl slaves`]); } return el; } else { return null; } case "cat drawing": - if (array.length > 0) { + if (isArray) { const el = document.createElement("span"); - if (array.length === 1) { - App.Events.addNode(el, [`A pretty drawing of you and`, slaveSentence(array), `cuddling together peacefully`]); + if (value.length === 1) { + App.Events.addNode(el, [`A pretty drawing of you and`, slaveSentence(value), `cuddling together peacefully`]); } else { - App.Events.addNode(el, [`Pretty drawings of you and`, slaveSentence(array), `cuddling together peacefully`]); + App.Events.addNode(el, [`Pretty drawings of you and`, slaveSentence(value), `cuddling together peacefully`]); } return el; } else { return null; } case "cat crayon": - if (array.length > 0) { + if (isArray) { const el = document.createElement("span"); - if (array.length === 1) { - App.Events.addNode(el, [`A red construction paper heart with crude crayon figures of you and`, slaveSentence(array), `holding hands above text reading "I LUV U ${V.PC.title !== 0 ? `MASTER` : `MISTRESS`}"`]); + if (value.length === 1) { + App.Events.addNode(el, [`A red construction paper heart with crude crayon figures of you and`, slaveSentence(value), `holding hands above text reading "I LUV U ${V.PC.title !== 0 ? `MASTER` : `MISTRESS`}"`]); } else { - App.Events.addNode(el, [`Red construction paper hearts with crude crayon figures of you and`, slaveSentence(array), `holding hands above text reading "I LUV U ${V.PC.title !== 0 ? `MASTER` : `MISTRESS`}"`]); + App.Events.addNode(el, [`Red construction paper hearts with crude crayon figures of you and`, slaveSentence(value), `holding hands above text reading "I LUV U ${V.PC.title !== 0 ? `MASTER` : `MISTRESS`}"`]); } return el; } else { return null; } case "a cloth napkin": - if (array.length > 0) { + if (isArray) { const el = document.createElement("span"); - if (array.length === 1) { - App.Events.addNode(el, [`A cloth napkin skillfully folded into the shape of`, array[0].napkinShape, `given to you by`, slaveSentence(array)]); + if (value.length === 1) { + App.Events.addNode(el, [`A cloth napkin skillfully folded into the shape of`, value[0].napkinShape, `given to you by`, slaveSentence(value)]); } else { const r = []; - // Napkins are weird; we need to sort by two properties: napkinShape and the slave. First, set up a map of the types of napkins, and attach the appropriate slaves to them by array: + // Napkins are weird; we need to sort by two properties: napkinShape and the slave. First, set up a map of the types of napkins, and attach the appropriate slaves to them by value: const napkinMap = new Map([]); - for (const slave of array) { + for (const slave of value) { if (!napkinMap.get(slave.napkinShape)) { napkinMap.set(slave.napkinShape, []); } @@ -640,9 +641,13 @@ App.Desc.officeDescription = function(lastElement) { return null; } case "a poster for the movie that was made about the love between one of your mercenaries and": { - const el = document.createElement("span"); - el.append("A poster for the movie that was made about the love between one of your mercenaries and ", slaveSentence(array), "."); - return el; + if (isArray) { + const el = document.createElement("span"); + el.append("A poster for the movie that was made about the love between one of your mercenaries and ", slaveSentence(value), "."); + return el; + } else { + return null; + } } // should never have plurals case "a collection of diplomas from expensive schools": diff --git a/src/endWeek/saSocialEffects.js b/src/endWeek/saSocialEffects.js index d4b42dfaca0d33773e942f325b0a863f1caf3677..7c0ec0a2cda1781aecf03bd2d12e0cfc26938900 100644 --- a/src/endWeek/saSocialEffects.js +++ b/src/endWeek/saSocialEffects.js @@ -3,6 +3,7 @@ */ App.SlaveAssignment.saSocialEffects = function(slave) { const {His, his, him, he, girl, wife} = getPronouns(slave); + let netFailedElite = 0; /** Build a social effect object * @param {FC.FutureSocietyDeco|""} FS @@ -289,7 +290,7 @@ App.SlaveAssignment.saSocialEffects = function(slave) { r.push(`an Elite`); } r.push(`child${slave.pregType > 1 ? 'ren are' : ' is'} growing within ${him}. The mark covering ${his} lower belly, coupled with ${his} gravidity and blessing, <span class="green">enamors</span> your populace.`); - V.failedElite -= (5 + slave.pregType); + netFailedElite -= (5 + slave.pregType); t.push(new SocialEffect("Eugenics", 3, "Breeder carrying elite baby", r.join(' '))); if (slave.abortionTat > 0) { r = []; @@ -329,7 +330,7 @@ App.SlaveAssignment.saSocialEffects = function(slave) { if (slave.pregKnown === 1 && V.eugenicsFullControl !== 1) { t.push(new SocialEffect("Eugenics", 0, "Unapproved pregnancy (ELITE WARNING)", `The Societal Elite <span class="red">judge you</span> for keeping pregnant slaves. It falls to the slaveowner to deal with subhuman pregnancies and you are failing in your duties as a member of the Elite.`)); - V.failedElite += (5 + slave.pregType); + netFailedElite += (5 + slave.pregType); } } if (slave.balls > 0 && slave.pubertyXY === 1 && slave.vasectomy === 0 && slave.ballType !== "sterile") { @@ -958,6 +959,9 @@ App.SlaveAssignment.saSocialEffects = function(slave) { } } } + + // apply elite failure + V.failedElite += netFailedElite; } function renderTooltip() {