Skip to content
Snippets Groups Projects
utilsArcology.js 3.36 KiB
Newer Older
  • Learn to ignore specific revisions
  • lowercasedonkey's avatar
    lowercasedonkey committed
    /** Returns the revivalist nationality associated with the player's arcology, or 0 if none
     * @returns {string|0}
     */
    globalThis.getRevivalistNationality = function() {
    	if (V.arcologies[0].FSRomanRevivalist > 90) {
    		return "Roman Revivalist";
    	} else if (V.arcologies[0].FSAztecRevivalist > 90) {
    		return "Aztec Revivalist";
    	} else if (V.arcologies[0].FSEgyptianRevivalist > 90) {
    		return "Ancient Egyptian Revivalist";
    	} else if (V.arcologies[0].FSEdoRevivalist > 90) {
    		return "Edo Revivalist";
    	} else if (V.arcologies[0].FSArabianRevivalist > 90) {
    		return "Arabian Revivalist";
    	} else if (V.arcologies[0].FSChineseRevivalist > 90) {
    		return "Ancient Chinese Revivalist";
    	}
    	return 0;
    };
    
    /** Calculate and return economic uncertainty multiplier for a given arcology
     * @param {number} arcologyID
     * @returns {number}
     */
    App.Utils.economicUncertainty = function(arcologyID) {
    	let uncertainty = arcologyID === 0 ? 5 : 10;
    	if (assistant.power === 1) {
    
    		uncertainty -= Math.max(Math.trunc(uncertainty / 2), 0);
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    	} else if (assistant.power > 1) {
    		uncertainty = 0;
    	}
    	return jsRandom(100 - uncertainty, 100 + uncertainty) / 100;
    };
    
    /**
     * @returns {number}
     */
    App.Utils.schoolCounter = function() {
    	return Array.from(App.Data.misc.schools.keys()).filter(s => V[s].schoolPresent).length;
    };
    
    /**
     * @returns {string}
     */
    App.Utils.schoolFailure = function() {
    	return Array.from(App.Data.misc.schools.keys()).find(s => V[s].schoolPresent && V[s].schoolProsperity <= -10);
    };
    
    lowercasedonkey's avatar
    lowercasedonkey committed
    /**
     * @typedef {Object} menialObject
     * @property {string} text
     * @property {number} value
     */
    
    /**
     * @returns {menialObject}
     */
    
    globalThis.menialPopCap = function() {
    	let r = "";
    
    	let popCap = 500 * (1 + V.building.findCells(cell => cell instanceof App.Arcology.Cell.Manufacturing && cell.type === "Pens").length);
    
    	let overMenialCap = V.menials + V.fuckdolls + V.menialBioreactors - popCap;
    	if (overMenialCap > 0) {
    		const price = menialSlaveCost(-overMenialCap);
    		if (V.menials > 0) {
    			if (V.menials > overMenialCap) {
    				cashX((overMenialCap * price), "menialTrades");
    				V.menialDemandFactor -= overMenialCap;
    				V.menials -= overMenialCap;
    				overMenialCap = 0;
    				r += "You don't have enough room for all your menials and are obliged to sell some.";
    			} else {
    				cashX((V.menials * price), "menialTrades");
    				V.menialDemandFactor -= V.menials;
    				overMenialCap -= V.menials;
    				V.menials = 0;
    				r += "You don't have enough room for your menials and are obliged to sell them.";
    			}
    		}
    		if (overMenialCap > 0 && V.fuckdolls > 0) {
    			if (V.fuckdolls > overMenialCap) {
    				cashX(overMenialCap * (price * 2), "menialTrades");
    				V.menialDemandFactor -= overMenialCap;
    				V.fuckdolls -= overMenialCap;
    				overMenialCap = 0;
    				r += "You don't have enough room for all your Fuckdolls and are obliged to sell some.";
    			} else {
    				cashX(V.fuckdolls * (price * 2), "menialTrades");
    				V.menialDemandFactor -= V.fuckdolls;
    				overMenialCap -= V.fuckdolls;
    				V.fuckdolls = 0;
    				r += "You don't have enough room for your Fuckdolls and are obliged to sell them.";
    			}
    		}
    		if (overMenialCap > 0 && V.menialBioreactors > 0) {
    			cashX(overMenialCap * (price - 100), "menialTrades");
    			V.menialDemandFactor -= overMenialCap;
    			V.menialBioreactors -= overMenialCap;
    			r += "You don't have enough room for all your menial bioreactors and are obliged to sell some.";
    		}
    	}
    	return {text: r, value: popCap};
    };