From d353ca219d6e2262764483afce65e8536447c670 Mon Sep 17 00:00:00 2001 From: Arkerthan <arkerthan@gmail.com> Date: Tue, 18 Feb 2020 14:10:52 +0100 Subject: [PATCH] create new building at storyInit --- src/arcologyBuilding/base.js | 28 ++++++++++++++-------- src/init/storyInit.tw | 45 ++++-------------------------------- src/uncategorized/main.tw | 4 ---- 3 files changed, 22 insertions(+), 55 deletions(-) diff --git a/src/arcologyBuilding/base.js b/src/arcologyBuilding/base.js index bdbe6922bf5..7f517647546 100644 --- a/src/arcologyBuilding/base.js +++ b/src/arcologyBuilding/base.js @@ -7,25 +7,33 @@ App.Arcology.getCellLink = function(path, message) { return App.UI.DOM.passageLink(message, "Cell", () => { V.cellPath = path; }); }; -App.Arcology.newBuilding = function() { +/** + * @returns {App.Arcology.Building} + */ +App.Arcology.defaultBuilding = function() { const sections = []; - sections.push(new App.Arcology.Section("s1", [[new App.Arcology.Cell.Penthouse()]])); - sections.push(new App.Arcology.Section("s2", [[new App.Arcology.Cell.Apartment(1, 2), new App.Arcology.Cell.Apartment(1, 3)]])); - sections.push(new App.Arcology.Section("s3", + sections.push(new App.Arcology.Section("penthouse", [[new App.Arcology.Cell.Penthouse()]])); + sections.push(new App.Arcology.Section("shops", [[new App.Arcology.Cell.Shop(1), new App.Arcology.Cell.Shop(1), new App.Arcology.Cell.Shop(1)]])); + sections.push(new App.Arcology.Section("apartments", [ - [new App.Arcology.Cell.Shop(1), new App.Arcology.Cell.Shop(1), new App.Arcology.Cell.Shop(1)], - [new App.Arcology.Cell.Shop(1), new App.Arcology.Cell.Shop(1), new App.Arcology.Cell.Shop(1), new App.Arcology.Cell.Shop(1), new App.Arcology.Cell.Apartment(1, 1)], - [new App.Arcology.Cell.Shop(1), new App.Arcology.Cell.Shop(1), new App.Arcology.Cell.Shop(1)] + [new App.Arcology.Cell.Apartment(1), new App.Arcology.Cell.Apartment(1), new App.Arcology.Cell.Apartment(1), new App.Arcology.Cell.Apartment(1)], + [new App.Arcology.Cell.Apartment(1), new App.Arcology.Cell.Apartment(1), new App.Arcology.Cell.Apartment(1), new App.Arcology.Cell.Apartment(1)], + [new App.Arcology.Cell.Apartment(1), new App.Arcology.Cell.Apartment(1), new App.Arcology.Cell.Apartment(1), new App.Arcology.Cell.Apartment(1)], ] )); - sections.push(new App.Arcology.Section("s4", [[new App.Arcology.Cell.Market(1), new App.Arcology.Cell.Market(1)]])); - sections.push(new App.Arcology.Section("s5", [[new App.Arcology.Cell.Manufacturing(1), new App.Arcology.Cell.Manufacturing(1)]])); + sections.push(new App.Arcology.Section("markets", [[new App.Arcology.Cell.Market(1), new App.Arcology.Cell.Market(1), new App.Arcology.Cell.Market(1), new App.Arcology.Cell.Market(1), new App.Arcology.Cell.Market(1)]])); + sections.push(new App.Arcology.Section("manufacturing", [[new App.Arcology.Cell.Manufacturing(1), new App.Arcology.Cell.Manufacturing(1), new App.Arcology.Cell.Manufacturing(1), new App.Arcology.Cell.Manufacturing(1), new App.Arcology.Cell.Manufacturing(1)]])); return new App.Arcology.Building(sections); }; -App.Arcology.sectionOrder = ["spire", "s1", "s2", "s3", "s4", "s5", "s6", "s7"]; +/** + * Order of the building sections. All possible sections have to be added here. + * + * @type {string[]} + */ +App.Arcology.sectionOrder = ["penthouse", "spire", "shops", "apartments", "markets", "manufacturing"]; App.Arcology.Section = class { /** diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw index d99d83e008d..91dbffff340 100644 --- a/src/init/storyInit.tw +++ b/src/init/storyInit.tw @@ -1116,47 +1116,10 @@ You should have received a copy of the GNU General Public License along with thi <<set $revealFoodEffects = 0>> <<set $rations = 0>> -<<set $sectors = [ - {type: "Penthouse", ownership: 1}, - {type: "Empty", ownership: 0}, - {type: "Empty", ownership: 0}, - {type: "Empty", ownership: 0}, - {type: "Empty", ownership: 0}, - {type: "Shops", ownership: 1}, - {type: "Shops", ownership: 1}, - {type: "Shops", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Apartments", ownership: 1}, - {type: "Markets", ownership: 1}, - {type: "Markets", ownership: 1}, - {type: "Markets", ownership: 1}, - {type: "Markets", ownership: 1}, - {type: "Markets", ownership: 1}, - {type: "Manufacturing", ownership: 1}, - {type: "Manufacturing", ownership: 1}, - {type: "Manufacturing", ownership: 1}, - {type: "Manufacturing", ownership: 1}, - {type: "Manufacturing", ownership: 1} -]>> - -<<for _i = 0; _i < 12; _i++>> - <<set _j = random(5,28)>> - <<if $sectors[_j].ownership == 1>> - <<set $sectors[_j].ownership = 0>> - <<else>> - <<set _i-->> - <</if>> -<</for>> +<<set $building = App.Arcology.defaultBuilding()>> +<<set _sellable = $building.findCells(cell => cell.canBeSold())>> +<<set _random12 = jsRandomMany(_sellable, 12)>> +<<run _random12.forEach(cell => {cell.owner = 0})>> <<set $menials = 0>> <<set $fuckdolls = 0>> diff --git a/src/uncategorized/main.tw b/src/uncategorized/main.tw index 78f701eab08..236a9236733 100644 --- a/src/uncategorized/main.tw +++ b/src/uncategorized/main.tw @@ -69,10 +69,6 @@ <<set _SL = $slaves.length>> <<if $newModelUI == 1>> - <<link "reset" "Main">> - <<set $building = App.Arcology.newBuilding()>> - <</link>> - <span id="building"></span> <<script>> $(document).one(':passageend', () => { -- GitLab