From 1fd11ddafae921ffa329f88cd5a8363c41d1b24d Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Thu, 5 Nov 2020 21:00:53 -0500
Subject: [PATCH] bioreactor loop fix

---
 src/endWeek/reports/dairyReport.js | 94 +++++++++++++++---------------
 1 file changed, 46 insertions(+), 48 deletions(-)

diff --git a/src/endWeek/reports/dairyReport.js b/src/endWeek/reports/dairyReport.js
index 9a2830d527a..6d6f1c2d2c2 100644
--- a/src/endWeek/reports/dairyReport.js
+++ b/src/endWeek/reports/dairyReport.js
@@ -1323,60 +1323,58 @@ App.EndWeek.dairyReport = function() {
 	}
 
 	if (V.createBioreactors === 1 && V.bioreactorPerfectedID !== 0) {
-		for (const slave of _slaves) {
+		const bioreactor = getSlave(V.bioreactorPerfectedID);
+		if (bioreactor) {
 			let _gender;
-			if (slave.ID === V.bioreactorPerfectedID) {
-				if (slave.ovaries === 1) {
-					if (slave.balls === 0) {
-						V.bioreactorsXX++;
-						_gender = "XX";
-					} else {
-						V.bioreactorsHerm++;
-						_gender = "herm";
-					}
+			if (bioreactor.ovaries === 1) {
+				if (bioreactor.balls === 0) {
+					V.bioreactorsXX++;
+					_gender = "XX";
 				} else {
-					if (slave.balls === 0) {
-						V.bioreactorsBarren++;
-						_gender = "barren";
-					} else {
-						V.bioreactorsXY++;
-						_gender = "XY";
-					}
+					V.bioreactorsHerm++;
+					_gender = "herm";
 				}
-				({
-					he, him, his, He, His, wife, girl
-				} = getPronouns(slave));
-				const _ageInWeeks = 52 * (V.retirementAge - slave.physicalAge);
-				r = [];
-				r.push(`${SlaveFullName(slave)}'s breasts,`);
-				if (slave.balls > 0) {
-					r.push(`balls,`);
-				}
-				if (slave.ovaries === 1) {
-					r.push(`belly,`);
-				}
-				r.push(`body, and mind have been completely adapted to synthesize useful products. ${He} has been reclassified as part of the machine ${he}'s now permanently attached to. This combination is projected to produce approximately`);
-				if (slave.balls > 0) {
-					r.push(commaNum(1000 * Math.trunc((_BF[_gender].cum * _ageInWeeks) / 1000)));
-					r.push(`liters of cum,`);
+			} else {
+				if (bioreactor.balls === 0) {
+					V.bioreactorsBarren++;
+					_gender = "barren";
+				} else {
+					V.bioreactorsXY++;
+					_gender = "XY";
 				}
-				if (slave.ovaries === 1) {
-					r.push(commaNum(100 * Math.trunc((_BF[_gender].femCum * _ageInWeeks) / 100)));
-					r.push(`liters of vaginal secretions,`);
-					if (V.dairyPregSetting === 3) {
-						r.push((13 * (V.retirementAge - slave.physicalAge)).toString());
-					} else {
-						r.push((5 * (V.retirementAge - slave.physicalAge)).toString());
-					}
-					r.push(`slaves,`);
+			}
+			({
+				he, him, his, He, His, wife, girl
+			} = getPronouns(bioreactor));
+			const _ageInWeeks = 52 * (V.retirementAge - bioreactor.physicalAge);
+			r = [];
+			r.push(`${SlaveFullName(bioreactor)}'s breasts,`);
+			if (bioreactor.balls > 0) {
+				r.push(`balls,`);
+			}
+			if (bioreactor.ovaries === 1) {
+				r.push(`belly,`);
+			}
+			r.push(`body, and mind have been completely adapted to synthesize useful products. ${He} has been reclassified as part of the machine ${he}'s now permanently attached to. This combination is projected to produce approximately`);
+			if (bioreactor.balls > 0) {
+				r.push(commaNum(1000 * Math.trunc((_BF[_gender].cum * _ageInWeeks) / 1000)));
+				r.push(`liters of cum,`);
+			}
+			if (bioreactor.ovaries === 1) {
+				r.push(commaNum(100 * Math.trunc((_BF[_gender].femCum * _ageInWeeks) / 100)));
+				r.push(`liters of vaginal secretions,`);
+				if (V.dairyPregSetting === 3) {
+					r.push((13 * (V.retirementAge - bioreactor.physicalAge)).toString());
+				} else {
+					r.push((5 * (V.retirementAge - bioreactor.physicalAge)).toString());
 				}
-				r.push(`and`);
-				r.push(commaNum(1000 * Math.trunc((_BF[_gender].milk * _ageInWeeks) / 1000)));
-				r.push(`liters of milk over a ${V.retirementAge - slave.physicalAge} year period before its biological components must be replaced.`);
-				App.Events.addParagraph(el, r);
-				removeSlave(slave);
-				break;
+				r.push(`slaves,`);
 			}
+			r.push(`and`);
+			r.push(commaNum(1000 * Math.trunc((_BF[_gender].milk * _ageInWeeks) / 1000)));
+			r.push(`liters of milk over a ${V.retirementAge - bioreactor.physicalAge} year period before its biological components must be replaced.`);
+			App.Events.addParagraph(el, r);
+			removeSlave(bioreactor);
 		}
 	}
 
-- 
GitLab