diff --git a/src/002-config/sugarCubeConfig.js b/src/002-config/sugarCubeConfig.js index 771f8b360634b68ebd6908feba5a1f5bfdc23bf0..a7cab8228445f24774c9af419d404b9f579913e6 100644 --- a/src/002-config/sugarCubeConfig.js +++ b/src/002-config/sugarCubeConfig.js @@ -6,12 +6,14 @@ Config.passages.start = "init"; /* Set description used by Save, for all passages, to give some decent information about game state. */ -Config.passages.descriptions = function () { +Config.passages.descriptions = function() { let sv = State.variables; - if (sv.arcologies === undefined || sv.arcologies.length === 0) - return "New Game Setup, Week 0"; // no arcology yet... - else + if (sv.arcologies === undefined || sv.arcologies.length === 0) { + // no arcology yet... + return "New Game Setup, Week 0"; + } else { return sv.arcologies[0].name + ", Week " + sv.week + ", " + sv.slaves.length + " Slaves, " + cashFormat(sv.cash); + } }; /* Disable forward/back buttons in panel. */ diff --git a/src/004-base/000-proxies.js b/src/004-base/000-proxies.js index 5d9da3f6190b4928176d0ded6c5ce8c37c424659..69b72acd7d6e9cf89d4301989b3a20a0c8de9df6 100644 --- a/src/004-base/000-proxies.js +++ b/src/004-base/000-proxies.js @@ -5,8 +5,8 @@ if (target[readOnlySymbol]) { return target; } if (_.isArray(target)) { return new Proxy(target, { - get:function(o, prop) { - if(prop === readOnlySymbol) { return true; } + get: function(o, prop) { + if (prop === readOnlySymbol) { return true; } const val = o[prop]; if (typeof val === 'function') { if (['push', 'unshift', 'pop'].includes(prop)) { @@ -18,24 +18,24 @@ } return createReadonlyProxy(val); }, - set:function(o, prop, value) { + set: function(o, prop, value) { return true; }, - deleteProperty:function(o, prop) { + deleteProperty: function(o, prop) { return true; } }); } if (_.isObject(target)) { return new Proxy(target, { - get:function(o, prop) { - if(prop === readOnlySymbol) { return true; } + get: function(o, prop) { + if (prop === readOnlySymbol) { return true; } return createReadonlyProxy(o[prop]); }, - set:function(o, prop, value) { + set: function(o, prop, value) { return true; }, - deleteProperty:function(o, prop) { + deleteProperty: function(o, prop) { return true; } }); @@ -48,8 +48,8 @@ if (target[cheaterSymbol]) { return target; } if (_.isArray(target)) { return new Proxy(target, { - get:function(o, prop) { - if(prop === cheaterSymbol) { return true; } + get: function(o, prop) { + if (prop === cheaterSymbol) { return true; } const val = o[prop]; if (typeof val === 'function') { if (['push', 'unshift', 'pop'].includes(prop)) { @@ -64,12 +64,12 @@ } return createCheatProxy(val); }, - set:function(o, prop, value) { + set: function(o, prop, value) { o[prop] = value; State.variables.cheater = 1;// Can't use `V` because it probably points to a proxy. return true; }, - deleteProperty:function(o, prop) { + deleteProperty: function(o, prop) { delete o[prop]; State.variables.cheater = 1;// Can't use `V` because it probably points to a proxy. return true; @@ -78,16 +78,16 @@ } if (_.isObject(target)) { return new Proxy(target, { - get:function(o, prop) { - if(prop === cheaterSymbol) { return true; } + get: function(o, prop) { + if (prop === cheaterSymbol) { return true; } return createCheatProxy(o[prop]); }, - set:function(o, prop, value) { + set: function(o, prop, value) { o[prop] = value; State.variables.cheater = 1; return true; }, - deleteProperty:function(o, prop) { + deleteProperty: function(o, prop) { delete o[prop]; State.variables.cheater = 1; return true; diff --git a/src/004-base/arcologyBuilding.js b/src/004-base/arcologyBuilding.js index 990ab2d94deac013158bc9f52f952efc6da53a1f..b801932a8479fb47d82f6468173ef9eaeecbc88c 100644 --- a/src/004-base/arcologyBuilding.js +++ b/src/004-base/arcologyBuilding.js @@ -171,7 +171,7 @@ App.Arcology.Cell.BaseCell = class extends App.Entity.Serializable { } } else { fragment.append(`You will have to acquire an additional ${oneCellPercentage}% interest in ${A.name} to take control of this sector. Such an interest is worth ${cashFormat(price)} and will require a transaction cost of ${cashFormat(10000)} to acquire for a total cost of ${cashFormat(price + 10000)}.`); - const availableCells = allCells.length * ((100-A.minority)/100) - ownedCells; + const availableCells = allCells.length * ((100 - A.minority) / 100) - ownedCells; if (availableCells >= 1) { const buySpan = document.createElement("span"); buySpan.classList.add("clear-formatting"); diff --git a/src/004-base/facility.js b/src/004-base/facility.js index d4ef66b608f6f0e7d03f19bd3230af663fcdc5f2..8a73a5b25e5e1201d32b852a44768becdd384fc6 100644 --- a/src/004-base/facility.js +++ b/src/004-base/facility.js @@ -136,13 +136,14 @@ App.Entity.Facilities.Job = class { * @param {number} [pureTrust=101] Minimal high trust level to pass test without devotion * @returns {boolean} */ - static _isBrokenEnough(slave, pureDevotion, devotion, trust, pureFear, pureTrust) { - if ((slave.devotion < (pureDevotion || 50)) && - (slave.trust < (pureTrust || 101)) && (slave.trust > (pureFear || -51)) && - ((slave.devotion <= (devotion || -51)) || (slave.trust >= (trust || -21)))) { - return false; - } - return true; + static _isBrokenEnough(slave, pureDevotion = 50, devotion = -51, trust = -21, pureFear = -51, pureTrust = 101) { + return slave.devotion >= pureDevotion + || slave.trust >= pureTrust + || slave.trust <= pureFear + || ( + slave.devotion > devotion + && slave.trust < trust + ); } /** @@ -198,6 +199,7 @@ App.Entity.Facilities.ManagingJob = class extends App.Entity.Facilities.Job { } return r; } + /** * Returns true if slave has enough applicable skill or career * @param {App.Entity.SlaveState} slave @@ -353,6 +355,7 @@ App.Entity.Facilities.Facility = class { get totalOccupants() { return this.hostedSlaves + this.nonEmployeeOccupantsCount; } + get hasEmployees() { return this.jobs.some(j => j.employeesIDs().size > 0); } @@ -546,6 +549,7 @@ App.Entity.Facilities.SingleJobFacility = class extends App.Entity.Facilities.Fa } this._job = this.job(); // cache the only job } + /** * @override * @protected diff --git a/src/005-passages/bcPassages.js b/src/005-passages/bcPassages.js index 1cf82e5ac49e4725e18ce05fdaecdf64cf691620..47e6bbb32868dbe8217505c6be194d01400fa3e5 100644 --- a/src/005-passages/bcPassages.js +++ b/src/005-passages/bcPassages.js @@ -6,7 +6,8 @@ new App.DomPassage("Backwards Compatibility", App.Update.setNonexistentProperties(V, App.Data.defaultGameStateVariables); - /* resetOnNGPlus contains half of the variables we need, but we use it politely here instead of forcing it so it fills in holes instead of overwriting data */ + // resetOnNGPlus contains half of the variables we need, but we use it politely here instead of forcing it so it + // fills in holes instead of overwriting data. App.Update.setNonexistentProperties(V, App.Data.resetOnNGPlus); return App.Update.backwardsCompatibility();