diff --git a/src/endWeek/events/expire.js b/src/endWeek/events/expire.js index a3e01063aa8d0de6b4e42df93e56add82681bde1..29117b16aebc198364de0553fcb2168891e8403b 100644 --- a/src/endWeek/events/expire.js +++ b/src/endWeek/events/expire.js @@ -22,11 +22,16 @@ globalThis.expirations = function() { if (slave) { App.UI.DOM.appendNewElement("p", el, expire(slave)); el.append(sectionBreak()); - removeSlave(slave); } } - - V.slaveExpirations = new Set(); + V.passageSwitchHandler = () => { + for (const slaveID of V.slaveExpirations) { + if (getSlave(slaveID)) { + removeSlave(getSlave(slaveID)); + } + } + V.slaveExpirations = new Set(); + }; return el; @@ -83,9 +88,8 @@ globalThis.expirations = function() { App.UI.DOM.appendNewElement("div", result, App.UI.DOM.link( `Plead necessity and reactivate ${his} indenture`, () => { - V.lowerClass -= 1; + keepSlave(-1000); r.push(`You plead necessity and place ${him} under another indenture, paying the trivial fees left over once ${he} has been charged for ${his} own forecasted upkeep. Naturally, ${he} offers no response at all to any of this.`); - cashX(-1000, "event", slave); }, [], "", @@ -140,8 +144,7 @@ globalThis.expirations = function() { App.Events.addNode(el, r); slave.indenture = -1; slave.indentureRestrictions = 0; - cashX(-1000, "event", slave); - V.lowerClass -= 1; + keepSlave(-1000); jQuery(result).empty().append(el); }, [], @@ -174,8 +177,7 @@ globalThis.expirations = function() { App.UI.DOM.appendNewElement("div", result, App.UI.DOM.link( `Offer ${him} a one year supplementary indenture`, () => { - cashX(forceNeg(_slaveCost), "slaveTransfer", slave); - V.lowerClass -= 1; + keepSlave(_slaveCost); jQuery(result).empty().append(`${He} smiles almost shyly when you offer ${him} a one year supplementary indenture. The price is reasonable, but definitely favorable to you. ${He} accepts it anyway, and you transfer the money into an escrow account to be held for ${him} until ${his} new indenture is done. Your sex slave once again, ${he} awaits your pleasure without a hint of fear.`); }, [], @@ -199,6 +201,7 @@ globalThis.expirations = function() { `Offer ${him} a one year supplementary indenture`, () => { cashX(forceNeg(_slaveCost), "slaveTransfer", slave); + V.slaveExpirations.delete(slave.ID); V.lowerClass -= 1; jQuery(result).empty().append(`${He} looks pensive when you offer ${him} a one year supplementary indenture. The price reflects the market, and is a reasonable compensation for a year of sexual slavery. ${He} accepts it after some consideration, and you transfer the money into an escrow account to be held for ${him} until ${his} new indenture is done. Your sex slave once again, ${he} awaits orders with complacency.`); }, @@ -227,5 +230,11 @@ globalThis.expirations = function() { note.append(slaveImpactLongTerm(slave)); return el; + + function keepSlave(cost) { + cashX(forceNeg(cost), "slaveTransfer", slave); + V.lowerClass -= 1; + V.slaveExpirations.delete(slave.ID); + } } };