From d6c2542d6e9e508867eb61eebbce612caa674d71 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Sun, 9 Aug 2020 15:27:26 -0700 Subject: [PATCH] Try to straighten out existing rivalry upgrade/downgrade logic. --- src/endWeek/saRivalries.js | 189 +++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 100 deletions(-) diff --git a/src/endWeek/saRivalries.js b/src/endWeek/saRivalries.js index 70115d6ca50..c265b47d31b 100644 --- a/src/endWeek/saRivalries.js +++ b/src/endWeek/saRivalries.js @@ -6,7 +6,7 @@ App.SlaveAssignment.rivalries = (function() { // eslint-disable-next-line no-unused-vars let he, him, his, hers, himself, girl, loli, He, His; - let rival; + let changed; return saRivalries; @@ -182,30 +182,60 @@ App.SlaveAssignment.rivalries = (function() { /** * @param {App.Entity.SlaveState} slave - * + * @param {App.Entity.SlaveState} rival + */ + function reduce(slave, rival) { + rival.rivalry--; + slave.rivalry--; + if (slave.rivalry === 0) { + rival.rivalryTarget = 0; + slave.rivalryTarget = 0; + } + changed = true; + } + + /** + * @param {App.Entity.SlaveState} slave + * @param {App.Entity.SlaveState} rival + */ + function increase(slave, rival) { + rival.rivalry++; + slave.rivalry++; + changed = true; + } + + /** + * @param {App.Entity.SlaveState} slave + * @param {App.Entity.SlaveState} rival + */ + function reconcile(slave, rival) { + rival.rivalry = 0; + rival.rivalryTarget = 0; + slave.rivalry = 0; + slave.rivalryTarget = 0; + changed = true; + } + + /** + * @param {App.Entity.SlaveState} slave */ function existingRivalry(slave) { - rival = getSlave(slave.rivalryTarget); - let incRivalry = 0; - let decRivalry = 0; - let reconciled = 0; - let worsenedRivalry = 0; - let lightenedRivalry = 0; - let lustyFix = 0; + const rival = getSlave(slave.rivalryTarget); let roll = jsRandom(0, 100); + changed = false; if (rival === undefined) { r.push(`<span class="red">Error, rivalryTarget not found.</span>`); } else { if (slave.fuckdoll) { r.push(`${slave.slaveName} is a living sex toy, not a person, it <span class="rivalry dec">can't really maintain any meaningful rivalry</span> with ${SlaveFullName(rival)}.`); - reconciled = 1; + reconcile(slave, rival); } else if (slave.fetish === "mindbroken") { r.push(`Since ${slave.slaveName} is mindbroken, ${he} <span class="rivalry dec">can't really maintain any meaningful rivalry</span> with ${SlaveFullName(rival)}.`); - reconciled = 1; + reconcile(slave, rival); } else if (rival.ID === slave.relationshipTarget && slave.relationship > 3) { r.push(`Since ${slave.slaveName} and ${slave.slaveName} are in a committed sexual relationship, they <span class="rivalry dec">can't really maintain any meaningful rivalry;</span> most disputes just end in a quick hatefucking.`); - reconciled = 1; + reconcile(slave, rival); } else { if (slave.need) { if (V.universalRulesConsent === 0) { @@ -218,8 +248,7 @@ App.SlaveAssignment.rivalries = (function() { rival.trust -= 3; if (slave.rivalry < 3) { r.push(`Of course, this <span class="rivalry inc">worsens their rivalry.</span>`); - incRivalry = 1; - worsenedRivalry = 1; + increase(slave, rival); } SimpleSexAct.Slaves(rival, slave, 5); } else if (slave.fetish === "dom") { @@ -229,8 +258,7 @@ App.SlaveAssignment.rivalries = (function() { rival.devotion -= 3; if (slave.rivalry < 3) { r.push(`Of course, this <span class="rivalry inc">worsens their rivalry.</span>`); - incRivalry = 1; - worsenedRivalry = 1; + increase(slave, rival); } SimpleSexAct.Slaves(rival, slave, 5); } @@ -238,123 +266,84 @@ App.SlaveAssignment.rivalries = (function() { } } } - if (worsenedRivalry !== 1) { - if (roll > 50) { - if (rival.fetish === slave.fetish) { - r.push(`${slave.slaveName} and ${SlaveFullName(rival)} share sexual interests, and in the sexual atmosphere of the arcology, it's <span class="rivalry dec">difficult for them to keep up their dislike</span> of one another with the mutual attraction.`); - decRivalry = 1; - lightenedRivalry = 1; + if (!changed && roll > 50) { + if (rival.fetish === slave.fetish) { + r.push(`${slave.slaveName} and ${SlaveFullName(rival)} share sexual interests, and in the sexual atmosphere of the arcology, it's <span class="rivalry dec">difficult for them to keep up their dislike</span> of one another with the mutual attraction.`); + reduce(slave, rival); + } + if (roll > 80 && slave.rivalry > 0) { + if (!changed && rival.trust < -20) { + if (slave.trust < -20) { + r.push(`Since both ${slave.slaveName} and ${SlaveFullName(rival)} are terrified of you, they work together to <span class="rivalry dec">get over their feud,</span> since it brings punishment on both of them.`); + reduce(slave, rival); + } } - if (roll > 80 && slave.rivalry > 0) { - if (rival.trust < -20) { - if (slave.trust < -20) { - r.push(`Since both ${slave.slaveName} and ${SlaveFullName(rival)} are terrified of you, they work together to <span class="rivalry dec">get over their feud,</span> since it brings punishment on both of them.`); - decRivalry = 1; - lightenedRivalry = 1; - } + if (!changed && rival.devotion > 50) { + if (slave.devotion > 50) { + r.push(`Since both ${slave.slaveName} and ${SlaveFullName(rival)} are devoted to you, they work together to <span class="rivalry dec">get over their feud,</span> since it gets in the way of their duties.`); + reduce(slave, rival); } - if (rival.devotion > 50) { - if (slave.devotion > 50) { - r.push(`Since both ${slave.slaveName} and ${SlaveFullName(rival)} are devoted to you, they work together to <span class="rivalry dec">get over their feud,</span> since it gets in the way of their duties.`); - decRivalry = 1; - lightenedRivalry = 1; - } + } + if (roll > 90 && slave.rivalry > 0) { + if (!changed && slave.energy > 95) { + r.push(`${slave.slaveName} lusts after ${SlaveFullName(rival)}, and does everything ${he} can to <span class="rivalry dec">patch up their differences.</span>`); + reduce(slave, rival); } - if (roll > 90 && slave.rivalry > 0) { - if (slave.energy > 95) { + if (!changed && slave.attrXX > 85) { + if (rival.vagina > -1 || rival.faceShape !== "masculine") { r.push(`${slave.slaveName} lusts after ${SlaveFullName(rival)}, and does everything ${he} can to <span class="rivalry dec">patch up their differences.</span>`); - decRivalry = 1; - lightenedRivalry = 1; - lustyFix = 1; - } - if (lustyFix !== 1) { - if (slave.attrXX > 85) { - if (rival.vagina > -1 || rival.faceShape !== "masculine") { - r.push(`${slave.slaveName} lusts after ${SlaveFullName(rival)}, and does everything ${he} can to <span class="rivalry dec">patch up their differences.</span>`); - decRivalry = 1; - lightenedRivalry = 1; - lustyFix = 1; - } - } + reduce(slave, rival); } - if (lustyFix !== 1) { - if (slave.attrXY > 85) { - if (canAchieveErection(rival) || rival.faceShape === "masculine") { - r.push(`${slave.slaveName} lusts after ${SlaveFullName(rival)}, and does everything ${he} can to <span class="rivalry dec">patch up their differences.</span>`); - decRivalry = 1; - lightenedRivalry = 1; - lustyFix = 1; - } - } + } + if (!changed && slave.attrXY > 85) { + if (canAchieveErection(rival) || rival.faceShape === "masculine") { + r.push(`${slave.slaveName} lusts after ${SlaveFullName(rival)}, and does everything ${he} can to <span class="rivalry dec">patch up their differences.</span>`); + reduce(slave, rival); } - if (lustyFix !== 1) { - if (rival.assignment !== slave.assignment) { - if (slave.subTarget !== rival.ID && rival.subTarget !== slave.ID) { - r.push(`With time apart ${slave.slaveName} and ${SlaveFullName(rival)} <span class="rivalry dec">dislike each other less.</span>`); - decRivalry = 1; - lightenedRivalry = 1; - } - } + } + if (!changed && rival.assignment !== slave.assignment) { + if (slave.subTarget !== rival.ID && rival.subTarget !== slave.ID) { + r.push(`With time apart ${slave.slaveName} and ${SlaveFullName(rival)} <span class="rivalry dec">dislike each other less.</span>`); + reduce(slave, rival); } } } } } - if (areRelated(slave, rival)) { - if (roll > 70 && slave.rivalry < 3 && lightenedRivalry !== 1) { + if (!changed && areRelated(slave, rival)) { + if (roll > 70 && slave.rivalry < 3) { r.push(`${slave.slaveName} and ${SlaveFullName(rival)} <span class="rivalry inc">pursue their family rivalry.</span>`); - incRivalry = 1; - worsenedRivalry = 1; - } else if (roll > 40 && slave.rivalry > 0 && worsenedRivalry !== 1) { + increase(slave, rival); + } else if (roll > 40 && slave.rivalry > 0) { r.push(`${slave.slaveName} and ${SlaveFullName(rival)} <span class="rivalry dec">patch up their family relationship.</span>`); - decRivalry = 1; - lightenedRivalry = 1; + reduce(slave, rival); } } - if (rival.origBodyOwnerID === slave.ID && lightenedRivalry !== 1) { + if (!changed && rival.origBodyOwnerID === slave.ID) { if (slave.rivalry < 3) { r.push(`${slave.slaveName} <span class="rivalry inc">refuses to accept ${SlaveFullName(rival)}'s control of ${his} former body,</span> worsening their rivalry.`); - incRivalry = 1; + increase(slave, rival); } - } else if (roll > (slave.devotion - slave.trust + 10) && lightenedRivalry !== 1) { + } else if (!changed && roll > (slave.devotion - slave.trust + 10)) { if (slave.rivalry < 3) { r.push(`${slave.slaveName} <span class="rivalry inc">bickers with ${SlaveFullName(rival)}</span> whenever ${he} can, worsening their rivalry.`); - incRivalry = 1; + increase(slave, rival); } - } else if (roll < (slave.devotion - slave.trust - 10) && slave.rivalry > 0 && worsenedRivalry !== 1) { + } else if (!changed && roll < (slave.devotion - slave.trust - 10) && slave.rivalry > 0) { r.push(`${slave.slaveName} does ${his} best to be nice to ${SlaveFullName(rival)}, and manages to <span class="rivalry dec">de-escalate their little feud.</span>`); - decRivalry = 1; + reduce(slave, rival); } } - - if (incRivalry !== 0) { - rival.rivalry++; - slave.rivalry++; - } else if (decRivalry !== 0) { - rival.rivalry--; - slave.rivalry--; - if (slave.rivalry === 0) { - rival.rivalryTarget = 0; - slave.rivalryTarget = 0; - } - } else if (reconciled !== 0) { - rival.rivalry = 0; - rival.rivalryTarget = 0; - slave.rivalry = 0; - slave.rivalryTarget = 0; - } } } - - /** * @param {App.Entity.SlaveState} slave * */ function rivalryValidation(slave) { // This will be obsoleted with multiple rivals system - rival = getSlave(slave.rivalryTarget); + const rival = getSlave(slave.rivalryTarget); if (rival !== undefined && slave.ID !== rival.rivalryTarget) { rival.rivalry = 0; rival.rivalryTarget = 0; -- GitLab