From a7d280cc0e9715060389e726804cdb93b9cadda6 Mon Sep 17 00:00:00 2001
From: Trashman1138 <11461-Trashman1138@users.noreply.gitgud.io>
Date: Sun, 6 Dec 2020 22:34:10 -0800
Subject: [PATCH] Allow minority ownership

---
 src/endWeek/economics/neighborsDevelopment.js | 265 ++++++++++++++----
 1 file changed, 215 insertions(+), 50 deletions(-)

diff --git a/src/endWeek/economics/neighborsDevelopment.js b/src/endWeek/economics/neighborsDevelopment.js
index a2d4c2a33ee..1f65d8c4744 100644
--- a/src/endWeek/economics/neighborsDevelopment.js
+++ b/src/endWeek/economics/neighborsDevelopment.js
@@ -236,9 +236,7 @@ App.EndWeek.neighborsDevelopment = function() {
 			arc.ownership = 0;
 		}
 		let owned = arc.minority + arc.ownership + arc.PCminority;
-		if (arc.minority < 10) {
-			arc.minority = 0;
-		} else if (arc.minority < arc.PCminority) {
+		if (arc.minority < arc.PCminority) {
 			arc.minority = 0;
 		} else if (owned >= 95) {
 			arc.minority -= random(3, 5);
@@ -261,7 +259,7 @@ App.EndWeek.neighborsDevelopment = function() {
 		if (arc.direction !== 0) {
 			/* AI ARCOLOGY SHARE BUYING AND SELLING */
 			const economicUncertainty = App.Utils.economicUncertainty(i);
-			if (arc.government !== "your agent") {
+			if (arc.government !== "your agent-") {
 				if (arc.government !== "your trustees") {
 					if (arc.minority + arc.ownership + arc.PCminority < 100) {
 						const prosperityDiff = arc.prosperity - averageProsperity;
@@ -1407,7 +1405,7 @@ App.EndWeek.neighborsDevelopment = function() {
 
 		if (arc.direction !== 0) {
 			if (societiesAdopted < V.FSCreditCount) {
-				if ((arc.rival === 1) || (societiesAdopted < (arc.prosperity / 25) + (V.week / 25) - 3)) {
+				if (((arc.rival === 1) && (societiesAdopted < FutureSocieties.activeCount(V.arcologies[0]))) || (societiesAdopted < (arc.prosperity / 25) + (V.week / 25) - 3)) {
 					r.push(neighborsFSadoption(i));
 				}
 			}
@@ -1630,149 +1628,316 @@ App.EndWeek.neighborsDevelopment = function() {
 		return el;
 
 		function fsAdoption() {
-			/** Adopt an FS without checking validity, forcibly abandoning any opposing FSes
-			 * For use only on the first rival FS; subsequent FSes should check validity normally
-			 * @param {FC.FutureSociety} adoptFS */
-			function adoptRivalFS(adoptFS) {
-				// clear any opposing FSes
-				const group = App.Data.FutureSociety.mutexGroups.find(g => g.includes(adoptFS));
-				if (group && group.length > 1) {
-					for (const opposing of group) {
-						arc[opposing] = "unset";
-					}
-				}
-				// and initialize the target FS at 5
-				arc[adoptFS] = 5;
-			}
+			/* PRIME RIVALRY FS ADOPTION - IGNORES VALIDITY */
 
 			if (arc.rival === 1) {
 				if (arc.government === "an individual") {
 					if (V.rivalryFSAdopted === 0) {
 						V.rivalryFSAdopted = 1;
-						const desc = "Its owner is";
+						let desc = "Its owner is";
 						switch (V.rivalryFS) {
 							case "Racial Subjugationism":
+								if (arc.FSSubjugationist !== "unset") {
+									arc.FSSubjugationist = "unset";
+								}
 								r.push(`${desc} preoccupied by belief in the superiority of the ${V.arcologies[0].FSSubjugationistRace} race, leading the arcology to <span class="yellow">adopt ${V.arcologies[0].FSSubjugationistRace} Supremacy.</span>`);
-								adoptRivalFS("FSSupremacist");
+								arc.FSSupremacist = 5;
 								arc.FSSupremacistRace = V.arcologies[0].FSSubjugationistRace;
 								return;
 							case "Racial Supremacism":
+								if (arc.FSSupremacist !== "unset") {
+									arc.FSSupremacist = "unset";
+								}
 								r.push(`${desc} preoccupied by a racial animus towards ${V.arcologies[0].FSSupremacistRace} people, leaving the arcology to <span class="yellow">adopt ${V.arcologies[0].FSSupremacistRace} Subjugation.</span>`);
-								adoptRivalFS("FSSubjugationist");
+								arc.FSSubjugationist = 5;
 								arc.FSSubjugationistRace = V.arcologies[0].FSSupremacistRace;
 								return;
 							case "Repopulation Focus":
+								if (arc.FSRepopulationFocus !== "unset") {
+									arc.FSRepopulationFocus = "unset";
+								}
 								r.push(`${desc} obsessed with building a new society based on its Societal Elite, leading the arcology to <span class="yellow">adopt Eugenics.</span>`);
-								adoptRivalFS("FSRestart");
+								arc.FSRestart = 5;
 								return;
 							case "Eugenics":
+								if (arc.FSRestart !== "unset") {
+									arc.FSRestart = "unset";
+								}
 								r.push(`${desc} obsessed with breeding a new society, leading the arcology to <span class="yellow">adopt Repopulationism.</span>`);
-								adoptRivalFS("FSRepopulationFocus");
+								arc.FSRepopulationFocus = 5;
 								return;
 							case "Gender Radicalism":
+								if (arc.FSGenderRadicalist !== "unset") {
+									arc.FSGenderRadicalist = "unset";
+								}
 								r.push(`${desc} enthusiastic about knocking slaves up, leading the arcology to <span class="yellow">adopt Gender Fundamentalism.</span>`);
-								adoptRivalFS("FSGenderFundamentalist");
+								arc.FSGenderFundamentalist = 5;
 								return;
 							case "Gender Fundamentalism":
+								if (arc.FSGenderFundamentalist !== "unset") {
+									arc.FSGenderFundamentalist = "unset";
+								}
 								r.push(`${desc} enthusiastic about fucking slaves in the butt, leading the arcology to <span class="yellow">adopt Gender Radicalism.</span>`);
-								adoptRivalFS("FSGenderRadicalist");
+								arc.FSGenderRadicalist = 5;
 								return;
 							case "Paternalism":
+								if (arc.FSPaternalist !== "unset") {
+									arc.FSPaternalist = "unset";
+								}
 								r.push(`${desc} partial to screaming and struggling, leading the arcology to <span class="yellow">adopt Degradationism.</span>`);
-								adoptRivalFS("FSDegradationist");
+								arc.FSDegradationist = 5;
 								return;
 							case "Degradationism":
+								if (arc.FSDegradationist !== "unset") {
+									arc.FSDegradationist = "unset";
+								}
 								r.push(`${desc} devoted to their slaves' advancement, leading the arcology to <span class="yellow">adopt Paternalism.</span>`);
-								adoptRivalFS("FSPaternalist");
+								arc.FSPaternalist = 5;
 								return;
 							case "Intellectual Dependency":
+								if (arc.FSIntellectualDependency !== "unset") {
+									arc.FSIntellectualDependency = "unset";
+								}
 								r.push(`${desc} obsessed with crafting the perfect slave, leading the arcology to <span class="yellow">adopt Slave Professionalism.</span>`);
-								adoptRivalFS("FSSlaveProfessionalism");
+								arc.FSSlaveProfessionalism = 5;
 								return;
 							case "Slave Professionalism":
+								if (arc.FSSlaveProfessionalism !== "unset") {
+									arc.FSSlaveProfessionalism = "unset";
+								}
 								r.push(`${desc} worried that they may one day be outsmarted by their chattel, leading the arcology to <span class="yellow">adopt Intellectual Dependency.</span>`);
-								adoptRivalFS("FSIntellectualDependency");
+								arc.FSIntellectualDependency = 5;
 								return;
 							case "Body Purism":
+								if (arc.FSBodyPurist !== "unset") {
+									arc.FSBodyPurist = "unset";
+								}
 								r.push(`${desc} fascinated with extreme surgery, leading the arcology to <span class="yellow">adopt Transformation Fetishism.</span>`);
-								adoptRivalFS("FSTransformationFetishist");
+								arc.FSTransformationFetishist = 5;
 								return;
 							case "Transformation Fetishism":
+								if (arc.FSTransformationFetishist !== "unset") {
+									arc.FSTransformationFetishist = "unset";
+								}
 								r.push(`${desc} concerned by trends in their slaves' health, leading the arcology to <span class="yellow">adopt Body Purism.</span>`);
-								adoptRivalFS("FSBodyPurist");
+								arc.FSBodyPurist = 5;
 								return;
 							case "Youth Preferentialism":
+								if (arc.FSYouthPreferentialist !== "unset") {
+									arc.FSYouthPreferentialist = "unset";
+								}
 								r.push(`${desc} devoted to time in bed with their MILF slaves, leading the arcology to <span class="yellow">adopt Maturity Preferentialism.</span>`);
-								adoptRivalFS("FSMaturityPreferentialist");
+								arc.FSMaturityPreferentialist = 5;
 								return;
 							case "Maturity Preferentialism":
+								if (arc.FSMaturityPreferentialist !== "unset") {
+									arc.FSMaturityPreferentialist = "unset";
+								}
 								r.push(`${desc} devoted to fucking nubile young slaves, leading the arcology to <span class="yellow">adopt Youth Preferentialism.</span>`);
-								adoptRivalFS("FSYouthPreferentialist");
+								arc.FSYouthPreferentialist = 5;
 								return;
 							case "Petite Admiration":
+								if (arc.FSPetiteAdmiration !== "unset") {
+									arc.FSPetiteAdmiration = "unset";
+								}
 								r.push(`${desc} convinced that tall equals beauty, leading the arcology to <span class="yellow">adopt Statuesque Glorification.</span>`);
-								adoptRivalFS("FSSlaveProfessionalism");
+								arc.FSSlaveProfessionalism = 5;
 								return;
 							case "Statuesque Glorification":
+								if (arc.FSStatuesqueGlorification !== "unset") {
+									arc.FSStatuesqueGlorification = "unset";
+								}
 								r.push(`${desc} enamored by those shorter than them, leading the arcology to <span class="yellow">adopt Petite Admiration.</span>`);
-								adoptRivalFS("FSPetiteAdmiration");
+								arc.FSPetiteAdmiration = 5;
 								return;
 							case "Slimness Enthusiasm":
+								if (arc.FSSlimnessEnthusiast !== "unset") {
+									arc.FSSlimnessEnthusiast = "unset";
+								}
 								r.push(`${desc} loves boobs, the bigger, the better, leading the arcology to <span class="yellow">adopt Asset Expansionism.</span>`);
-								adoptRivalFS("FSAssetExpansionist");
+								arc.FSAssetExpansionist = 5;
 								return;
 							case "Asset Expansionism":
+								if (arc.FSAssetExpansionist !== "unset") {
+									arc.FSAssetExpansionist = "unset";
+								}
 								r.push(`${desc} loves a slim slave with tight holes, leading the arcology to <span class="yellow">adopt Slimness Enthusiasm.</span>`);
-								adoptRivalFS("FSSlimnessEnthusiast");
+								arc.FSSlimnessEnthusiast = 5;
 								return;
 							case "Pastoralism":
+								if (arc.FSPastoralist !== "unset") {
+									arc.FSPastoralist = "unset";
+								}
 								r.push(`${desc} loves cum, leading the arcology to <span class="yellow">adopt Cummunism.</span>`);
-								adoptRivalFS("FSCummunism");
+								arc.FSCummunism = 5;
 								return;
 							case "Cummunism":
+								if (arc.FSCummunism !== "unset") {
+									arc.FSCummunism = "unset";
+								}
 								r.push(`${desc} addicted to breast milk straight from the nipple, leading the arcology to <span class="yellow">adopt Pastoralism.</span>`);
-								adoptRivalFS("FSPastoralist");
+								arc.FSPastoralist = 5;
 								return;
 							case "Hedonistic Decadence":
+								if (arc.FSHedonisticDecadence !== "unset") {
+									arc.FSHedonisticDecadence = "unset";
+								}
 								r.push(`${desc} devoted to spending time in the gym, leading the arcology to <span class="yellow">adopt Physical Idealism.</span>`);
-								adoptRivalFS("FSPhysicalIdealist");
+								arc.FSPhysicalIdealist = 5;
 								return;
 							case "Physical Idealism":
+								if (arc.FSPhysicalIdealist !== "unset") {
+									arc.FSPhysicalIdealist = "unset";
+								}
 								r.push(`${desc} addicted to pleasure, leading the arcology to <span class="yellow">adopt Decadent Hedonism.</span>`);
-								adoptRivalFS("FSHedonisticDecadence");
+								arc.FSHedonisticDecadence = 5;
 								return;
 							case "Chattel Religionism":
+								if (arc.FSChattelReligionist !== "unset") {
+									arc.FSChattelReligionist = "unset";
+								}
 								r.push(`${desc} open minded, leading the arcology to <span class="yellow">permit cultural freedom.</span>`);
-								adoptRivalFS("FSNull");
+								arc.FSNull = 5;
 								return;
 							case "Multiculturalism":
+								if (arc.FSNull !== "unset") {
+									arc.FSNull = "unset";
+								}
 								r.push(`${desc} devoutly religious, and interested in a reformation, leading the arcology to <span class="yellow">adopt Chattel Religionism.</span>`);
-								adoptRivalFS("FSChattelReligionist");
+								arc.FSChattelReligionist = 5;
 								return;
 							case "Roman Revivalism":
+								if (arc.FSRomanRevivalist !== "unset") {
+									arc.FSRomanRevivalist = "unset";
+								}
+								if (arc.FSEgyptianRevivalist !== "unset") {
+									arc.FSEgyptianRevivalist = "unset";
+								}
+								if (arc.FSEdoRevivalist !== "unset") {
+									arc.FSEdoRevivalist = "unset";
+								}
+								if (arc.FSArabianRevivalist !== "unset") {
+									arc.FSArabianRevivalist = "unset";
+								}
+								if (arc.FSChineseRevivalist !== "unset") {
+									arc.FSChineseRevivalist = "unset";
+								}
+								if (arc.FSNeoImperialist !== "unset") {
+									arc.FSNeoImperialist = "unset";
+								}
 								r.push(`${desc} fascinated by ancient Aztec history, leading the arcology to <span class="yellow">adopt Aztec Revivalism.</span>`);
-								adoptRivalFS("FSAztecRevivalist");
+								arc.FSAztecRevivalist = 5;
 								return;
 							case "Neo-Imperialism":
 							case "Egyptian Revivalism":
+								if (arc.FSEgyptianRevivalist !== "unset") {
+									arc.FSEgyptianRevivalist = "unset";
+								}
+								if (arc.FSRomanRevivalist !== "unset") {
+									arc.FSRomanRevivalist = "unset";
+								}
+								if (arc.FSEdoRevivalist !== "unset") {
+									arc.FSEdoRevivalist = "unset";
+								}
+								if (arc.FSChineseRevivalist !== "unset") {
+									arc.FSChineseRevivalist = "unset";
+								}
+								if (arc.FSAztecRevivalist !== "unset") {
+									arc.FSAztecRevivalist = "unset";
+								}
+								if (arc.FSNeoImperialist !== "unset") {
+									arc.FSNeoImperialist = "unset";
+								}
 								r.push(`${desc} fascinated by Arabian romanticism, leading the arcology to <span class="yellow">adopt Arabian Revivalism.</span>`);
-								adoptRivalFS("FSArabianRevivalist");
+								arc.FSArabianRevivalist = 5;
 								return;
 							case "Edo Revivalism":
+								if (arc.FSEdoRevivalist !== "unset") {
+									arc.FSEdoRevivalist = "unset";
+								}
+								if (arc.FSRomanRevivalist !== "unset") {
+									arc.FSRomanRevivalist = "unset";
+								}
+								if (arc.FSEgyptianRevivalist !== "unset") {
+									arc.FSEgyptianRevivalist = "unset";
+								}
+								if (arc.FSArabianRevivalist !== "unset") {
+									arc.FSArabianRevivalist = "unset";
+								}
+								if (arc.FSAztecRevivalist !== "unset") {
+									arc.FSAztecRevivalist = "unset";
+								}
+								if (arc.FSNeoImperialist !== "unset") {
+									arc.FSNeoImperialist = "unset";
+								}
 								r.push(`${desc} fascinated by the long tale of Chinese history, leading the arcology to <span class="yellow">adopt Chinese Revivalism.</span>`);
-								adoptRivalFS("FSChineseRevivalist");
+								arc.FSChineseRevivalist = 5;
 								return;
 							case "Arabian Revivalism":
+								if (arc.FSArabianRevivalist !== "unset") {
+									arc.FSArabianRevivalist = "unset";
+								}
+								if (arc.FSRomanRevivalist !== "unset") {
+									arc.FSRomanRevivalist = "unset";
+								}
+								if (arc.FSEdoRevivalist !== "unset") {
+									arc.FSEdoRevivalist = "unset";
+								}
+								if (arc.FSChineseRevivalist !== "unset") {
+									arc.FSChineseRevivalist = "unset";
+								}
+								if (arc.FSAztecRevivalist !== "unset") {
+									arc.FSAztecRevivalist = "unset";
+								}
+								if (arc.FSNeoImperialist !== "unset") {
+									arc.FSNeoImperialist = "unset";
+								}
 								r.push(`${desc} fascinated by ancient Egyptian history, leading the arcology to <span class="yellow">adopt Egyptian Revivalism.</span>`);
-								adoptRivalFS("FSEgyptianRevivalist");
+								arc.FSEgyptianRevivalist = 5;
 								return;
 							case "Chinese Revivalism":
+								if (arc.FSChineseRevivalist !== "unset") {
+									arc.FSChineseRevivalist = "unset";
+								}
+								if (arc.FSRomanRevivalist !== "unset") {
+									arc.FSRomanRevivalist = "unset";
+								}
+								if (arc.FSEgyptianRevivalist !== "unset") {
+									arc.FSEgyptianRevivalist = "unset";
+								}
+								if (arc.FSArabianRevivalist !== "unset") {
+									arc.FSArabianRevivalist = "unset";
+								}
+								if (arc.FSAztecRevivalist !== "unset") {
+									arc.FSAztecRevivalist = "unset";
+								}
+								if (arc.FSNeoImperialist !== "unset") {
+									arc.FSNeoImperialist = "unset";
+								}
 								r.push(`${desc} fascinated by Japanese history, leading the arcology to <span class="yellow">adopt Edo Revivalism.</span>`);
-								adoptRivalFS("FSEdoRevivalist");
+								arc.FSEdoRevivalist = 5;
 								return;
 							case "Aztec Revivalism":
+								if (arc.FSAztecRevivalist !== "unset") {
+									arc.FSAztecRevivalist = "unset";
+								}
+								if (arc.FSEgyptianRevivalist !== "unset") {
+									arc.FSEgyptianRevivalist = "unset";
+								}
+								if (arc.FSEdoRevivalist !== "unset") {
+									arc.FSEdoRevivalist = "unset";
+								}
+								if (arc.FSArabianRevivalist !== "unset") {
+									arc.FSArabianRevivalist = "unset";
+								}
+								if (arc.FSChineseRevivalist !== "unset") {
+									arc.FSChineseRevivalist = "unset";
+								}
+								if (arc.FSNeoImperialist !== "unset") {
+									arc.FSNeoImperialist = "unset";
+								}
 								r.push(`${desc} fascinated by classical Roman history, leading the arcology to <span class="yellow">adopt Roman Revivalism.</span>`);
-								adoptRivalFS("FSRomanRevivalist");
+								arc.FSRomanRevivalist = 5;
 								return;
 							default:
 								V.rivalryFSAdopted = 0;
-- 
GitLab