Skip to content
Snippets Groups Projects
Commit 40050f17 authored by lowercasedonkey's avatar lowercasedonkey
Browse files

simplify list generation

parent f7fc76d0
No related branches found
No related tags found
No related merge requests found
......@@ -5,9 +5,14 @@ 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();
/** @type {Array<keyof FC.FutureSocietyIdMap>} */
const validDecorations = FutureSocieties.activeFSes(arc).filter(name => (arc[name] > 20));
const decorationNames = Array.from(validDecorations, name => FutureSocieties.decorationName(name));
if (V.brothel > 0) {
activeFacilities.set(V.brothelName, "brothelDecoration");
}
......@@ -70,18 +75,12 @@ App.UI.facilityRedecoration = function() {
function createPulldown(option, variable) {
const select = document.createElement("select");
select.classList.add("rajs-list");
const arc = V.arcologies[0];
for (const FS of FutureSocieties.activeFSes(arc)) {
if (arc[FS] > 20) {
const decorationName = FutureSocieties.decorationName(FS);
if (decorationName) {
const choice = App.UI.DOM.makeElement("option", decorationName, "indent");
if (V[variable] === decorationName) {
choice.selected = true;
}
select.append(choice);
}
for (const decorationName of decorationNames) {
const choice = App.UI.DOM.makeElement("option", decorationName, "indent");
if (V[variable] === decorationName) {
choice.selected = true;
}
select.append(choice);
}
const choice = App.UI.DOM.makeElement("option", "standard", "indent");
if (V[variable] === "standard") {
......@@ -104,25 +103,32 @@ App.UI.facilityRedecoration = function() {
function modifyAll(option) {
const select = document.createElement("select");
select.classList.add("rajs-list");
const arc = V.arcologies[0];
for (const FS of FutureSocieties.activeFSes(arc)) {
if (arc[FS] > 20) {
const decorationName = FutureSocieties.decorationName(FS);
if (decorationName) {
App.UI.DOM.appendNewElement("option", select, decorationName, "indent");
}
}
for (const decorationName of decorationNames) {
App.UI.DOM.appendNewElement("option", select, decorationName, "indent");
}
App.UI.DOM.appendNewElement("option", select, "standard", "indent");
App.UI.DOM.appendNewElement("option", select, "Distribute Evenly", "indent");
select.onchange = () => {
const O = select.options[select.selectedIndex];
for (const decoration of activeFacilities.values()) {
if (O.value !== "standard") {
cashX(-5000, "capEx");
if (O.value === "Distribute Evenly") {
let i = 0;
for (const decoration of activeFacilities.values()) {
if (O.value !== "standard") {
cashX(-5000, "capEx");
}
V[decoration] = O.value;
}
} else {
for (const decoration of activeFacilities.values()) {
if (O.value !== "standard") {
cashX(-5000, "capEx");
}
V[decoration] = O.value;
}
V[decoration] = O.value;
}
App.UI.reload();
};
select.selectedIndex = -1;
......
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