diff --git a/src/futureSocieties/fsDecoration.js b/src/futureSocieties/fsDecoration.js index a8521b78cbfef789adc354b16fcf7a540eea12f1..7861241d48ae57bb351a16903a3729b531e4cb72 100644 --- a/src/futureSocieties/fsDecoration.js +++ b/src/futureSocieties/fsDecoration.js @@ -65,33 +65,40 @@ App.UI.facilityRedecoration = function() { // dummy variable to make sure the first option is selected by default const currentSelected = {value: "none"}; - options.addOption(`The decoration style of ${name} is`, "value", currentSelected) + let option = options.addOption(`Set decoration value for all facilities to`, "value", currentSelected) .addValue("(Select option)", "none") - .addValue("Standard", "standard") - .addValueList(decorationNames) - .addValue("Distribute Evenly", "even") - .addCallbackToEach(value => { - console.log(value); - if (value === "even") { // 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"); + .addValue("Standard", "standard"); + if (decorationNames.length > 0) { + option.addValueList(decorationNames) + .addValue("Distribute Evenly", "even"); + } + option.addCallbackToEach(value => { + console.log(value); + let totalCost = 0; + if (value === "even") { // 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()) { + if (V[decoration] !== decorationNames[i]) { + totalCost += 5000; V[decoration] = decorationNames[i]; - i++; - if (i >= decorationNames.length) { - i = 0; - } } - } else { - for (const decoration of activeFacilities.values()) { - if (value !== "standard") { - cashX(-5000, "capEx"); - } - V[decoration] = value; + i++; + if (i >= decorationNames.length) { + i = 0; + } + } + } else if (value !== "none") { + for (const decoration of activeFacilities.values()) { + if (value !== "standard") { + totalCost += 5000; } + V[decoration] = value; } - }) - .pulldown(); + } + if (totalCost > 0) { + cashX(forceNeg(totalCost), "capEx"); + } + }).pulldown(); for (const [name, decoration] of activeFacilities) { options.addOption(`The decoration style of ${name} is`, decoration)