diff --git a/src/arcologyBuilding/base.js b/src/arcologyBuilding/base.js index 40483a5085e033bc25aa34e9a22129eeeb543eed..e4173a8efd9c7d2f3efe80d1e29b2a896da2d42b 100644 --- a/src/arcologyBuilding/base.js +++ b/src/arcologyBuilding/base.js @@ -44,7 +44,7 @@ App.Arcology.defaultBuilding = function(terrain = "default") { */ const env = {terrain: terrain, established: false, fs: ""}; const candidates = App.Arcology.presets.filter(preset => preset.isAllowed(env)); - return candidates.pluck().construct(env); + return candidates.pluck().construct(env).building; }; /** diff --git a/src/arcologyBuilding/presets.js b/src/arcologyBuilding/presets.js index d48b061d2fcac799248f0b6aef0d838ea6b42736..f17784718d0ea8ee38b7c024613d83dbf96a1a94 100644 --- a/src/arcologyBuilding/presets.js +++ b/src/arcologyBuilding/presets.js @@ -7,8 +7,7 @@ /** * @typedef {object} buildingPreset * @property {function(arcologyEnvironment):boolean} isAllowed - * @property {function(arcologyEnvironment):App.Arcology.Building} construct - * @property {function():void} apply + * @property {function(arcologyEnvironment):{building: App.Arcology.Building, apply: function()}} construct */ /** @@ -159,62 +158,162 @@ App.Arcology.presets = (function() { } } + /** + * @param {App.Arcology.Building} building + * @param {arcologyEnvironment} environment + * @returns {{building: App.Arcology.Building, apply: function()}} + */ + function randomizeBuilding(building, environment) { + const apply = []; + if (Math.random() < 0.5) { + apply.push(addFsShop(building, environment.fs)); + } + return {building: building, apply: () => { apply.forEach(a => { a(); }); }}; + } + + /** + * @param {App.Arcology.Building} building + * @param {string} fs + * @returns {function():undefined} + */ + function addFsShop(building, fs) { + function randomShop() { + return building.findCells(cell => cell instanceof App.Arcology.Cell.Shop).random(); + } + + switch (fs) { + case "Supremacist": + randomShop().type = "Supremacist"; + return () => { V.FSPromenade.Supremacist = 1; }; + case "Subjugationist": + randomShop().type = "Subjugationist"; + return () => { V.FSPromenade.Subjugationist = 1; }; + case "GenderRadicalist": + randomShop().type = "Gender Radicalist"; + return () => { V.FSPromenade.GenderRadicalist = 1; }; + case "GenderFundamentalist": + randomShop().type = "Gender Fundamentalist"; + return () => { V.FSPromenade.GenderFundamentalist = 1; }; + case "Paternalist": + randomShop().type = "Paternalist"; + return () => { V.FSPromenade.Paternalist = 1; }; + case "Degradationist": + randomShop().type = "Degradationist"; + return () => { V.FSPromenade.Degradationist = 1; }; + case "AssetExpansionist": + randomShop().type = "Asset Expansionist"; + return () => { V.FSPromenade.AssetExpansionist = 1; }; + case "SlimnessEnthusiast": + randomShop().type = "Slimness Enthusiast"; + return () => { V.FSPromenade.SlimnessEnthusiast = 1; }; + case "TransformationFetishist": + randomShop().type = "Transformation Fetishist"; + return () => { V.FSPromenade.TransformationFetishist = 1; }; + case "BodyPurist": + randomShop().type = "Body Purist"; + return () => { V.FSPromenade.BodyPurist = 1; }; + case "MaturityPreferentialist": + randomShop().type = "Maturity Preferentialist"; + return () => { V.FSPromenade.MaturityPreferentialist = 1; }; + case "YouthPreferentialist": + randomShop().type = "Youth Preferentialist"; + return () => { V.FSPromenade.YouthPreferentialist = 1; }; + case "Pastoralist": + randomShop().type = "Pastoralist"; + return () => { V.FSPromenade.Pastoralist = 1; }; + case "PhysicalIdealist": + randomShop().type = "Physical Idealist"; + return () => { V.FSPromenade.PhysicalIdealist = 1; }; + case "ChattelReligionist": + randomShop().type = "Chattel Religionist"; + return () => { V.FSPromenade.ChattelReligionist = 1; }; + case "RomanRevivalist": + randomShop().type = "Roman Revivalist"; + return () => { V.FSPromenade.RomanRevivalist = 1; }; + case "AztecRevivalist": + randomShop().type = "Aztec Revivalist"; + return () => { V.FSPromenade.AztecRevivalist = 1; }; + case "EgyptianRevivalist": + randomShop().type = "Egyptian Revivalist"; + return () => { V.FSPromenade.EgyptianRevivalist = 1; }; + case "EdoRevivalist": + randomShop().type = "Edo Revivalist"; + return () => { V.FSPromenade.EdoRevivalist = 1; }; + case "ArabianRevivalist": + randomShop().type = "Arabian Revivalist"; + return () => { V.FSPromenade.ArabianRevivalist = 1; }; + case "ChineseRevivalist": + randomShop().type = "Chinese Revivalist"; + return () => { V.FSPromenade.Degradationist = 1; }; + case "Repopulationist": + randomShop().type = "Repopulationist"; + return () => { V.FSPromenade.Repopulationist = 1; }; + case "Eugenics": + randomShop().type = "Eugenics"; + return () => { V.FSPromenade.Eugenics = 1; }; + case "HedonisticDecadence": + randomShop().type = "Hedonistic Decadence"; + return () => { V.FSPromenade.HedonisticDecadence = 1; }; + case "IntellectualDependency": + randomShop().type = "Intellectual Dependency"; + return () => { V.FSPromenade.IntellectualDependency = 1; }; + case "SlaveProfessionalism": + randomShop().type = "Slave Professionalism"; + return () => { V.FSPromenade.SlaveProfessionalism = 1; }; + case "PetiteAdmiration": + randomShop().type = "Petite Admiration"; + return () => { V.FSPromenade.PetiteAdmiration = 1; }; + case "StatuesqueGlorification": + randomShop().type = "Statuesque Glorification"; + return () => { V.FSPromenade.StatuesqueGlorification = 1; }; + default: + return () => {}; + } + } + return [ /* basic types for controlled start */ { isAllowed: env => !env.established && env.terrain === "default", - construct: () => templateToBuilding(templates.default), - apply() {} + construct: () => { return {building: templateToBuilding(templates.default), apply: () => {}}; } }, { isAllowed: env => !env.established && env.terrain === "urban", - construct: () => templateToBuilding(templates.urban), - apply() {} + construct: () => { return {building: templateToBuilding(templates.urban), apply: () => {}}; } }, { isAllowed: env => !env.established && env.terrain === "rural", - construct: () => templateToBuilding(templates.rural), - apply() {} + construct: () => { return {building: templateToBuilding(templates.rural), apply: () => {}}; } }, { isAllowed: env => !env.established && env.terrain === "ravine", - construct: () => templateToBuilding(templates.ravine), - apply() {} + construct: () => { return {building: templateToBuilding(templates.ravine), apply: () => {}}; } }, { isAllowed: env => !env.established && env.terrain === "marine", - construct: () => templateToBuilding(templates.marine), - apply() {} + construct: () => { return {building: templateToBuilding(templates.marine), apply: () => {}}; } }, { isAllowed: env => !env.established && env.terrain === "oceanic", - construct: () => templateToBuilding(templates.oceanic), - apply() {} + construct: () => { return {building: templateToBuilding(templates.oceanic), apply: () => {}}; } }, /* crazy presets for established arcologies TODO */ { isAllowed: env => env.established && env.terrain === "default", - construct() { return templateToBuilding(templates.default); }, - apply() {} + construct: env => { return randomizeBuilding(templateToBuilding(templates.default), env); } }, { isAllowed: env => env.established && env.terrain === "urban", - construct() { return templateToBuilding(templates.urban); }, - apply() {} + construct: env => { return randomizeBuilding(templateToBuilding(templates.urban), env); } }, { isAllowed: env => env.established && env.terrain === "rural", - construct() { return templateToBuilding(templates.rural); }, - apply() {} + construct: env => { return randomizeBuilding(templateToBuilding(templates.rural), env); } }, { isAllowed: env => env.established && env.terrain === "ravine", - construct() { return templateToBuilding(templates.ravine); }, - apply() {} + construct: env => { return randomizeBuilding(templateToBuilding(templates.ravine), env); } }, { isAllowed: env => env.established && env.terrain === "marine", - construct() { return templateToBuilding(templates.marine); }, - apply() {} + construct: env => { return randomizeBuilding(templateToBuilding(templates.marine), env); } }, { isAllowed: env => env.established && env.terrain === "oceanic", - construct() { return templateToBuilding(templates.oceanic); }, - apply() {} + construct: env => { return randomizeBuilding(templateToBuilding(templates.oceanic), env); } }, { isAllowed: env => env.established && Math.random() < 0.1, - construct: () => { return templateToBuilding(templates.dick); }, - apply() {} + construct: env => { return randomizeBuilding(templateToBuilding(templates.dick), env); } }, ]; }()); @@ -250,7 +349,7 @@ App.Arcology.upgrades = function(building) { /** @type {Array<upgrade>} */ const upgrades = [{ id: "spire", - layouts: ["default", "urban", "rural", "ravine", "marine", "oceanic"], + layouts: ["default", "urban", "rural", "ravine", "marine", "oceanic", "dick"], exclusive: [], name: "spire", desc: "the addition of a spire at the top of the arcology to increase the space available for the wealthiest citizens to own whole floors", cost: 250000, apply: () => { diff --git a/src/events/intro/arcologySelection.js b/src/events/intro/arcologySelection.js index 2845f0f8e23a8129b838af342392b2376da1ddb7..2c83f0ce969e64c070a5d7adb660607c082899e6 100644 --- a/src/events/intro/arcologySelection.js +++ b/src/events/intro/arcologySelection.js @@ -195,8 +195,8 @@ App.Intro.generateEstablishedArcologies = function() { arcology.language = getLanguage(); const env = {terrain: arcology.terrain, established: true, fs: arcology.fs}; - const preset = App.Arcology.randomPreset(env); - arcology.building = preset.construct(env); + const preset = App.Arcology.randomPreset(env).construct(env); + arcology.building = preset.building; arcology.apply = preset.apply; return arcology;