Skip to content
Snippets Groups Projects
Commit d6c2542d authored by svornost's avatar svornost
Browse files

Try to straighten out existing rivalry upgrade/downgrade logic.

parent 4a9d4025
No related branches found
No related tags found
1 merge request!7419Fixes/cleanup for saRivalries
...@@ -6,7 +6,7 @@ App.SlaveAssignment.rivalries = (function() { ...@@ -6,7 +6,7 @@ App.SlaveAssignment.rivalries = (function() {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
let he, him, his, hers, himself, girl, loli, He, His; let he, him, his, hers, himself, girl, loli, He, His;
let rival; let changed;
return saRivalries; return saRivalries;
...@@ -182,30 +182,60 @@ App.SlaveAssignment.rivalries = (function() { ...@@ -182,30 +182,60 @@ App.SlaveAssignment.rivalries = (function() {
/** /**
* @param {App.Entity.SlaveState} slave * @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) { function existingRivalry(slave) {
rival = getSlave(slave.rivalryTarget); const rival = getSlave(slave.rivalryTarget);
let incRivalry = 0;
let decRivalry = 0;
let reconciled = 0;
let worsenedRivalry = 0;
let lightenedRivalry = 0;
let lustyFix = 0;
let roll = jsRandom(0, 100); let roll = jsRandom(0, 100);
changed = false;
if (rival === undefined) { if (rival === undefined) {
r.push(`<span class="red">Error, rivalryTarget not found.</span>`); r.push(`<span class="red">Error, rivalryTarget not found.</span>`);
} else { } else {
if (slave.fuckdoll) { 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)}.`); 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") { } 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)}.`); 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) { } 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.`); 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 { } else {
if (slave.need) { if (slave.need) {
if (V.universalRulesConsent === 0) { if (V.universalRulesConsent === 0) {
...@@ -218,8 +248,7 @@ App.SlaveAssignment.rivalries = (function() { ...@@ -218,8 +248,7 @@ App.SlaveAssignment.rivalries = (function() {
rival.trust -= 3; rival.trust -= 3;
if (slave.rivalry < 3) { if (slave.rivalry < 3) {
r.push(`Of course, this <span class="rivalry inc">worsens their rivalry.</span>`); r.push(`Of course, this <span class="rivalry inc">worsens their rivalry.</span>`);
incRivalry = 1; increase(slave, rival);
worsenedRivalry = 1;
} }
SimpleSexAct.Slaves(rival, slave, 5); SimpleSexAct.Slaves(rival, slave, 5);
} else if (slave.fetish === "dom") { } else if (slave.fetish === "dom") {
...@@ -229,8 +258,7 @@ App.SlaveAssignment.rivalries = (function() { ...@@ -229,8 +258,7 @@ App.SlaveAssignment.rivalries = (function() {
rival.devotion -= 3; rival.devotion -= 3;
if (slave.rivalry < 3) { if (slave.rivalry < 3) {
r.push(`Of course, this <span class="rivalry inc">worsens their rivalry.</span>`); r.push(`Of course, this <span class="rivalry inc">worsens their rivalry.</span>`);
incRivalry = 1; increase(slave, rival);
worsenedRivalry = 1;
} }
SimpleSexAct.Slaves(rival, slave, 5); SimpleSexAct.Slaves(rival, slave, 5);
} }
...@@ -238,123 +266,84 @@ App.SlaveAssignment.rivalries = (function() { ...@@ -238,123 +266,84 @@ App.SlaveAssignment.rivalries = (function() {
} }
} }
} }
if (worsenedRivalry !== 1) { if (!changed && roll > 50) {
if (roll > 50) { if (rival.fetish === slave.fetish) {
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.`);
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);
decRivalry = 1; }
lightenedRivalry = 1; 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 (!changed && rival.devotion > 50) {
if (rival.trust < -20) { if (slave.devotion > 50) {
if (slave.trust < -20) { 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.`);
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);
decRivalry = 1;
lightenedRivalry = 1;
}
} }
if (rival.devotion > 50) { }
if (slave.devotion > 50) { if (roll > 90 && slave.rivalry > 0) {
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.`); if (!changed && slave.energy > 95) {
decRivalry = 1; r.push(`${slave.slaveName} lusts after ${SlaveFullName(rival)}, and does everything ${he} can to <span class="rivalry dec">patch up their differences.</span>`);
lightenedRivalry = 1; reduce(slave, rival);
}
} }
if (roll > 90 && slave.rivalry > 0) { if (!changed && slave.attrXX > 85) {
if (slave.energy > 95) { 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>`); 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; reduce(slave, rival);
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;
}
}
} }
if (lustyFix !== 1) { }
if (slave.attrXY > 85) { if (!changed && slave.attrXY > 85) {
if (canAchieveErection(rival) || rival.faceShape === "masculine") { 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>`); 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; reduce(slave, rival);
lightenedRivalry = 1;
lustyFix = 1;
}
}
} }
if (lustyFix !== 1) { }
if (rival.assignment !== slave.assignment) { if (!changed && rival.assignment !== slave.assignment) {
if (slave.subTarget !== rival.ID && rival.subTarget !== slave.ID) { 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>`); r.push(`With time apart ${slave.slaveName} and ${SlaveFullName(rival)} <span class="rivalry dec">dislike each other less.</span>`);
decRivalry = 1; reduce(slave, rival);
lightenedRivalry = 1;
}
}
} }
} }
} }
} }
} }
if (areRelated(slave, rival)) { if (!changed && areRelated(slave, rival)) {
if (roll > 70 && slave.rivalry < 3 && lightenedRivalry !== 1) { if (roll > 70 && slave.rivalry < 3) {
r.push(`${slave.slaveName} and ${SlaveFullName(rival)} <span class="rivalry inc">pursue their family rivalry.</span>`); r.push(`${slave.slaveName} and ${SlaveFullName(rival)} <span class="rivalry inc">pursue their family rivalry.</span>`);
incRivalry = 1; increase(slave, rival);
worsenedRivalry = 1; } else if (roll > 40 && slave.rivalry > 0) {
} else if (roll > 40 && slave.rivalry > 0 && worsenedRivalry !== 1) {
r.push(`${slave.slaveName} and ${SlaveFullName(rival)} <span class="rivalry dec">patch up their family relationship.</span>`); r.push(`${slave.slaveName} and ${SlaveFullName(rival)} <span class="rivalry dec">patch up their family relationship.</span>`);
decRivalry = 1; reduce(slave, rival);
lightenedRivalry = 1;
} }
} }
if (rival.origBodyOwnerID === slave.ID && lightenedRivalry !== 1) { if (!changed && rival.origBodyOwnerID === slave.ID) {
if (slave.rivalry < 3) { 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.`); 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) { if (slave.rivalry < 3) {
r.push(`${slave.slaveName} <span class="rivalry inc">bickers with ${SlaveFullName(rival)}</span> whenever ${he} can, worsening their rivalry.`); 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>`); 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 * @param {App.Entity.SlaveState} slave
* *
*/ */
function rivalryValidation(slave) { function rivalryValidation(slave) {
// This will be obsoleted with multiple rivals system // This will be obsoleted with multiple rivals system
rival = getSlave(slave.rivalryTarget); const rival = getSlave(slave.rivalryTarget);
if (rival !== undefined && slave.ID !== rival.rivalryTarget) { if (rival !== undefined && slave.ID !== rival.rivalryTarget) {
rival.rivalry = 0; rival.rivalry = 0;
rival.rivalryTarget = 0; rival.rivalryTarget = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment