Skip to content
Snippets Groups Projects
fsDecoration.js 7.47 KiB
Newer Older
  • Learn to ignore specific revisions
  • /** Replaces <<SetFacilityDecoration>> widget
    
     * @returns {DocumentFragment}
    
    App.UI.facilityRedecoration = function() {
    	const el = new DocumentFragment();
    	const activeFacilities = new Map([]);
    	const options = new App.UI.OptionsGroup();
    
    	const arc = V.arcologies[0];
    
    
    	FutureSocieties.DecorationCleanup();
    
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    	const applicableFS = FutureSocieties.activeFSes(arc).filter(name => (arc[name] > 20));
    	const decorationNames =  Array.from(applicableFS, FS => FutureSocieties.decorationName(FS));
    
    	if (V.brothel > 0) {
    		activeFacilities.set(V.brothelName, "brothelDecoration");
    	}
    
    	if (V.club > 0) {
    		activeFacilities.set(V.clubName, "clubDecoration");
    	}
    
    	if (V.dairy > 0) {
    		activeFacilities.set(V.dairyName, "dairyDecoration");
    	}
    
    	if (V.farmyard > 0) {
    		activeFacilities.set(V.farmyardName, "farmyardDecoration");
    	}
    
    	if (V.spa > 0) {
    		activeFacilities.set(V.spaName, "spaDecoration");
    	}
    
    	if (V.nursery > 0) {
    		activeFacilities.set(V.nurseryName, "nurseryDecoration");
    	}
    
    	if (V.clinic > 0) {
    		activeFacilities.set(V.clinicName, "clinicDecoration");
    
    
    	if (V.schoolroom > 0) {
    		activeFacilities.set(V.schoolroomName, "schoolroomDecoration");
    	}
    
    	if (V.cellblock > 0) {
    		activeFacilities.set(V.cellblockName, "cellblockDecoration");
    	}
    
    	if (V.servantsQuarters > 0) {
    		activeFacilities.set(V.servantsQuartersName, "servantsQuartersDecoration");
    	}
    
    	if (V.arcade > 0) {
    		activeFacilities.set(V.arcadeName, "arcadeDecoration");
    	}
    
    	if (V.masterSuite > 0) {
    		activeFacilities.set(V.masterSuiteName, "masterSuiteDecoration");
    
    	options.addOption(`Change style for all facilities`)
    		.addCustomDOM(modifyAll());
    
    	for (const [name, decoration] of activeFacilities) {
    
    		options.addOption(`The decoration style of ${name} is`)
    			.addCustomDOM(createPulldown(decoration));
    
    	function createPulldown(variable) {
    
    		const select = document.createElement("select");
    		select.classList.add("rajs-list");
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    
    		// Standard decorations
    		const choice = App.UI.DOM.appendNewElement("option", select, "Standard");
    		choice.value = "standard";
    		if (V[variable] === "standard") {
    			choice.selected = true;
    		}
    
    		// FS decorations
    
    		for (const decorationName of decorationNames) {
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    			const choice = App.UI.DOM.makeElement("option", decorationName);
    
    			if (V[variable] === decorationName) {
    				choice.selected = true;
    
    			select.append(choice);
    
    
    		select.onchange = () => {
    			const O = select.options[select.selectedIndex];
    
    			if (O.value !== "standard") {
    
    			V[variable] = O.value;
    
    		const select = document.createElement("select");
    		select.classList.add("rajs-list");
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    
    		// Standard decorations
    		const standard = App.UI.DOM.appendNewElement("option", select, "Standard");
    		standard.value = "standard";
    
    		// FS decorations
    
    		for (const decorationName of decorationNames) {
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    			App.UI.DOM.appendNewElement("option", select, decorationName);
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    		// Round Robin
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    		App.UI.DOM.appendNewElement("option", select, "Distribute Evenly");
    
    		select.onchange = () => {
    			const O = select.options[select.selectedIndex];
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    			if (O.value === "Distribute Evenly") { // Cycles through the list of available FS decorations, and distributes them to facilities round robin style.
    
    				let i = 0;
    				for (const decoration of activeFacilities.values()) {
    
    					cashX(-5000, "capEx");
    					V[decoration] = decorationNames[i];
    					i++;
    					if (i >= decorationNames.length) {
    						i = 0;
    
    					}
    				}
    			} else {
    				for (const decoration of activeFacilities.values()) {
    
    					if (O.value !== "standard") {
    
    						cashX(-5000, "capEx");
    					}
    
    					V[decoration] = O.value;
    
    				}
    			}
    			App.UI.reload();
    		};
    		select.selectedIndex = -1;
    
    
    /**
     *
     * @param {FC.FutureSociety} FS
     * @param {Array} items
     * @returns {HTMLElement}
     */
    App.UI.FSChangeDecoration = function(FS, items) {
    	const el = document.createElement("div");
    	el.classList.add("indent");
    	const FSDecoration = FS + "Decoration";
    	let costs;
    	switch (V.arcologies[0][FSDecoration]) {
    		case 20:
    			costs = 2500;
    			el.append(`${V.arcologies[0].name} is not customized to support this goal. `);
    			if (V.arcologies[0][FS] >= 10) {
    				el.append(
    					App.UI.DOM.link(
    						`Modify your arcology's internal media to support this goal`,
    						() => {
    							V.arcologies[0][FSDecoration] = 40;
    							cashX(forceNeg(costs), "capEx");
    						},
    						[],
    						"Future Society",
    						`Costs ${cashFormat(costs)}`
    					),
    				);
    			} else {
    				el.append(`You must advance this goal before customization to support it becomes available. `);
    			}
    			break;
    		case 40:
    			el.append(`${V.arcologies[0].name}'s media is supporting this goal. `);
    			if (V.arcologies[0][FS] >= 30) {
    				costs = 10000;
    				el.append(
    					App.UI.DOM.link(
    						`Redecorate your arcology's public spaces to support this goal`,
    						() => {
    							V.arcologies[0][FSDecoration] = 60;
    							cashX(forceNeg(costs), "capEx");
    						},
    						[],
    						"Future Society",
    						`Costs ${cashFormat(costs)}`
    					),
    				);
    			} else {
    				el.append(`You must advance this goal before further customization to support it becomes available. `);
    			}
    			break;
    		case 60:
    			el.append(`${V.arcologies[0].name}'s media is supporting this goal, and ${V.arcologies[0].name}'s public spaces are decorated to support it too. `);
    			if (V.arcologies[0][FS] >= 50) {
    				costs = 10000;
    				el.append(
    					App.UI.DOM.link(
    						`Station slaves in your arcology's public spaces to promote this goal`,
    						() => {
    							V.arcologies[0][FSDecoration] = 80;
    							cashX(forceNeg(costs), "capEx");
    						},
    						[],
    						"Future Society",
    						`Costs ${cashFormat(costs)}`
    					),
    				);
    			} else {
    				el.append(`You must advance this goal before further customization to support it becomes available. `);
    			}
    			break;
    		case 80:
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    			el.append(`${V.arcologies[0].name}'s media is supporting this goal; ${V.arcologies[0].name}'s public spaces are decorated to support it, and have slaves stationed in them to support it too. `);
    
    			if (V.arcologies[0][FS] >= 70) {
    				if (FS === "FSRestart") {
    					costs = 75000;
    					el.append(
    						App.UI.DOM.link(
    							`Customize the exterior of the arcology to support this goal and fully establish the Societal Elite`,
    							() => {
    								V.arcologies[0].FSRestartDecoration = 100;
    								V.upgradeMultiplierArcology = upgradeMultiplier('engineering');
    								V.upgradeMultiplierMedicine = upgradeMultiplier('medicine');
    								for (const item of items) {
    									_.set(V, item, 1);
    								}
    							},
    							[],
    							"Future Society",
    							`Costs ${cashFormat(costs)}`
    						),
    					);
    				} else {
    					costs = 10000;
    					el.append(
    						App.UI.DOM.link(
    							`Station slaves in your arcology's public spaces to promote this goal`,
    							() => {
    								V.arcologies[0][FSDecoration] = 100;
    								cashX(forceNeg(costs), "capEx");
    								for (const item of items) {
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    									_.set(V, item, 1);
    
    								}
    							},
    							[],
    							"Future Society",
    							`Costs ${cashFormat(costs)}`
    						),
    					);
    				}
    			} else {
    				el.append(`You must advance this goal before further customization to support it becomes available. `);
    			}
    			break;
    		case 100:
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    			el.append(`${V.arcologies[0].name}'s media is supporting this goal; ${V.arcologies[0].name}'s public spaces are decorated to support it, and have slaves stationed in them to support it. The exterior of the arcology has been remodeled to support it as well; the arcology is fully customized for this goal. `);