From 897cb3a5ca5787926ddbec48206f1ccc5f8d9e9f Mon Sep 17 00:00:00 2001 From: Blank_Alt <12406-Blank_Alt@users.noreply.gitgud.io> Date: Mon, 1 Mar 2021 17:39:13 +0000 Subject: [PATCH] Incubator - PC pregnancy Fix [Ready to Merge] --- src/facilities/incubator/incubatorInteract.js | 202 +++++++----------- 1 file changed, 77 insertions(+), 125 deletions(-) diff --git a/src/facilities/incubator/incubatorInteract.js b/src/facilities/incubator/incubatorInteract.js index 91e9b6ef0d2..c4ff6c7e019 100644 --- a/src/facilities/incubator/incubatorInteract.js +++ b/src/facilities/incubator/incubatorInteract.js @@ -512,11 +512,36 @@ App.UI.incubator = function() { const _reservedNursery = WombReserveCount(V.PC, "nursery"); r.push(App.UI.DOM.makeElement("span", `You're ${V.PC.pregWeek} ${(V.PC.pregWeek === 1) ? `week`:`weeks`} pregnant`, ["pink", "bold"])); if (_WL === 1) { - r.push(`a baby.`); + r.push(`with a baby`); } else { - r.push(`${pregNumberName(_WL, 2)}.`); + r.push(`with ${pregNumberName(_WL, 2)}`); } - const choices = document.createElement("div"); + + if (reservedChildren < freeTanks) { + if (freeTanks === 1) { + r.push(`and have an <span class="lime">available aging tank.</span>`); + } else { + r.push(`and have <span class="lime">${freeTanks - reservedChildren} available aging tanks.</span>`); + } + } else if (reservedChildren >= freeTanks) { + r.push(`and <span class='red'>ran out of room for your offspring.</span>`); + } + + if (V.pregnancyMonitoringUpgrade === 1) { + r.push( + App.UI.DOM.link( + `Inspect pregnancy`, + () => { }, + [], + `Analyze PC Pregnancy` + ) + ); + } + + App.Events.addNode(el, r, "div"); + r = []; + + let choices = document.createElement("div"); choices.classList.add("choices"); if (_reservedIncubator > 0) { childrenReserved = 1; @@ -529,50 +554,41 @@ App.UI.incubator = function() { } else { r.push(`All ${_reservedIncubator} of your children will be placed in ${V.incubatorName}.`); } + } + App.Events.addNode(el, r, "div"); + r = []; - if ((_reservedIncubator < _WL) && (reservedChildren < freeTanks) && (_reservedIncubator - _reservedNursery > 0)) { - if (V.pregnancyMonitoringUpgrade === 1) { - linkArray.push( - App.UI.DOM.link( - `Inspect pregnancy`, - () => { }, - [], - `Analyze PC Pregnancy` - ) - ); - } + if (reservedChildren < freeTanks) { + if (_WL - _reservedNursery === 0) { + r.push( + App.UI.DOM.makeElement( + "span", + `Your ${(_WL === 1) ? `child is` : `children are`} already reserved for ${V.nurseryName}`, + "note" + ) + ); linkArray.push( App.UI.DOM.link( - `Keep another child`, + `Keep your ${(_WL === 1) ? `child` : `children`} here instead`, + () => { + WombChangeReserveType(V.PC, 'nursery', 'incubator'); + refresh(); + } + ) + ); + } else { + linkArray.push( + App.UI.DOM.link( + `Keep ${(_WL > 1) ? `a` : `your`} child`, () => { WombAddToGenericReserve(V.PC, 'incubator', 1); refresh(); } ) ); - if (_reservedIncubator > 0) { - linkArray.push( - App.UI.DOM.link( - `Keep one less child`, - () => { - WombCleanGenericReserve(V.PC, 'incubator', 1); - refresh(); - } - ) - ); - } - if (_reservedIncubator > 1) { - linkArray.push( - App.UI.DOM.link( - `Keep none of your children`, - () => { - WombCleanGenericReserve(V.PC, 'incubator', 9999); - refresh(); - } - ) - ); - } - if ((reservedChildren + _WL - _reservedIncubator) <= freeTanks) { + + const availableChildren = reservedChildren + _WL - _reservedIncubator; + if (_WL > 1 && (availableChildren <= freeTanks)) { linkArray.push( App.UI.DOM.link( `Keep the rest of your children`, @@ -583,103 +599,39 @@ App.UI.incubator = function() { ) ); } - } else if ((_reservedIncubator === _WL) || (reservedChildren === freeTanks) || (_reservedIncubator - _reservedNursery >= 0)) { - if (V.pregnancyMonitoringUpgrade === 1) { - linkArray.push( - App.UI.DOM.link( - `Inspect pregnancy`, - () => { }, - [], - `Analyze PC Pregnancy` - ) - ); - } - linkArray.push( - App.UI.DOM.link( - `Keep one less child`, - () => { - WombCleanGenericReserve(V.PC, 'incubator', 1); - refresh(); - } - ) - ); - if (_reservedIncubator > 1) { - App.UI.DOM.link( - `Keep none of your children`, - () => { - WombCleanGenericReserve(V.PC, 'incubator', 9999); - refresh(); - } - ); - } } - } else if (reservedChildren < freeTanks) { - if (_WL - _reservedNursery === 0) { - r.push( - App.UI.DOM.makeElement( - "span", - `Your ${(_WL === 1) ? `child is` : `children are`} already reserved for ${V.nurseryName}`, - "note" - ) - ); + choices.append(App.UI.DOM.generateLinksStrip(linkArray)); + el.append(choices); + } + + App.Events.addNode(el, r, "div"); + + choices = document.createElement("div"); + choices.classList.add("choices"); + linkArray = []; + if (_reservedIncubator > 0) { + linkArray.push( App.UI.DOM.link( - `Keep your ${(_WL === 1) ? `child` : `children`} here instead`, + `Keep one less child`, () => { - WombChangeReserveType(V.PC, 'nursery', 'incubator'); + WombCleanGenericReserve(V.PC, 'incubator', 1); refresh(); } - ); - } else { - r.push(``); - if (freeTanks === 1) { - r.push(`You have an <span class="lime"> available aging tank.</span>`); - } else { - r.push(`You have <span class="lime"> available aging tanks.</span>`); - } - if (V.pregnancyMonitoringUpgrade === 1) { - linkArray.push( - App.UI.DOM.link( - `Inspect pregnancy`, - () => { }, - [], - `Analyze PC Pregnancy` - ) - ); - } + ) + ); + } + if (_reservedIncubator > 1) { + linkArray.push( App.UI.DOM.link( - `Keep ${(_WL > 1) ? `a` : `your`} child`, + `Keep none of your children`, () => { - WombAddToGenericReserve(V.PC, 'incubator', 1); + WombCleanGenericReserve(V.PC, 'incubator', 9999); refresh(); } - ); - if ((_WL > 1) && (reservedChildren + _WL - _reservedIncubator) <= freeTanks) { - App.UI.DOM.link( - `Keep all of your children|Incubator`, - () => { - WombAddToGenericReserve(V.PC, 'incubator', 9999); - refresh(); - } - ); - } - } - } else if (reservedChildren === freeTanks) { - if (V.pregnancyMonitoringUpgrade === 1) { - linkArray.push( - App.UI.DOM.link( - `Inspect pregnancy`, - () => { }, - [], - `Analyze PC Pregnancy` - ) - ); - } - const noRoom = new DocumentFragment(); - noRoom.append(`You have `); - App.UI.DOM.appendNewElement("span", noRoom, `no room for your offspring.`, "red"); - linkArray.push(noRoom); + ) + ); } - App.Events.addNode(el, r, "div"); + choices.append(App.UI.DOM.generateLinksStrip(linkArray)); el.append(choices); -- GitLab