diff --git a/src/endWeek/saRivalries.js b/src/endWeek/saRivalries.js index f2c6a2e3668e4254359d4861ad7ac9c80706e06c..c265b47d31baa731811462cebb227d35556b3370 100644 --- a/src/endWeek/saRivalries.js +++ b/src/endWeek/saRivalries.js @@ -6,8 +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 slavesLength; + let changed; return saRivalries; @@ -17,22 +16,17 @@ App.SlaveAssignment.rivalries = (function() { */ function saRivalries(slave) { r = []; - slavesLength = V.slaves.length; ({ // eslint-disable-next-line no-unused-vars he, him, his, hers, himself, girl, He, His, loli } = getPronouns(slave)); - if (slave.rivalry === 0) { - if (slave.fuckdoll === 0 && slave.fetish !== "mindbroken") { - if (isSlaveAvailable(slave) && slave.assignment !== window.Job.CONFINEMENT) { - if (slave.devotion < jsRandom(20, 100) && slave.trust > jsRandom(-100, -20)) { - generateRivalry(slave); - } - } + if (canStartRivalry(slave)) { + if (isSlaveAvailable(slave) && slave.assignment !== Job.CONFINEMENT) { + generateRivalry(slave); } - } else { + } else if (slave.rivalry) { existingRivalry(slave); } if (slave.rivalry) { @@ -42,172 +36,206 @@ App.SlaveAssignment.rivalries = (function() { return r.join(" "); } + /** Can this slave possibly get a new rival? + * @param {App.Entity.SlaveState} slave + * @returns {boolean} + */ + function canStartRivalry(slave) { + const headstrong = (slave.devotion < jsRandom(20, 100)) && (slave.trust > jsRandom(-100, -20)); + return (slave.rivalry === 0 && slave.fetish !== "mindbroken" && slave.fuckdoll === 0 && headstrong); + } + /** * @param {App.Entity.SlaveState} slave * */ function generateRivalry(slave) { let foundRival = 0; - const slavesLength = V.slaves.length; - for (let sar = 0; sar < slavesLength; sar++) { - if (V.slaves[sar].ID !== slave.ID && V.slaves[sar].rivalry === 0 && V.slaves[sar].ID !== slave.relationshipTarget) { - if (V.slaves[sar].fetish !== "mindbroken" && V.slaves[sar].fuckdoll === 0) { - if (V.slaves[sar].devotion < jsRandom(20, 100) && V.slaves[sar].trust > jsRandom(-100, -20)) { - if (V.slaves[sar].origBodyOwnerID === slave.ID && V.slaves[sar].devotion > 0 && slave.devotion < -30) { - r.push(`${slave.slaveName} loathes that ${SlaveFullName(V.slaves[sar])} is using <span class="em">${his}</span> body to benefit you and makes it abundantly clear every chance ${he} gets. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } - if (foundRival !== 1 && slave.behavioralFlaw !== "none") { - switch (slave.behavioralFlaw) { - case "arrogant": - if (V.slaves[sar].intelligence > slave.intelligence+slave.intelligenceImplant) { - r.push(`${slave.slaveName} is an arrogant bitch, and ${SlaveFullName(V.slaves[sar])} is authentically smarter than ${he} is, which of course ${he} cannot stand. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } - break; - case "bitchy": - if (V.slaves[sar].behavioralFlaw === "odd") { - r.push(`${slave.slaveName} is a bit of a bitch, and poor odd ${SlaveFullName(V.slaves[sar])} is a convenient target for ${his} bullying. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } - break; - case "odd": - if (V.slaves[sar].behavioralFlaw === "bitchy") { - r.push(`${slave.slaveName} is rather strange. ${SlaveFullName(V.slaves[sar])}, who is kind of a bitch, frequently bullies ${him} about it. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } - break; - case "hates men": - if (V.slaves[sar].attrXX > 35) { - if (V.slaves[sar].faceShape === "masculine" || V.slaves[sar].faceShape === "androgynous" ) { - if (V.slaves[sar].muscles > 10) { - if (V.slaves[sar].vagina > -1) { - r.push(`${slave.slaveName} hates men, and poor butch ${SlaveFullName(V.slaves[sar])} really gets to ${him}, despite having a pussy and everything. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } else { - r.push(`${slave.slaveName} hates men, and poor masculine ${SlaveFullName(V.slaves[sar])} really gets to ${him}. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } - } + for (const potentialRival of V.slaves) { + if (canStartRivalry(potentialRival) && potentialRival.ID !== slave.ID && potentialRival.ID !== slave.relationshipTarget) { + if (potentialRival.origBodyOwnerID === slave.ID && potentialRival.devotion > 0 && slave.devotion < -30) { + r.push(`${slave.slaveName} loathes that ${SlaveFullName(potentialRival)} is using <span class="em">${his}</span> body to benefit you and makes it abundantly clear every chance ${he} gets. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; + } + if (foundRival !== 1 && slave.behavioralFlaw !== "none") { + switch (slave.behavioralFlaw) { + case "arrogant": + if (potentialRival.intelligence > slave.intelligence+slave.intelligenceImplant) { + r.push(`${slave.slaveName} is an arrogant bitch, and ${SlaveFullName(potentialRival)} is authentically smarter than ${he} is, which of course ${he} cannot stand. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; + } + break; + case "bitchy": + if (potentialRival.behavioralFlaw === "odd") { + r.push(`${slave.slaveName} is a bit of a bitch, and poor odd ${SlaveFullName(potentialRival)} is a convenient target for ${his} bullying. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; + } + break; + case "odd": + if (potentialRival.behavioralFlaw === "bitchy") { + r.push(`${slave.slaveName} is rather strange. ${SlaveFullName(potentialRival)}, who is kind of a bitch, frequently bullies ${him} about it. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; + } + break; + case "hates men": + if (potentialRival.attrXX > 35) { + if (potentialRival.faceShape === "masculine" || potentialRival.faceShape === "androgynous" ) { + if (potentialRival.muscles > 10) { + if (potentialRival.vagina > -1) { + r.push(`${slave.slaveName} hates men, and poor butch ${SlaveFullName(potentialRival)} really gets to ${him}, despite having a pussy and everything. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; + } else { + r.push(`${slave.slaveName} hates men, and poor masculine ${SlaveFullName(potentialRival)} really gets to ${him}. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; } } - break; - case "hates women": - if (V.slaves[sar].attrXY > 35) { - if (V.slaves[sar].faceShape !== "masculine") { - if (V.slaves[sar].muscles <= 30) { - if (V.slaves[sar].vagina > -1) { - r.push(`${slave.slaveName} hates women, and something about the feminine ${SlaveFullName(V.slaves[sar])} really gets to ${him}. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } else { - r.push(`${slave.slaveName} hates women, and something about the girly ${SlaveFullName(V.slaves[sar])} really gets to ${him}, despite poor V.slaves[sar].slaveName not being perfectly female at all. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } - } + } + } + break; + case "hates women": + if (potentialRival.attrXY > 35) { + if (potentialRival.faceShape !== "masculine") { + if (potentialRival.muscles <= 30) { + if (potentialRival.vagina > -1) { + r.push(`${slave.slaveName} hates women, and something about the feminine ${SlaveFullName(potentialRival)} really gets to ${him}. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; + } else { + r.push(`${slave.slaveName} hates women, and something about the girly ${SlaveFullName(potentialRival)} really gets to ${him}, despite poor potentialRival.slaveName not being perfectly female at all. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; } } - break; - case "gluttonous": - if (V.slaves[sar].behavioralFlaw === "anorexic") { - r.push(`${slave.slaveName}, who loves food, can't stand ${SlaveFullName(V.slaves[sar])}'s prissy anorexia. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } else if (V.slaves[sar].weight < -30) { - r.push(`${slave.slaveName}, who loves food, can't stand ${SlaveFullName(V.slaves[sar])}'s severe emaciation. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } - break; - case "anorexic": - if (V.slaves[sar].behavioralFlaw === "gluttonous") { - r.push(`${slave.slaveName}, an anorexic, can't stand ${SlaveFullName(V.slaves[sar])}'s disgusting gluttony. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } else if (V.slaves[sar].weight > 95) { - r.push(`${slave.slaveName}, an anorexic, can't stand ${SlaveFullName(V.slaves[sar])}'s immense girth. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } - break; - case "devout": - if (V.slaves[sar].behavioralFlaw === "liberated") { - r.push(`${slave.slaveName}, who is devout and might be considered rather conservative if ${he} were free, can't stand ${SlaveFullName(V.slaves[sar])}'s revolting gender liberation. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } - break; - case "liberated": - if (V.slaves[sar].behavioralFlaw === "devout") { - r.push(`${slave.slaveName}, who is liberated and might be considered rather liberal if ${he} were free, can't stand ${SlaveFullName(V.slaves[sar])}'s bigoted religious faith. <span class="rivalry inc">They start to dislike each other.</span>`); - foundRival = 1; - } - break; - } - } - if (foundRival !== 1 && V.slaves[sar].assignment === slave.assignment) { - if (jsRandom(0, 1) === 1) { - r.push(`${slave.slaveName} and ${SlaveFullName(V.slaves[sar])} see too much of each other while they`); - switch (V.slaves[sar].assignment) { - case window.Job.HOUSE: - case window.Job.QUARTER: - r.push(`work as servants`); - break; - case window.Job.SUBORDINATE: - r.push(`prepare to serve your other slaves`); - break; - case window.Job.GLORYHOLE: - r.push(`work nearby glory holes`); - break; - case window.Job.CELLBLOCK: - r.push(`are confined in nearby cells`); - break; - case window.Job.FUCKTOY: - r.push(`wait for you to use them`); - break; - default: - r.push(`${V.slaves[sar].assignment}`); } - r.push(`and <span class="rivalry inc">start to dislike each other.</span>`); + } + break; + case "gluttonous": + if (potentialRival.behavioralFlaw === "anorexic") { + r.push(`${slave.slaveName}, who loves food, can't stand ${SlaveFullName(potentialRival)}'s prissy anorexia. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; + } else if (potentialRival.weight < -30) { + r.push(`${slave.slaveName}, who loves food, can't stand ${SlaveFullName(potentialRival)}'s severe emaciation. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; + } + break; + case "anorexic": + if (potentialRival.behavioralFlaw === "gluttonous") { + r.push(`${slave.slaveName}, an anorexic, can't stand ${SlaveFullName(potentialRival)}'s disgusting gluttony. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; + } else if (potentialRival.weight > 95) { + r.push(`${slave.slaveName}, an anorexic, can't stand ${SlaveFullName(potentialRival)}'s immense girth. <span class="rivalry inc">They start to dislike each other.</span>`); foundRival = 1; } - } - if (foundRival === 1) { - // needed to break the loop if the case statement picked a rival. - // might as well use it to condense all the rival sets too. - slave.rivalry = 1; - slave.rivalryTarget = V.slaves[sar].ID; - V.slaves[sar].rivalry = 1; - V.slaves[sar].rivalryTarget = slave.ID; break; + case "devout": + if (potentialRival.behavioralFlaw === "liberated") { + r.push(`${slave.slaveName}, who is devout and might be considered rather conservative if ${he} were free, can't stand ${SlaveFullName(potentialRival)}'s revolting gender liberation. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; + } + break; + case "liberated": + if (potentialRival.behavioralFlaw === "devout") { + r.push(`${slave.slaveName}, who is liberated and might be considered rather liberal if ${he} were free, can't stand ${SlaveFullName(potentialRival)}'s bigoted religious faith. <span class="rivalry inc">They start to dislike each other.</span>`); + foundRival = 1; + } + break; + } + } + if (foundRival !== 1 && potentialRival.assignment === slave.assignment) { + if (jsRandom(0, 1) === 1) { + r.push(`${slave.slaveName} and ${SlaveFullName(potentialRival)} see too much of each other while they`); + switch (potentialRival.assignment) { + case Job.HOUSE: + case Job.QUARTER: + r.push(`work as servants`); + break; + case Job.SUBORDINATE: + r.push(`prepare to serve your other slaves`); + break; + case Job.GLORYHOLE: + r.push(`work nearby glory holes`); + break; + case Job.CELLBLOCK: + r.push(`are confined in nearby cells`); + break; + case Job.FUCKTOY: + r.push(`wait for you to use them`); + break; + default: + r.push(`${potentialRival.assignment}`); } + r.push(`and <span class="rivalry inc">start to dislike each other.</span>`); + foundRival = 1; } } + if (foundRival === 1) { + // needed to break the loop if the case statement picked a rival. + // might as well use it to condense all the rival sets too. + slave.rivalry = 1; + slave.rivalryTarget = potentialRival.ID; + potentialRival.rivalry = 1; + potentialRival.rivalryTarget = slave.ID; + break; + } } } } /** * @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 commited 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; + 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.`); + reconcile(slave, rival); } else { if (slave.need) { if (V.universalRulesConsent === 0) { @@ -219,9 +247,8 @@ App.SlaveAssignment.rivalries = (function() { slave.devotion += 3; rival.trust -= 3; if (slave.rivalry < 3) { - r.push(`Of course, this <span class="rival inc">worsens their rivalry.</span>`); - incRivalry = 1; - worsenedRivalry = 1; + r.push(`Of course, this <span class="rivalry inc">worsens their rivalry.</span>`); + increase(slave, rival); } SimpleSexAct.Slaves(rival, slave, 5); } else if (slave.fetish === "dom") { @@ -230,9 +257,8 @@ App.SlaveAssignment.rivalries = (function() { slave.devotion += 3; rival.devotion -= 3; if (slave.rivalry < 3) { - r.push(`Of course, this <span class="rival inc">worsens their rivalry.</span>`); - incRivalry = 1; - worsenedRivalry = 1; + r.push(`Of course, this <span class="rivalry inc">worsens their rivalry.</span>`); + increase(slave, rival); } SimpleSexAct.Slaves(rival, slave, 5); } @@ -240,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="rival 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="rival 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="rival 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) { - r.push(`${slave.slaveName} lusts after ${SlaveFullName(rival)}, and does everything ${he} can to <span class="rival dec">patch up their differences.</span>`); - decRivalry = 1; - lightenedRivalry = 1; - lustyFix = 1; + 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>`); + reduce(slave, rival); } - 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="rival dec">patch up their differences.</span>`); - decRivalry = 1; - lightenedRivalry = 1; - lustyFix = 1; - } - } - } - 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="rival 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="rival 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) { - r.push(`${slave.slaveName} and ${SlaveFullName(rival)} <span class="rival inc">pursue their family rivalry.</span>`); - incRivalry = 1; - worsenedRivalry = 1; - } else if (roll > 40 && slave.rivalry > 0 && worsenedRivalry !== 1) { - r.push(`${slave.slaveName} and ${SlaveFullName(rival)} <span class="rival dec">patch up their family relationship.</span>`); - decRivalry = 1; - 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>`); + 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>`); + 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="rival inc">refuses to accept ${SlaveFullName(rival)}'s control of ${his} former body,</span> worsening their rivalry.`); - incRivalry = 1; + r.push(`${slave.slaveName} <span class="rivalry inc">refuses to accept ${SlaveFullName(rival)}'s control of ${his} former body,</span> worsening their rivalry.`); + 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="rival inc">bickers with ${SlaveFullName(rival)}</span> whenever ${he} can, worsening their rivalry.`); - incRivalry = 1; + r.push(`${slave.slaveName} <span class="rivalry inc">bickers with ${SlaveFullName(rival)}</span> whenever ${he} can, worsening their rivalry.`); + increase(slave, rival); } - } else if (roll < (slave.devotion - slave.trust - 10) && slave.rivalry > 0 && worsenedRivalry !== 1) { - r.push(`${slave.slaveName} does ${his} best to be nice to ${SlaveFullName(rival)}, and manages to <span class="rival dec">de-escalate their little feud.</span>`); - decRivalry = 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>`); + 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;