diff --git a/src/endWeek/saPregnancy.js b/src/endWeek/saPregnancy.js index cbb57dcb8d04d77467c8d2262c25eb73e9c02fde..fefa620048021c20b3647df91353a2fedfa87857 100644 --- a/src/endWeek/saPregnancy.js +++ b/src/endWeek/saPregnancy.js @@ -842,6 +842,19 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { } } + /** + * @param {number} fatherId + * @param {string} message + * @param {(slave: FC.SlaveState) => void | undefined} callback + */ + function runPregEvent(fatherId, message, callback) { + r.push(message); + knockMeUp(slave, 100, 2, fatherId); + if (callback) { + callback(slave); + } + } + /** * @param {FC.SlaveState} slave */ @@ -897,6 +910,8 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { } /** + * Priority is universal rules -> pregEvent from SAs if present -> general preg logic + * * @param {FC.SlaveState} slave */ function impregnation(slave) { @@ -904,6 +919,7 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { let Stud = getSlave(V.StudID); // May be undefined! const studIgnoresRules = (Stud && V.universalRulesImpregnation === "Stud" && Stud.career === "a breeding bull" && Stud.fetish === Fetish.MINDBROKEN && canMove(Stud)); const pussy = (slave.mpreg === 1 ? "asspussy" : "pussy"); + const impregEvent = App.EndWeek.saVars.getRandomPregEvent(slave); let satisfiedPregFetish = 0; let StudVaginal = 0; let rapeAddsFlaw = 0; @@ -1931,6 +1947,8 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { } else { knockMeUp(slave, 100, 2, -2); } + } else if (impregEvent) { + runPregEvent(impregEvent.fatherId, impregEvent.message, impregEvent.callback); } else if (conceptionSeed > (50 - (V.reproductionFormula * 10))) { switch (slave.assignment) { case Job.REST: @@ -1984,18 +2002,7 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { case Job.PUBLIC: case Job.WHORE: case Job.BROTHEL: - if (slave.eggType === "human") { - if (slave.pregKnown === 0) { - r.push(`Due to all the citizens cumming in ${his} fertile`); - if (slave.mpreg === 1) { - r.push(`ass,`); - } else { - r.push(`pussy,`); - } - r.push(`<span class="pregnant">${he} has become pregnant.</span>`); - } - knockMeUp(slave, 100, 2, -2); - } + // Handled now via preg events within their respective RAs. break; case Job.GLORYHOLE: case Job.ARCADE: diff --git a/src/endWeek/saServeThePublic.js b/src/endWeek/saServeThePublic.js index 0ae79ae25b8454f9a3847d80dbcb1dd7c279cc2b..5228182ea262c0f3d510e853b2cfa1d35571dfad 100644 --- a/src/endWeek/saServeThePublic.js +++ b/src/endWeek/saServeThePublic.js @@ -45,6 +45,7 @@ App.SlaveAssignment.serveThePublic = function saServeThePublic(slave) { if (V.showVignettes === 1) { assignmentVignette(slave); } + pregnancy(slave); return r; @@ -1571,4 +1572,32 @@ App.SlaveAssignment.serveThePublic = function saServeThePublic(slave) { } } } + + /** + * Checks for pregnancy + * @param {FC.SlaveState} slave + */ + function pregnancy(slave) { + if (!canGetPregnant(slave) || slave.eggType !== "human") { + return; + } + const fertileUseCount = slave.mpreg === 1 ? analUse : vaginalUse; + if (fertileUseCount < 1) { + return; + } + const pregChance = Math.log(fertileUseCount + 1) * (V.reproductionFormula ? 10 : 7.5); + if (jsRandom(0, 99) < pregChance) { + let citizenDesc = `a citizen`; + if (fertileUseCount > 100) { + citizenDesc = `masses of citizens`; + } else if (fertileUseCount > 50) { + citizenDesc = `a great deal of citizens`; + } else if (fertileUseCount > 10) { + citizenDesc = `several citizens`; + } else if (fertileUseCount > 1) { + citizenDesc = `citizens`; + } + App.EndWeek.saVars.addPregEvent(slave, -2, `Due to ${citizenDesc} cumming in ${his} fertile ${slave.mpreg === 1 ? anusDesc(slave, true) : vaginaDesc(slave, true)}, <span class="pregnant">${he} has become pregnant.</span>`); + } + } }; diff --git a/src/endWeek/saSharedVariables.js b/src/endWeek/saSharedVariables.js index 6f3c5f18b69c5e4809e4e961f2c8e926919510f6..a5d7605ebb31160b233e13290006a112a659e57c 100644 --- a/src/endWeek/saSharedVariables.js +++ b/src/endWeek/saSharedVariables.js @@ -73,6 +73,14 @@ App.EndWeek.SASharedVariables = class { this.facilitySpots = { servantsQuarters: 0 }; + /** + * Object that stores pregnancy events from the Slave Assignment reports report to use in saPregnancy. + * Can store multiple events and will randomly pick one. + * Key of the object should be the slave id. + * Includes an optional callback that can be used to increment sex act counts or update stats. + * @type {{[key: number]: { message: string, fatherId: number, callback: (slave: FC.SlaveState) => void | undefined }[]}} + */ + this.pregnancy = {}; } /** Compute shared subslave ratio (subslaves per ordinary slave) */ @@ -84,4 +92,30 @@ App.EndWeek.SASharedVariables = class { } return subCount / (V.dormitoryPopulation + V.roomsPopulation - subCount); } + + /** + * Helper to add a preg event to the facility pregnancy object. + * @param {FC.SlaveState} slave + * @param {number} fatherId + * @param {string} message + * @param {(slave: FC.SlaveState) => void | undefined} callback + */ + addPregEvent(slave, fatherId, message, callback=undefined) { + if (this.pregnancy[slave.ID]) { + this.pregnancy[slave.ID] = [...this.pregnancy[slave.ID], {message, fatherId, callback}]; + } else { + this.pregnancy[slave.ID] = [{message, fatherId, callback}]; + } + } + + /** + * @param {FC.SlaveState} slave + */ + getRandomPregEvent(slave) { + const events = this.pregnancy[slave.ID]; + if (!events) { + return null; + } + return jsEither(events); + } }; diff --git a/src/endWeek/saWhore.js b/src/endWeek/saWhore.js index 8ce549723f783ecdca2d4f847dbae1b2cccd5536..c6ec805db236fda1abe8c6110e8274a1e92666b3 100644 --- a/src/endWeek/saWhore.js +++ b/src/endWeek/saWhore.js @@ -53,6 +53,7 @@ App.SlaveAssignment.whore = function(slave) { if (V.showVignettes === 1) { assignmentVignette(slave); } + pregnancy(slave); return r; @@ -1661,4 +1662,32 @@ App.SlaveAssignment.whore = function(slave) { incomeStats.rep += Math.trunc(FuckResult * vignette.effect * 0.1); } } + + /** + * Checks for pregnancy + * @param {FC.SlaveState} slave + */ + function pregnancy(slave) { + if (!canGetPregnant(slave) || slave.eggType !== "human") { + return; + } + const fertileUseCount = slave.mpreg === 1 ? analUse : vaginalUse; + if (fertileUseCount < 1) { + return; + } + const pregChance = Math.log(fertileUseCount + 1) * (V.reproductionFormula ? 10 : 7.5); + if (jsRandom(0, 99) < pregChance) { + let customerDesc = `a customer`; + if (fertileUseCount > 100) { + customerDesc = `scores of customers`; + } else if (fertileUseCount > 50) { + customerDesc = `many customers`; + } else if (fertileUseCount > 10) { + customerDesc = `several customers`; + } else if (fertileUseCount > 1) { + customerDesc = `customers`; + } + App.EndWeek.saVars.addPregEvent(slave, -2, `Due to ${customerDesc} cumming in ${his} fertile ${slave.mpreg === 1 ? anusDesc(slave, true) : vaginaDesc(slave, true)}, <span class="pregnant">${he} has become pregnant.</span>`); + } + } };