From ebdd7dad3a89f3e6e4d21e02ea5074600fd45272 Mon Sep 17 00:00:00 2001 From: Skriv <skrivelese@gmail.com> Date: Mon, 4 Nov 2019 21:16:23 +0100 Subject: [PATCH] Eslint suggestions --- src/004-base/facility.js | 4 +- src/Corporation/corporate-constants.js | 958 ++++----- .../corporate-divisionAcquiring.js | 159 +- src/Corporation/corporate-divisionBase.js | 375 ++-- .../corporate-divisionProcessing.js | 175 +- src/Corporation/corporate-divisionWorking.js | 178 +- src/Corporation/corporate.js | 1851 ++++++++--------- src/debugging/debugJS.js | 2 +- src/endWeek/saNanny.js | 270 +-- src/endWeek/saRules.js | 317 +-- src/endWeek/saServeThePublic.js | 2 +- src/endWeek/saWhore.js | 4 +- src/endWeek/saWorkAGloryHole.js | 2 +- 13 files changed, 2179 insertions(+), 2118 deletions(-) diff --git a/src/004-base/facility.js b/src/004-base/facility.js index 00f8912f948..30a76db6dd6 100644 --- a/src/004-base/facility.js +++ b/src/004-base/facility.js @@ -259,7 +259,7 @@ App.Entity.Facilities.ManagingJob = class extends App.Entity.Facilities.Job { /** @returns {App.Entity.SlaveState} */ get currentEmployee() { const obj = State.variables[capFirstChar(this.desc.position)]; - return obj === undefined || obj === 0 ? null : obj; + return obj === undefined || obj === 0 ? null : obj; } /** @private */ @@ -336,7 +336,7 @@ App.Entity.Facilities.Facility = class { } /** Facility slave capacity - * @returns {number} */ + * @returns {number} */ get capacity() { return State.variables[this.desc.baseName]; } diff --git a/src/Corporation/corporate-constants.js b/src/Corporation/corporate-constants.js index 5117176df8f..59eb1e9eb89 100644 --- a/src/Corporation/corporate-constants.js +++ b/src/Corporation/corporate-constants.js @@ -1,41 +1,41 @@ -App.Corporate.InitConstants = function () { - App.Corporate.payoutMinimumCash = 1000000; - App.Corporate.payoutCorpValueMultiplier = 0.05; - App.Corporate.dividendOptions = [0.75, 0.5, 0.25, 0.1, 0.05]; - App.Corporate.stockSplits = [ - { - 'newStocks': 3, - 'oldStocks': 2, - 'weeks': 1, - 'cost': 7.5 - }, - { - 'newStocks': 2, - 'weeks': 1, - 'cost': 10 - }, - { - 'newStocks': 3, - 'weeks': 2, - 'cost': 12.5 - }, - { - 'newStocks': 4, - 'weeks': 3, - 'cost': 15 - }, - { - 'oldStocks': 4, - 'weeks': 1, - 'cost': 15 - }, - { - 'oldStocks': 10, - 'weeks': 2, - 'cost': 25 - }, - ]; - /* +App.Corporate.InitConstants = function() { + App.Corporate.payoutMinimumCash = 1000000; + App.Corporate.payoutCorpValueMultiplier = 0.05; + App.Corporate.dividendOptions = [0.75, 0.5, 0.25, 0.1, 0.05]; + App.Corporate.stockSplits = [ + { + 'newStocks': 3, + 'oldStocks': 2, + 'weeks': 1, + 'cost': 7.5 + }, + { + 'newStocks': 2, + 'weeks': 1, + 'cost': 10 + }, + { + 'newStocks': 3, + 'weeks': 2, + 'cost': 12.5 + }, + { + 'newStocks': 4, + 'weeks': 3, + 'cost': 15 + }, + { + 'oldStocks': 4, + 'weeks': 1, + 'cost': 15 + }, + { + 'oldStocks': 10, + 'weeks': 2, + 'cost': 25 + }, + ]; + /* center/range object: The center value is the average or center value of the property, while range is the value range (centered on center). So if center is 1 and range is 0.5, the value can be anything from 0.75 to 1.25. == Base == @@ -97,445 +97,445 @@ App.Corporate.InitConstants = function () { */ - App.Corporate.divisionList = [ - new App.Corporate.Division.Acquiring( { - 'id':'Extra', - 'name':'Extralegal Enslavement', - 'focusDescription':'capturing and enslaving prisoners', - 'sizeCost': 20, - 'slaveValue':10, - 'acquiring': { - 'center':1, - 'range': 0.8, - }, - 'maintenance':{ - 'linear': 7.5, - 'quadratic': 5, - 'category':'acquision', - }, - 'founding':{ - 'corporateCash':100, - }, - 'mercenaryHelp': { - 'level': 2, - 'cost': 0.05 - }, - 'nextDivision': [ - "Break", - "Arcade" - ], - 'merger':[ - { - 'name': 'mercenary company', - 'cost': 50, - 'text': { - 'trouble':'a troubled mercenary company. After a spate of failed operations, the rank and file deposed their management and are now looking to merge with a better-run organization. The old leadership did not engage in enslavement activities, but the mercenaries have decided to turn their talents towards slaving for profit in conflict zones.', - 'acquire':' and ease their transition to conflict zone slaving.' - }, - 'result': { - 'development': 5 - } - } - ] - }), - new App.Corporate.Division.Acquiring( { - 'id': 'Legal', - 'name': 'Legal Enslavement', - 'focusDescription': 'legal enslavement', - 'sizeCost': 25, - 'slaveValue':15, - 'acquiring': { - 'center':1, - 'range': 0.5, - }, - 'maintenance':{ - 'linear': 12, - 'quadratic': 6, - 'category':'acquision', - }, - 'founding':{ - 'corporateCash':125, - }, - 'nextDivision': [ - "Train", - "Menial", - "Surgery" - ], - 'merger':[ - { - 'name':'telemarketing firm', - 'cost': 50, - 'text': { - 'trouble':'an old world telemarketing firm. In an attempt to survive in the changing economy, it turned its focus towards convincing desperate, ignorant, or stupid people from the old world to accept voluntary enslavement, through a variety of entrapment procedures. It failed to make the transition successfully, but you could certainly continue its operations under your aegis.', - 'acquire':' and clean out the deadwood, getting the business in Free Cities shape.' - }, - 'result': { - 'development':5 - } - } - ] - }), - new App.Corporate.Division.Processing( { - 'id': 'Break', - 'name': 'Slave Breaking', - 'focusDescription': 'breaking slaves', - 'sizeCost': 10, - 'addedValue': 5, - 'processing': { - 'center':0.3, - 'range':0.3, - }, - 'maintenance':{ - 'linear': 0.45, - 'quadratic': 0.6, - 'category':'processing', - }, - 'founding':{ - 'corporateCash':25, - }, - 'slaveProcessType':{ - 'present':'break', - 'past':'broke' - }, - 'slaveProcessDescription':{ - 'present':'attempting to break', - 'future':'break', - 'past':'broken', - 'market': { - single: 'slave that needs breaking', - plural: 'slaves that need breaking' - } - }, - 'nextDivision': [ - "Train", - "Menial", - "Surgery" - ], - 'merger':[ - { - 'name': 'slave breaking facility', - 'cost': 50, - 'text': { - 'trouble':'a small slave breaking firm. Despite a great need for obedient slaves the owner of this little establishment was unable to turn a profit. The facility has everything a respecting slave breaking could ever need, it seems the owner simply lacked the right character to apply effective breaking techniques. Your corporation knows perfectly well what it takes to achieve obedience and the assets can be put to great use.', - 'acquire':' and staff it with qualified personnel to make use of the new assets.' - }, - 'result': { - 'development':5, - 'slaves':5 - } - } - ] - }), - new App.Corporate.Division.Processing( { - 'id': 'Surgery', - 'name': 'Slave Modifications', - 'focusDescription': 'physical slave modifications', - 'sizeCost': 20, - 'addedValue':8, - 'processing': { - 'center':0.5, - 'range':0.2, - }, - 'maintenance':{ - 'linear': 2.4, - 'quadratic': 1, - 'category':'processing', - }, - 'founding':{ - 'corporateCash':55, - }, - 'slaveProcessType':{ - 'present':'modify', - 'past':'finished working on' - }, - 'slaveProcessDescription':{ - 'present':'working on', - 'future':'work on', - 'past':'improved', - 'market': { - single: 'slave that could use some work done to their body', - plural: 'slaves that could use some work done to their bodies' - } - }, - 'nextDivision': [ - "Train", - "Dairy" - ], - 'merger':[ - { - 'name': 'medical clinic', - 'cost': 50, - 'text': { - 'trouble':"a small medical clinic. Medical malpractice continues to be a major source of trouble for surgeons in the old world. A plastic surgeon has just suffered defeat in a major legal case over implant ruptures. He's looking to make the transition to a more enlightened area, along with his inventory and staff.", - 'acquire':" and the surgeon decides to retire on the proceeds of the sale, wishing your corporation well. It was a smart decision; he can retire to the Free Cities on that sum of money, and remote surgery is killing surgeons' wages." - }, - 'result': { - 'development': 3, - 'slaves':3 - } - } - ] - }), - new App.Corporate.Division.Processing( { - 'id': 'Train', - 'name': 'Slave Training', - 'focusDescription': 'training slaves', - 'sizeCost': 25, - 'addedValue': 11, - 'processing': { - 'center':0.2, - 'range':0.3, - }, - 'maintenance':{ - 'linear': 0.7, - 'quadratic': 1, - 'category':'processing', - }, - 'founding':{ - 'corporateCash':50, - }, - 'slaveProcessType':{ - 'present':'train', - 'past':'trained' - }, - 'slaveProcessDescription':{ - 'present':'training', - 'future':'train', - 'past':'trained', - 'market': { - single: 'slave that needs slave training', - plural: 'slaves that need slave training' - } - }, - 'nextDivision': [ - "Whore" - ], - 'merger':[ - { - 'name': 'slave training firm', - 'cost': 50, - 'text': { - 'trouble':"a small slave training firm. Slave training is a notoriously difficult business, since the maturation times on the merchandise can be extremely long, and the improvement in price can be marginal if the training does not prove highly successful. There's nothing inherently wrong with the business, they've simply hit a cash flow bottleneck and need to merge with a cash-rich organization like yours.", - 'acquire':". The previous owners are happy they'll be able to continue operations under the aegis of a better-run, richer corporation." - }, - 'result': { - 'development': 3, - 'slaves':3 - } - } - ] - }), - new App.Corporate.Division.Working( { - 'id': 'Arcade', - 'name': 'Sex Arcades', - 'focusDescription': 'operating sex arcades', - 'sizeCost': 5, - 'attrition': { - 'center':0.05, - 'range':0.2, - }, - 'maintenance':{ - 'linear': 0.2, - 'quadratic': 0.125, - 'category':'working', - }, - 'revenue':{ - 'center':1000, - 'range':0.1 - }, - 'founding':{ - 'corporateCash':15, - 'startingSize':20, - }, - 'slaveWorkDescription':{ - 'present':'exploiting', - 'future':'exploit', - 'past':'wore out', - 'market': 'fresh slave' - }, - 'merger':[ - { - 'name': 'café', - 'cost': 50, - 'text': { - 'trouble':"a quaint maid café. The prime location together with a popular concept should make for a bustling business and yet the owner is looking to get out of the business hoping to salvage some of his savings. Sadly there was a lack of capital to employ attractive servant slave maids. While someone might very well be more than willing to come in and invest in some better slaves, the place is so cheap you could easily replace the furniture and use the current assets to create a new arcade location for your corporation instead.", - 'acquire':". The old owner wishes his slaves luck under the new management, not knowing your plans for the place. A new sex arcade under your corporate umbrella will open shortly." - }, - 'result': { - 'development':5, - 'slaves':5 - } - } - ] - }), - new App.Corporate.Division.Working( { - 'id': 'Menial', - 'name': 'Menial Services', - 'focusDescription': 'offering menial services', - 'sizeCost': 6.5, - 'attrition': { - 'center':0.05, - 'range':0.2, - }, - 'maintenance':{ - 'linear': 0.2, - 'quadratic': 0.1, - 'category':'working', - }, - 'revenue':{ - 'center':1250, - 'range':0.2 - }, - 'founding':{ - 'corporateCash':20, - 'startingSize':20, - }, - 'slaveWorkDescription':{ - 'present':'exploiting', - 'future':'exploit', - 'past':'wore out', - 'market':'menial slave' - }, - 'merger':[ - { - 'name': 'slaveholding firm', - 'cost': 50, - 'text': { - 'trouble':"a minor slaveholding company. A major deal with a troubled government just fell through, and they had depended on it going through to an unwise degree. They need to merge with a larger slaving concern immediately, but there's nothing at all wrong with their significant inventory of slaves.", - 'acquire':", cash out its hapless staff, and absorb its stock into your corporation." - }, - 'result': { - 'development':5, - 'slaves':5 - } - } - ] - }), - new App.Corporate.Division.Working( { - 'id': 'Dairy', - 'name': 'Dairy', - 'focusDescription': 'milking slaves', - 'sizeCost': 15, - 'attrition': { - 'center':0.05, - 'range':0.2, - }, - 'maintenance':{ - 'linear': 0.85, - 'quadratic': 0.4, - 'category':'working', - }, - 'revenue':{ - 'center':3000, - 'range':0.2 - }, - 'founding':{ - 'corporateCash':25, - }, - 'slaveWorkDescription':{ - 'present':'milking', - 'future':'milk', - 'past':'ran dry', - 'market': 'cow' - }, - 'merger':[ - { - 'name': 'farm', - 'cost': 50, - 'text': { - 'trouble':"a dairy farm. Why a conventional dairy farm popped up as target confused you for a moment, but it quickly became clear the entire family was so deep in debt it would be a no brainer to buy the farm and start milking the large-uddered farmer's daughters as a great addition to your corporate dairy.", - 'acquire':" and your new slaves for the corporation. The family is not happy with your plans, but their approval is not required, you care only for their fluids." - }, - 'result': { - 'development':3, - 'slaves':3 - } - } - ] - }), - new App.Corporate.Division.Working( { - 'id': 'Whore', - 'name': 'Escort Service', - 'focusDescription': 'whoring out slaves', - 'sizeCost': 20, - 'attrition': { - 'center':0.05, - 'range':0.2, - }, - 'maintenance':{ - 'linear': 0.7, - 'quadratic': 0.25, - 'category':'working', - }, - 'revenue':{ - 'center':3000, - 'range':0.1 - }, - 'founding':{ - 'corporateCash':50, - }, - 'slaveWorkDescription':{ - 'present':'whoring out', - 'future':'whore out', - 'past':'lost their appeal', - 'market': 'trained whore' - }, - 'merger':[ - { - 'name': 'brothel', - 'cost': 50, - 'text': { - 'trouble':"a little brothel. With slave whores becoming the dominant force in sexual services the current madam lost her passion for the business. She's getting up there in age and has run a tight ship for many years so she deemed it the right time to bow out. All you need to do to add a new brothel location for your corporation is sign at the dotted line before anyone else has a chance to bite.", - 'acquire':" before anyone else can make an offer. The madam is surprised by your speed, but happily signs over the brothel." - }, - 'result': { - 'development':3, - 'slaves':3 - } - } - ] - }) - ]; - //divisionCategoriesList: Division maintenance categories are used to calculate the overhead that occurs from having multiple divisions within the same category. - // id: The identifier that will be used in division.maintenance.category - // freeDivisions: How many divisions must appear in this category before the overhead cost comes into play. For example, if this is 1, then the second division will cost divisionCost, and the third will bring the overhead up to four times divisionCost. - // divisionCost: How much to multiply the overhead by in cash. The first division past the free divisions will cost this much, but the value will increase exponentially. - // freeDevelopment: How many developments, totaled across all divisions in the category, are ignored by this category before overhead comes into play. Note: freeDivisions does *not* affect this; if freeDevelopment is 100 and freeDivisions is 1, if you only have a single division with 110 developments, you will be charged for the 10 developments over. - // developmentCost: How much to multiply the squared developments by, in cash. The first development past the ignored value will cost this much, but the cost increases exponentially. - //corporate: The corporate-wide overhead for divisions, beyond the individual categories. - // freeDivisions: How many total divisions, across all categories, are ignored before charging corporate level overhead. - // divisionCost: How much to multiply the square of counted divisions in cash. The first counted division will cost this much, but the value increases exponentially. - //Equations: - // divisionBaseOverhead = (divisions - freeDivisions) ^ 2 * divisionCost - // divisionOperationOverhead = (sum(development) - freeDevelopment) ^ 2 * developmentCost - // corpOverhead = (divisions - 2) ^ 2 * 10000 - App.Corporate.maintenance = { - divisionCategoriesList: [ - { - id:'acquision', - freeDivisions: 0, - divisionCost: 25000, - freeDevelopment: 100, - developmentCost: 2 - }, - { - id:'processing', - freeDivisions: 0, - divisionCost: 25000, - freeDevelopment: 200, - developmentCost: 1 - }, - { - id:'working', - freeDivisions: 1, - divisionCost: 15000, - freeDevelopment: 800, - developmentCost: 0.1 - }, - ], - corporate: { - freeDivisions: 2, - divisionCost: 10000 - } - }; + App.Corporate.divisionList = [ + new App.Corporate.Division.Acquiring( { + 'id': 'Extra', + 'name': 'Extralegal Enslavement', + 'focusDescription': 'capturing and enslaving prisoners', + 'sizeCost': 20, + 'slaveValue': 10, + 'acquiring': { + 'center': 1, + 'range': 0.8, + }, + 'maintenance': { + 'linear': 7.5, + 'quadratic': 5, + 'category': 'acquision', + }, + 'founding': { + 'corporateCash': 100, + }, + 'mercenaryHelp': { + 'level': 2, + 'cost': 0.05 + }, + 'nextDivision': [ + "Break", + "Arcade" + ], + 'merger': [ + { + 'name': 'mercenary company', + 'cost': 50, + 'text': { + 'trouble': 'a troubled mercenary company. After a spate of failed operations, the rank and file deposed their management and are now looking to merge with a better-run organization. The old leadership did not engage in enslavement activities, but the mercenaries have decided to turn their talents towards slaving for profit in conflict zones.', + 'acquire': ' and ease their transition to conflict zone slaving.' + }, + 'result': { + 'development': 5 + } + } + ] + }), + new App.Corporate.Division.Acquiring( { + 'id': 'Legal', + 'name': 'Legal Enslavement', + 'focusDescription': 'legal enslavement', + 'sizeCost': 25, + 'slaveValue': 15, + 'acquiring': { + 'center': 1, + 'range': 0.5, + }, + 'maintenance': { + 'linear': 12, + 'quadratic': 6, + 'category': 'acquision', + }, + 'founding': { + 'corporateCash': 125, + }, + 'nextDivision': [ + "Train", + "Menial", + "Surgery" + ], + 'merger': [ + { + 'name': 'telemarketing firm', + 'cost': 50, + 'text': { + 'trouble': 'an old world telemarketing firm. In an attempt to survive in the changing economy, it turned its focus towards convincing desperate, ignorant, or stupid people from the old world to accept voluntary enslavement, through a variety of entrapment procedures. It failed to make the transition successfully, but you could certainly continue its operations under your aegis.', + 'acquire': ' and clean out the deadwood, getting the business in Free Cities shape.' + }, + 'result': { + 'development': 5 + } + } + ] + }), + new App.Corporate.Division.Processing( { + 'id': 'Break', + 'name': 'Slave Breaking', + 'focusDescription': 'breaking slaves', + 'sizeCost': 10, + 'addedValue': 5, + 'processing': { + 'center': 0.3, + 'range': 0.3, + }, + 'maintenance': { + 'linear': 0.45, + 'quadratic': 0.6, + 'category': 'processing', + }, + 'founding': { + 'corporateCash': 25, + }, + 'slaveProcessType': { + 'present': 'break', + 'past': 'broke' + }, + 'slaveProcessDescription': { + 'present': 'attempting to break', + 'future': 'break', + 'past': 'broken', + 'market': { + single: 'slave that needs breaking', + plural: 'slaves that need breaking' + } + }, + 'nextDivision': [ + "Train", + "Menial", + "Surgery" + ], + 'merger': [ + { + 'name': 'slave breaking facility', + 'cost': 50, + 'text': { + 'trouble': 'a small slave breaking firm. Despite a great need for obedient slaves the owner of this little establishment was unable to turn a profit. The facility has everything a respecting slave breaking could ever need, it seems the owner simply lacked the right character to apply effective breaking techniques. Your corporation knows perfectly well what it takes to achieve obedience and the assets can be put to great use.', + 'acquire': ' and staff it with qualified personnel to make use of the new assets.' + }, + 'result': { + 'development': 5, + 'slaves': 5 + } + } + ] + }), + new App.Corporate.Division.Processing( { + 'id': 'Surgery', + 'name': 'Slave Modifications', + 'focusDescription': 'physical slave modifications', + 'sizeCost': 20, + 'addedValue': 8, + 'processing': { + 'center': 0.5, + 'range': 0.2, + }, + 'maintenance': { + 'linear': 2.4, + 'quadratic': 1, + 'category': 'processing', + }, + 'founding': { + 'corporateCash': 55, + }, + 'slaveProcessType': { + 'present': 'modify', + 'past': 'finished working on' + }, + 'slaveProcessDescription': { + 'present': 'working on', + 'future': 'work on', + 'past': 'improved', + 'market': { + single: 'slave that could use some work done to their body', + plural: 'slaves that could use some work done to their bodies' + } + }, + 'nextDivision': [ + "Train", + "Dairy" + ], + 'merger': [ + { + 'name': 'medical clinic', + 'cost': 50, + 'text': { + 'trouble': "a small medical clinic. Medical malpractice continues to be a major source of trouble for surgeons in the old world. A plastic surgeon has just suffered defeat in a major legal case over implant ruptures. He's looking to make the transition to a more enlightened area, along with his inventory and staff.", + 'acquire': " and the surgeon decides to retire on the proceeds of the sale, wishing your corporation well. It was a smart decision; he can retire to the Free Cities on that sum of money, and remote surgery is killing surgeons' wages." + }, + 'result': { + 'development': 3, + 'slaves': 3 + } + } + ] + }), + new App.Corporate.Division.Processing( { + 'id': 'Train', + 'name': 'Slave Training', + 'focusDescription': 'training slaves', + 'sizeCost': 25, + 'addedValue': 11, + 'processing': { + 'center': 0.2, + 'range': 0.3, + }, + 'maintenance': { + 'linear': 0.7, + 'quadratic': 1, + 'category': 'processing', + }, + 'founding': { + 'corporateCash': 50, + }, + 'slaveProcessType': { + 'present': 'train', + 'past': 'trained' + }, + 'slaveProcessDescription': { + 'present': 'training', + 'future': 'train', + 'past': 'trained', + 'market': { + single: 'slave that needs slave training', + plural: 'slaves that need slave training' + } + }, + 'nextDivision': [ + "Whore" + ], + 'merger': [ + { + 'name': 'slave training firm', + 'cost': 50, + 'text': { + 'trouble': "a small slave training firm. Slave training is a notoriously difficult business, since the maturation times on the merchandise can be extremely long, and the improvement in price can be marginal if the training does not prove highly successful. There's nothing inherently wrong with the business, they've simply hit a cash flow bottleneck and need to merge with a cash-rich organization like yours.", + 'acquire': ". The previous owners are happy they'll be able to continue operations under the aegis of a better-run, richer corporation." + }, + 'result': { + 'development': 3, + 'slaves': 3 + } + } + ] + }), + new App.Corporate.Division.Working( { + 'id': 'Arcade', + 'name': 'Sex Arcades', + 'focusDescription': 'operating sex arcades', + 'sizeCost': 5, + 'attrition': { + 'center': 0.05, + 'range': 0.2, + }, + 'maintenance': { + 'linear': 0.2, + 'quadratic': 0.125, + 'category': 'working', + }, + 'revenue': { + 'center': 1000, + 'range': 0.1 + }, + 'founding': { + 'corporateCash': 15, + 'startingSize': 20, + }, + 'slaveWorkDescription': { + 'present': 'exploiting', + 'future': 'exploit', + 'past': 'wore out', + 'market': 'fresh slave' + }, + 'merger': [ + { + 'name': 'café', + 'cost': 50, + 'text': { + 'trouble': "a quaint maid café. The prime location together with a popular concept should make for a bustling business and yet the owner is looking to get out of the business hoping to salvage some of his savings. Sadly there was a lack of capital to employ attractive servant slave maids. While someone might very well be more than willing to come in and invest in some better slaves, the place is so cheap you could easily replace the furniture and use the current assets to create a new arcade location for your corporation instead.", + 'acquire': ". The old owner wishes his slaves luck under the new management, not knowing your plans for the place. A new sex arcade under your corporate umbrella will open shortly." + }, + 'result': { + 'development': 5, + 'slaves': 5 + } + } + ] + }), + new App.Corporate.Division.Working( { + 'id': 'Menial', + 'name': 'Menial Services', + 'focusDescription': 'offering menial services', + 'sizeCost': 6.5, + 'attrition': { + 'center': 0.05, + 'range': 0.2, + }, + 'maintenance': { + 'linear': 0.2, + 'quadratic': 0.1, + 'category': 'working', + }, + 'revenue': { + 'center': 1250, + 'range': 0.2 + }, + 'founding': { + 'corporateCash': 20, + 'startingSize': 20, + }, + 'slaveWorkDescription': { + 'present': 'exploiting', + 'future': 'exploit', + 'past': 'wore out', + 'market': 'menial slave' + }, + 'merger': [ + { + 'name': 'slaveholding firm', + 'cost': 50, + 'text': { + 'trouble': "a minor slaveholding company. A major deal with a troubled government just fell through, and they had depended on it going through to an unwise degree. They need to merge with a larger slaving concern immediately, but there's nothing at all wrong with their significant inventory of slaves.", + 'acquire': ", cash out its hapless staff, and absorb its stock into your corporation." + }, + 'result': { + 'development': 5, + 'slaves': 5 + } + } + ] + }), + new App.Corporate.Division.Working( { + 'id': 'Dairy', + 'name': 'Dairy', + 'focusDescription': 'milking slaves', + 'sizeCost': 15, + 'attrition': { + 'center': 0.05, + 'range': 0.2, + }, + 'maintenance': { + 'linear': 0.85, + 'quadratic': 0.4, + 'category': 'working', + }, + 'revenue': { + 'center': 3000, + 'range': 0.2 + }, + 'founding': { + 'corporateCash': 25, + }, + 'slaveWorkDescription': { + 'present': 'milking', + 'future': 'milk', + 'past': 'ran dry', + 'market': 'cow' + }, + 'merger': [ + { + 'name': 'farm', + 'cost': 50, + 'text': { + 'trouble': "a dairy farm. Why a conventional dairy farm popped up as target confused you for a moment, but it quickly became clear the entire family was so deep in debt it would be a no brainer to buy the farm and start milking the large-uddered farmer's daughters as a great addition to your corporate dairy.", + 'acquire': " and your new slaves for the corporation. The family is not happy with your plans, but their approval is not required, you care only for their fluids." + }, + 'result': { + 'development': 3, + 'slaves': 3 + } + } + ] + }), + new App.Corporate.Division.Working( { + 'id': 'Whore', + 'name': 'Escort Service', + 'focusDescription': 'whoring out slaves', + 'sizeCost': 20, + 'attrition': { + 'center': 0.05, + 'range': 0.2, + }, + 'maintenance': { + 'linear': 0.7, + 'quadratic': 0.25, + 'category': 'working', + }, + 'revenue': { + 'center': 3000, + 'range': 0.1 + }, + 'founding': { + 'corporateCash': 50, + }, + 'slaveWorkDescription': { + 'present': 'whoring out', + 'future': 'whore out', + 'past': 'lost their appeal', + 'market': 'trained whore' + }, + 'merger': [ + { + 'name': 'brothel', + 'cost': 50, + 'text': { + 'trouble': "a little brothel. With slave whores becoming the dominant force in sexual services the current madam lost her passion for the business. She's getting up there in age and has run a tight ship for many years so she deemed it the right time to bow out. All you need to do to add a new brothel location for your corporation is sign at the dotted line before anyone else has a chance to bite.", + 'acquire': " before anyone else can make an offer. The madam is surprised by your speed, but happily signs over the brothel." + }, + 'result': { + 'development': 3, + 'slaves': 3 + } + } + ] + }) + ]; + //divisionCategoriesList: Division maintenance categories are used to calculate the overhead that occurs from having multiple divisions within the same category. + // id: The identifier that will be used in division.maintenance.category + // freeDivisions: How many divisions must appear in this category before the overhead cost comes into play. For example, if this is 1, then the second division will cost divisionCost, and the third will bring the overhead up to four times divisionCost. + // divisionCost: How much to multiply the overhead by in cash. The first division past the free divisions will cost this much, but the value will increase exponentially. + // freeDevelopment: How many developments, totaled across all divisions in the category, are ignored by this category before overhead comes into play. Note: freeDivisions does *not* affect this; if freeDevelopment is 100 and freeDivisions is 1, if you only have a single division with 110 developments, you will be charged for the 10 developments over. + // developmentCost: How much to multiply the squared developments by, in cash. The first development past the ignored value will cost this much, but the cost increases exponentially. + //corporate: The corporate-wide overhead for divisions, beyond the individual categories. + // freeDivisions: How many total divisions, across all categories, are ignored before charging corporate level overhead. + // divisionCost: How much to multiply the square of counted divisions in cash. The first counted division will cost this much, but the value increases exponentially. + //Equations: + // divisionBaseOverhead = (divisions - freeDivisions) ^ 2 * divisionCost + // divisionOperationOverhead = (sum(development) - freeDevelopment) ^ 2 * developmentCost + // corpOverhead = (divisions - 2) ^ 2 * 10000 + App.Corporate.maintenance = { + divisionCategoriesList: [ + { + id: 'acquision', + freeDivisions: 0, + divisionCost: 25000, + freeDevelopment: 100, + developmentCost: 2 + }, + { + id: 'processing', + freeDivisions: 0, + divisionCost: 25000, + freeDevelopment: 200, + developmentCost: 1 + }, + { + id: 'working', + freeDivisions: 1, + divisionCost: 15000, + freeDevelopment: 800, + developmentCost: 0.1 + }, + ], + corporate: { + freeDivisions: 2, + divisionCost: 10000 + } + }; }; diff --git a/src/Corporation/corporate-divisionAcquiring.js b/src/Corporation/corporate-divisionAcquiring.js index bdf5a516446..a814b4bfa8f 100644 --- a/src/Corporation/corporate-divisionAcquiring.js +++ b/src/Corporation/corporate-divisionAcquiring.js @@ -1,89 +1,84 @@ App.Corporate.Init_DivisionAcquiring = function(shared) { - - App.Corporate.Division.Acquiring = class extends App.Corporate.Division.Base { - constructor({slaveValue, acquiring, mercenaryHelp, nextDivision}) { - super(arguments[0]); - this._const.slaveValue = slaveValue; - this._const.acquiring = new averageRange(acquiring); - this._const.nextDivisions = nextDivision; - if(mercenaryHelp != null) { - this._const.mercenaryHelp = { - level: mercenaryHelp.level, - cost: mercenaryHelp.cost - } - } - } - //abstract virtual definitions - get fromMarket() { return false; } - get toMarket() { return true; } - get heldSlaves() { return this.getStored("Slaves"); } - set heldSlaves(value) { this.setStored("Slaves",Math.trunc(value)); } - get activeSlaves() { return 0; } - set activeSlaves(value) { throw "Cannot set active slaves for acquiring divisions"; } - get processRate() { return this._const.acquiring.center; } - get purchasedSlaveValue() { return null; } - get initialSlaveValue() { return this.soldSlaveValue; } - get soldSlaveValue() { return this._const.slaveValue; } - get nounFinishedSlave() { return "slave"; } - get nounSlaveFromMarket() { return "slave"; } - messageSlaveCount() { - return `It averages <span class="green">${numberWithPluralNonZero(this.developmentCount, "new slave")}</span> each week.`; - } - messageSlaveOutput() { - return shared.MessageSlaveToMarket(this); - } - message_endWeek_Slaves(divLedger) { - let newSlaves = divLedger.slaves.value; - if(newSlaves > 0) { - return `<span class="green">acquired ${numberWithPlural(newSlaves, "slave")}</span>` + App.Corporate.Division.Acquiring = class extends App.Corporate.Division.Base { + constructor({slaveValue, acquiring, mercenaryHelp, nextDivision}) { + super(arguments[0]); + this._const.slaveValue = slaveValue; + this._const.acquiring = new averageRange(acquiring); + this._const.nextDivisions = nextDivision; + if (mercenaryHelp != null) { + this._const.mercenaryHelp = { + level: mercenaryHelp.level, + cost: mercenaryHelp.cost + }; + } + } + //abstract virtual definitions + get fromMarket() { return false; } + get toMarket() { return true; } + get heldSlaves() { return this.getStored("Slaves"); } + set heldSlaves(value) { this.setStored("Slaves", Math.trunc(value)); } + get activeSlaves() { return 0; } + set activeSlaves(value) { throw "Cannot set active slaves for acquiring divisions"; } + get processRate() { return this._const.acquiring.center; } + get purchasedSlaveValue() { return null; } + get initialSlaveValue() { return this.soldSlaveValue; } + get soldSlaveValue() { return this._const.slaveValue; } + get nounFinishedSlave() { return "slave"; } + get nounSlaveFromMarket() { return "slave"; } + messageSlaveCount() { + return `It averages <span class="green">${numberWithPluralNonZero(this.developmentCount, "new slave")}</span> each week.`; + } + messageSlaveOutput() { + return shared.MessageSlaveToMarket(this); + } + message_endWeek_Slaves(divLedger) { + let newSlaves = divLedger.slaves.value; + if (newSlaves > 0) { + return `<span class="green">acquired ${numberWithPlural(newSlaves, "slave")}</span>` + (this.hadMercenaryHelp ? " with the help of your mercenaries" : ""); - } - else { - return `<span class="red">failed to acquire any slaves</span>` + } else { + return `<span class="red">failed to acquire any slaves</span>` + (this.hadMercenaryHelp ? " even with the help of your mercenaries" : ""); - } - } - endWeek_Slaves(divLedger) { - let slaves = shared.EndWeekProcessing_Slaves(this.developmentCount, this._const.acquiring); - this.heldSlaves += slaves.value; - return divLedger.slaves.apply(slaves); - } - //virtual overrides - get purchasedSlaveValue() { - return null; - } - get nextDivisions() { return this._const.nextDivisions; } - dissolve() { - App.Corporate.sellSlaves(this, this.heldSlaves); - super.dissolve(); - delete V[`${this._const.corpId}Slaves`]; - } - getAutoBuyFromMarket() { - return false; - } - setAutoBuyFromMarket(value) { - throw "Acquiring divisions cannot acquire from the market"; - } + } + } + endWeek_Slaves(divLedger) { + let slaves = shared.EndWeekProcessing_Slaves(this.developmentCount, this._const.acquiring); + this.heldSlaves += slaves.value; + return divLedger.slaves.apply(slaves); + } + //virtual overrides + get nextDivisions() { return this._const.nextDivisions; } + dissolve() { + App.Corporate.sellSlaves(this, this.heldSlaves); + super.dissolve(); + delete V[`${this._const.corpId}Slaves`]; + } + getAutoBuyFromMarket() { + return false; + } + setAutoBuyFromMarket(value) { + throw "Acquiring divisions cannot acquire from the market"; + } - get availableRoom() { return 0; } - get maintenanceSlaves() { return this.developmentCount; } - get maintenanceCost() { - //If it makes sense to have mercenaries help with other types of divisions, this code and the mercenaryHelp property will need to be moved into the super class. - let baseCost = super.maintenanceCost; + get availableRoom() { return 0; } + get maintenanceSlaves() { return this.developmentCount; } + get maintenanceCost() { + //If it makes sense to have mercenaries help with other types of divisions, this code and the mercenaryHelp property will need to be moved into the super class. + let baseCost = super.maintenanceCost; - if(this.hadMercenaryHelp) { - const mercHelpCost = Math.trunc((V.mercenaries - this.mercenaryHelp.level) * this.mercenaryHelp.cost * 1000); - baseCost += mercHelpCost; - } - return baseCost; - } + if (this.hadMercenaryHelp) { + const mercHelpCost = Math.trunc((V.mercenaries - this.mercenaryHelp.level) * this.mercenaryHelp.cost * 1000); + baseCost += mercHelpCost; + } + return baseCost; + } - create() { - super.create(); - this.heldSlaves = 0; - shared.FoundingSetupAutoSell(this); - } + create() { + super.create(); + this.heldSlaves = 0; + shared.FoundingSetupAutoSell(this); + } - get hadMercenaryHelp() { return this.mercenaryHelp != null && V.mercenaries > this.mercenaryHelp.level;} - }; -} + get hadMercenaryHelp() { return this.mercenaryHelp != null && V.mercenaries > this.mercenaryHelp.level; } + }; +}; diff --git a/src/Corporation/corporate-divisionBase.js b/src/Corporation/corporate-divisionBase.js index 90de97fd571..3880cfff960 100644 --- a/src/Corporation/corporate-divisionBase.js +++ b/src/Corporation/corporate-divisionBase.js @@ -1,204 +1,199 @@ App.Corporate.Init_DivisionBase = function(shared) { + App.Corporate.Division.Base = class { + constructor({id, name, focusDescription, sizeCost, maintenance, founding, merger}) { + this._const = {}; + this._const.id = id; + this._const.corpId = `corpDiv${capFirstChar(id)}`; + this._const.cost = sizeCost; + this._const.name = name; + this._const.focusDescription = focusDescription; + this._const.maintenance = { + quadratic: maintenance.quadratic, + linear: maintenance.linear, + category: maintenance.category + }; + if (founding != null) { + this._const.founding = new shared.FoundingType(this, founding); + } + if (merger != null && _.isObject(merger) || (Array.isArray(merger) && merger.length > 0)) { + if (!Array.isArray(merger)) { + merger = [merger]; + } + this._const.merger = merger; + } + this.relatedDivisions = new shared.RelatedDivisionType(); + } + //initialized data + get id() { return this._const.id; } + get sizeCost() { return this._const.cost; } + get name() { return this._const.name; } + get focusDescription() { return this._const.focusDescription; } + get founding() { return this._const.founding; } + get nextDivisions() { return null; } + get hasMergers() { return this._const.merger != null; } + get mergerChoices() { return this._const.merger; } + get maintenanceCategory() { return this._const.maintenance.category; } - App.Corporate.Division.Base = class { - constructor({id, name, focusDescription, sizeCost, maintenance, founding, merger}) { - this._const = {}; - this._const.id = id; - this._const.corpId = `corpDiv${capFirstChar(id)}`; - this._const.cost = sizeCost; - this._const.name = name; - this._const.focusDescription = focusDescription; - this._const.maintenance = { - quadratic: maintenance.quadratic, - linear: maintenance.linear, - category: maintenance.category - }; - if(founding != null) { - this._const.founding = new shared.FoundingType(this, founding); - } - if(merger != null && _.isObject(merger) || (Array.isArray(merger) && merger.length > 0)) { - if(!Array.isArray(merger)) { - merger = [merger]; - } - this._const.merger = merger; - } - this.relatedDivisions = new shared.RelatedDivisionType(); - } - //initialized data - get id() { return this._const.id; } - get sizeCost() { return this._const.cost; } - get name() { return this._const.name; } - get focusDescription() { return this._const.focusDescription; } - get founding() { return this._const.founding; } - get nextDivisions() { return null; } - get hasMergers() { return this._const.merger != null; } - get mergerChoices() { return this._const.merger; } - get maintenanceCategory() { return this._const.maintenance.category; } + //stored variables + get founded() { return this.getStored('') == 1; } + get foundedDate() { return this.getStored('Founded'); } + get developmentCount() { return this.getStored("Dev"); } + set developmentCount(value) { + if (value < 0) { throw "Cannot set development count to less than 0"; } + //dissolve is the only function that sets founded to false. + if (value == 0 && this.founded) { throw "Cannot set development count to 0; use dissolve instead."; } + this.setStored("Dev", value); + } - //stored variables - get founded() { return this.getStored('') == 1; } - get foundedDate() { return this.getStored('Founded');} - get developmentCount() { return this.getStored("Dev"); } - set developmentCount(value) { - if(value < 0) throw "Cannot set development count to less than 0"; - //dissolve is the only function that sets founded to false. - if(value == 0 && this.founded) throw "Cannot set development count to 0; use dissolve instead."; - this.setStored("Dev", value); - } - - //calculated - get availableRoom() { return Math.max(0, this.developmentCount - this.activeSlaves); } - get maintenanceCost() { - return Math.trunc( this._const.maintenance.linear * 1000 * this.developmentCount + //calculated + get availableRoom() { return Math.max(0, this.developmentCount - this.activeSlaves); } + get maintenanceCost() { + return Math.trunc( this._const.maintenance.linear * 1000 * this.developmentCount + this._const.maintenance.quadratic * Math.pow(this.activeSlaves, 2)); - } - get foundingCostDivision() { return this._const.founding.size * this.sizeCost; } - get foundingCost() { return this.foundingCostDivision; } - get canFoundCorporation() { return this._const.founding != null; } - get foundingCash() { - if(!this.canFoundCorporation) throw `${this.name} is not set up found a corporation` - return 1000 * this._const.founding.startingPrice; - } - get value() { - const developmentValue = this.developmentCount * this.sizeCost * 800; - let slaveProcValue = 0; - let slaveHeldValue = 0; + } + get foundingCostDivision() { return this._const.founding.size * this.sizeCost; } + get foundingCost() { return this.foundingCostDivision; } + get canFoundCorporation() { return this._const.founding != null; } + get foundingCash() { + if (!this.canFoundCorporation) { throw `${this.name} is not set up found a corporation`; } + return 1000 * this._const.founding.startingPrice; + } + get value() { + const developmentValue = this.developmentCount * this.sizeCost * 800; + let slaveProcValue = 0; + let slaveHeldValue = 0; - if(this.activeSlaves > 0) - slaveProcValue = this.activeSlaves * this.purchasedSlaveValue * 1000; - if(this.heldSlaves > 0) - slaveHeldValue = this.heldSlaves * this.soldSlaveValue * 1000; + if (this.activeSlaves > 0) { slaveProcValue = this.activeSlaves * this.purchasedSlaveValue * 1000; } + if (this.heldSlaves > 0) { slaveHeldValue = this.heldSlaves * this.soldSlaveValue * 1000; } - return developmentValue + slaveProcValue + slaveHeldValue; - } + return developmentValue + slaveProcValue + slaveHeldValue; + } - //abstract virtual - get fromMarket() { throw "Must be defined"; } - get toMarket() { throw "Must be defined"; } - get heldSlaves() { throw "Must be defined"; } - set heldSlaves(value) { throw "Must be defined"; } - get activeSlaves() { throw "Must be defined"; } - set activeSlaves(value) { throw "Must be defined"; } - get processRate() { throw "Must be defined"; } - get initialSlaveValue() { throw "Must be defined"; } - get soldSlaveValue() { throw "Must be defined"; } - get slaveAction() { throw "Must be defined"; } - get nounFinishedSlave() { throw "Must be defined"; } - get nounSlaveFromMarket() { throw "Must be defined"; } - messageSlaveCount() { throw "Must be defined"; } - messageSlaveOutput() { throw "Must be defined"; } - message_endWeek_Slaves(divLedger) { throw "Must be defined"; } - endWeek_Slaves(ledger, divLedger) { throw "Must be defined"; } + //abstract virtual + get fromMarket() { throw "Must be defined"; } + get toMarket() { throw "Must be defined"; } + get heldSlaves() { throw "Must be defined"; } + set heldSlaves(value) { throw "Must be defined"; } + get activeSlaves() { throw "Must be defined"; } + set activeSlaves(value) { throw "Must be defined"; } + get processRate() { throw "Must be defined"; } + get initialSlaveValue() { throw "Must be defined"; } + get soldSlaveValue() { throw "Must be defined"; } + get slaveAction() { throw "Must be defined"; } + get nounFinishedSlave() { throw "Must be defined"; } + get nounSlaveFromMarket() { throw "Must be defined"; } + messageSlaveCount() { throw "Must be defined"; } + messageSlaveOutput() { throw "Must be defined"; } + message_endWeek_Slaves(divLedger) { throw "Must be defined"; } + endWeek_Slaves(ledger, divLedger) { throw "Must be defined"; } - //The value of a slave ignoring enhancements from founded divisions - //The actual value of a slave after all improvements - get purchasedSlaveValue() { - let cheapest = { 'value':Number.MAX_VALUE, 'div': null}; - let expensive = { 'value': 0 , 'div': null}; - for(let fromDiv of this.relatedDivisions.from) { - let initialValue = fromDiv.initialSlaveValue; - if(initialValue < cheapest.value) { - cheapest.value = initialValue; - cheapest.div = fromDiv; - } - if(fromDiv.founded) { - let soldValue = fromDiv.soldSlaveValue; - if(soldValue > expensive.value) { - expensive.value = soldValue; - expensive.div = fromDiv; - } - } - } - if(expensive.div != null && expensive.value != cheapest.value) { - //The added value of an owned intermediary takes time to work its way through this division to the next - let expensiveDiv = expensive.div; - let valueDiff = expensive.value - cheapest.value; - let weeksSinceFounding = V.week - (expensiveDiv.foundedDate || 0); - let weeksToProcess = 10 * expensiveDiv.processRate; - let multiplier = Math.min(weeksSinceFounding / weeksToProcess, 1); - let finalAddedValue = valueDiff * multiplier; - return cheapest.value + finalAddedValue; - } - else if(cheapest.div != null) { - return cheapest.value; - } - throw "No route to acquisition found."; - } - get maintenanceSlaves() { return this.activeSlaves * this.processRate; } - getDisplayMaintenanceCost() { - const cost = this.maintenanceCost; - const processedCount = this.maintenanceSlaves; + //The value of a slave ignoring enhancements from founded divisions + //The actual value of a slave after all improvements + get purchasedSlaveValue() { + let cheapest = {'value': Number.MAX_VALUE, 'div': null}; + let expensive = {'value': 0, 'div': null}; + for (let fromDiv of this.relatedDivisions.from) { + let initialValue = fromDiv.initialSlaveValue; + if (initialValue < cheapest.value) { + cheapest.value = initialValue; + cheapest.div = fromDiv; + } + if (fromDiv.founded) { + let soldValue = fromDiv.soldSlaveValue; + if (soldValue > expensive.value) { + expensive.value = soldValue; + expensive.div = fromDiv; + } + } + } + if (expensive.div != null && expensive.value != cheapest.value) { + //The added value of an owned intermediary takes time to work its way through this division to the next + let expensiveDiv = expensive.div; + let valueDiff = expensive.value - cheapest.value; + let weeksSinceFounding = V.week - (expensiveDiv.foundedDate || 0); + let weeksToProcess = 10 * expensiveDiv.processRate; + let multiplier = Math.min(weeksSinceFounding / weeksToProcess, 1); + let finalAddedValue = valueDiff * multiplier; + return cheapest.value + finalAddedValue; + } else if (cheapest.div != null) { + return cheapest.value; + } + throw "No route to acquisition found."; + } + get maintenanceSlaves() { return this.activeSlaves * this.processRate; } + getDisplayMaintenanceCost() { + const cost = this.maintenanceCost; + const processedCount = this.maintenanceSlaves; - return { cost, perUnit: cost / processedCount }; - } - getAutoSendToDivision(division) { - return !App.Corporate.ownsIntermediaryDivision(this, division) + return {cost, perUnit: cost / processedCount}; + } + getAutoSendToDivision(division) { + return !App.Corporate.ownsIntermediaryDivision(this, division) && this.getStored(`To${division.id}`) == 1; - } - setAutoSendToDivision(division, value) { - this.setStored(`To${division.id}`, value ? 1 : 0); - } - getAutoSendToMarket() { - return this.getStored("ToMarket") == 1; - } - setAutoSendToMarket(value) { - this.setStored("ToMarket", value ? 1 : 0); - } - getAutoBuyFromMarket() { - return this.getStored("FromMarket"); - } - setAutoBuyFromMarket(value) { - this.setStored("FromMarket", value ? 1 : 0); - } - endweek_Revenue(divLedger) { - //Unless otherwise specified, divisions don't produce revenue directly. - } - endWeek_Transfer(divLedger) { - let transferRetval = { total:0 }; - let divisions = []; - for(let otherDiv of this.relatedDivisions.to.filter(div=> div.founded && this.getAutoSendToDivision(div))) { - const otherLedger = divLedger.weekLedger.getDivision(otherDiv); - - const room = otherDiv.availableRoom - otherLedger.transfer.in; - if(room == 0) continue; - divisions.push({division: otherDiv, room}); - } - const fillDivisions = evenFillArray(divisions, this.heldSlaves, pair=>pair.room); - for(const filled of fillDivisions) { - const division = filled.item.division; - const value = filled.value; - divLedger.transfer.addDivision(division, value); - } + } + setAutoSendToDivision(division, value) { + this.setStored(`To${division.id}`, value ? 1 : 0); + } + getAutoSendToMarket() { + return this.getStored("ToMarket") == 1; + } + setAutoSendToMarket(value) { + this.setStored("ToMarket", value ? 1 : 0); + } + getAutoBuyFromMarket() { + return this.getStored("FromMarket"); + } + setAutoBuyFromMarket(value) { + this.setStored("FromMarket", value ? 1 : 0); + } + endweek_Revenue(divLedger) { + //Unless otherwise specified, divisions don't produce revenue directly. + } + endWeek_Transfer(divLedger) { + let transferRetval = {total: 0}; + let divisions = []; + for (let otherDiv of this.relatedDivisions.to.filter(div=> div.founded && this.getAutoSendToDivision(div))) { + const otherLedger = divLedger.weekLedger.getDivision(otherDiv); - } - endWeek_Market(divLedger) { - if(this.getAutoSendToMarket()) { - divLedger.market.sell = this.heldSlaves - divLedger.transfer.total; - } - if(this.getAutoBuyFromMarket()) { - divLedger.market.buy = this.availableRoom - divLedger.transfer.in; - } - shared.SellUnhousedSlaves(this, divLedger, this.processRate); - } + const room = otherDiv.availableRoom - otherLedger.transfer.in; + if (room == 0) { continue; } + divisions.push({division: otherDiv, room}); + } + const fillDivisions = evenFillArray(divisions, this.heldSlaves, pair=>pair.room); + for (const filled of fillDivisions) { + const division = filled.item.division; + const value = filled.value; + divLedger.transfer.addDivision(division, value); + } + } + endWeek_Market(divLedger) { + if (this.getAutoSendToMarket()) { + divLedger.market.sell = this.heldSlaves - divLedger.transfer.total; + } + if (this.getAutoBuyFromMarket()) { + divLedger.market.buy = this.availableRoom - divLedger.transfer.in; + } + shared.SellUnhousedSlaves(this, divLedger, this.processRate); + } - create() { - if(this.founded) throw `${this.name} has already been founded.`; + create() { + if (this.founded) { throw `${this.name} has already been founded.`; } - App.Corporate.expandedDivision(); - App.Corporate.chargeAsset(this.foundingCostDivision * 1000, "development"); - this.setStored('', 1); - this.developmentCount = this._const.founding.size; - this.setStored('Founded', V.week); - } - dissolve() { - this.setStored('', 0); - App.Corporate.sellDevelopment(this); - App.Corporate.dissolvedDivision(); - this.relatedDivisions.to.forEach(nextDep => delete V[`${this._const.corpId}To${nextDep.id}`]); - } + App.Corporate.expandedDivision(); + App.Corporate.chargeAsset(this.foundingCostDivision * 1000, "development"); + this.setStored('', 1); + this.developmentCount = this._const.founding.size; + this.setStored('Founded', V.week); + } + dissolve() { + this.setStored('', 0); + App.Corporate.sellDevelopment(this); + App.Corporate.dissolvedDivision(); + this.relatedDivisions.to.forEach(nextDep => delete V[`${this._const.corpId}To${nextDep.id}`]); + } - //private helpers - getStored(key ) { return V[this._const.corpId + key]; } - setStored(key, value) { V[this._const.corpId + key] = value; } - }; -} + //private helpers + getStored(key ) { return V[this._const.corpId + key]; } + setStored(key, value) { V[this._const.corpId + key] = value; } + }; +}; diff --git a/src/Corporation/corporate-divisionProcessing.js b/src/Corporation/corporate-divisionProcessing.js index a5870ac1cb2..9d866b833f3 100644 --- a/src/Corporation/corporate-divisionProcessing.js +++ b/src/Corporation/corporate-divisionProcessing.js @@ -1,93 +1,90 @@ App.Corporate.Init_DivisionProcessing = function(shared) { + App.Corporate.Division.Processing = class extends App.Corporate.Division.Base { + constructor({founding, addedValue, processing, nextDivision, slaveProcessType, slaveProcessDescription}) { + super(arguments[0]); + this._const.addedValue = addedValue; + this._const.processing = new averageRange(processing); + this._const.nextDivisions = nextDivision; + this._const.slaveProcessType = slaveProcessType; + this._const.slaveProcessDescription = slaveProcessDescription; + } - App.Corporate.Division.Processing = class extends App.Corporate.Division.Base { - constructor({founding, addedValue, processing, nextDivision, slaveProcessType, slaveProcessDescription}) { - super(arguments[0]); - this._const.addedValue = addedValue; - this._const.processing = new averageRange(processing); - this._const.nextDivisions = nextDivision; - this._const.slaveProcessType = slaveProcessType; - this._const.slaveProcessDescription = slaveProcessDescription; - } + //abstract virtual definitions + get fromMarket() { return true; } + get toMarket() { return true; } + get heldSlaves() { return this.getStored("Slaves2" ); } + set heldSlaves(value) { this.setStored("Slaves2", Math.trunc(value)); } + get activeSlaves() { return this.getStored("Slaves" ); } + set activeSlaves(value) { this.setStored("Slaves", Math.trunc(value)); } + get processRate() { return this._const.processing.center; } + get soldSlaveValue() { + //TODO: find a way to cache this. + return this.purchasedSlaveValue + this._const.addedValue; + } + get slaveAction() { + return this._const.slaveProcessDescription; + } + get nounFinishedSlave() { return `${this._const.slaveProcessDescription.past} slave`; } + get nounSlaveFromMarket() { return this._const.slaveProcessDescription.market; } + messageSlaveCount() { + return shared.MessageProcessedSlaves(this, `can ${this._const.slaveProcessType.present}`, 'green'); + } + messageSlaveOutput() { + return shared.MessageSlaveToMarket(this); + } + message_endWeek_Slaves(divLedger) { + let newSlaves = divLedger.slaves.value; + //The division + let retval = this._const.slaveProcessType.past; //exploited + if (newSlaves <= 0) { + retval += " <span class='red'>none of its slaves</span>"; + } else { + retval += ` <span class="green">${numberWithPlural(newSlaves, 'slave')}</span>`; + } + retval += ". The division "; + if (this.activeSlaves) { + retval += `is still ${this._const.slaveProcessDescription.present} ${numberWithPlural(this.activeSlaves, "slave")}`; + } else { + retval += `doesn't have any slaves to ${this._const.slaveProcessDescription.future}`; + } + return retval; + } + endWeek_Slaves(divLedger) { + let slaves = shared.EndWeekProcessing_Slaves(this.activeSlaves, this._const.processing); + this.activeSlaves -= slaves.value; + this.heldSlaves += slaves.value; + return divLedger.slaves.apply(slaves); + } + get initialSlaveValue() { + const values = this.relatedDivisions.from + .map(fromDiv => fromDiv.initialSlaveValue); + if (values.length === 0) { throw "No route to acquisition found."; } + return Math.min(...values) + this._const.addedValue; + } + //virtual override + get nextDivisions() { return this._const.nextDivisions; } + get developmentCount() { return super.developmentCount; } + set developmentCount(value) { + super.developmentCount = value; + shared.SellOverflowSlaves(this); + } + dissolve() { + App.Corporate.sellSlaves(this, this.heldSlaves); + super.dissolve(); + delete V[this._const.corpId + "Slaves"]; + delete V[this._const.corpId + "Slaves2"]; + } - //abstract virtual definitions - get fromMarket() { return true; } - get toMarket() { return true; } - get heldSlaves() { return this.getStored("Slaves2" ); } - set heldSlaves(value) { this.setStored("Slaves2", Math.trunc(value)); } - get activeSlaves() { return this.getStored("Slaves" ); } - set activeSlaves(value) { this.setStored("Slaves" , Math.trunc(value)); } - get processRate() { return this._const.processing.center; } - get soldSlaveValue() { - //TODO: find a way to cache this. - return this.purchasedSlaveValue + this._const.addedValue; - } - get slaveAction() { - return this._const.slaveProcessDescription; - } - get nounFinishedSlave() { return `${this._const.slaveProcessDescription.past} slave`; } - get nounSlaveFromMarket() { return this._const.slaveProcessDescription.market; } - messageSlaveCount() { - return shared.MessageProcessedSlaves(this, `can ${this._const.slaveProcessType.present}`, 'green'); - } - messageSlaveOutput() { - return shared.MessageSlaveToMarket(this); - } - message_endWeek_Slaves(divLedger) { - let newSlaves = divLedger.slaves.value; - //The division - let retval = this._const.slaveProcessType.past; //exploited - if(newSlaves <= 0) { - retval += " <span class='red'>none of its slaves</span>"; - } - else { - retval += ` <span class="green">${numberWithPlural(newSlaves, 'slave')}</span>`; - } - retval += ". The division "; - if(this.activeSlaves) { - retval += `is still ${this._const.slaveProcessDescription.present} ${numberWithPlural(this.activeSlaves, "slave")}`; - } - else { - retval += `doesn't have any slaves to ${this._const.slaveProcessDescription.future}`; - } - return retval; - } - endWeek_Slaves(divLedger) { - let slaves = shared.EndWeekProcessing_Slaves(this.activeSlaves, this._const.processing); - this.activeSlaves -= slaves.value; - this.heldSlaves += slaves.value; - return divLedger.slaves.apply(slaves); - } - get initialSlaveValue() { - const values = this.relatedDivisions.from - .map(fromDiv => fromDiv.initialSlaveValue); - if(values.length == 0) throw "No route to acquisition found."; - return Math.min(...values) + this._const.addedValue; - } - //virtual override - get nextDivisions() { return this._const.nextDivisions; } - get developmentCount() { return super.developmentCount; } - set developmentCount(value) { - super.developmentCount = value; - shared.SellOverflowSlaves(this); - } - dissolve() { - App.Corporate.sellSlaves(this, this.heldSlaves); - super.dissolve(); - delete V[this._const.corpId + "Slaves"]; - delete V[this._const.corpId + "Slaves2"]; - } - - get foundingCostSlaves() { return this._const.founding.size * this.purchasedSlaveValue; } - get foundingCost() { return this.foundingCostDivision + this.foundingCostSlaves; } - create() { - super.create(); - App.Corporate.chargeAsset(this.foundingCostSlaves * 1000, "slaves"); - this.activeSlaves = this._const.founding.size; - this.heldSlaves = 0; - shared.FoundingSetupAutoBuy(this); - shared.FoundingSetupAutoSell(this); - } - }; -} + get foundingCostSlaves() { return this._const.founding.size * this.purchasedSlaveValue; } + get foundingCost() { return this.foundingCostDivision + this.foundingCostSlaves; } + create() { + super.create(); + App.Corporate.chargeAsset(this.foundingCostSlaves * 1000, "slaves"); + this.activeSlaves = this._const.founding.size; + this.heldSlaves = 0; + shared.FoundingSetupAutoBuy(this); + shared.FoundingSetupAutoSell(this); + } + }; +}; diff --git a/src/Corporation/corporate-divisionWorking.js b/src/Corporation/corporate-divisionWorking.js index 1cbd33e232a..f9b763d1d48 100644 --- a/src/Corporation/corporate-divisionWorking.js +++ b/src/Corporation/corporate-divisionWorking.js @@ -1,95 +1,93 @@ App.Corporate.Init_DivisionWorking = function(shared) { + App.Corporate.Division.Working = class extends App.Corporate.Division.Base { + constructor({founding, attrition, revenue, slaveWorkDescription}) { + super(arguments[0]); + this._const.attrition = new averageRange(attrition); + this._const.revenue = new averageRange(revenue); + this._const.slaveWorkDescription = slaveWorkDescription; + } - App.Corporate.Division.Working = class extends App.Corporate.Division.Base { - constructor({founding, attrition, revenue, slaveWorkDescription}) { - super(arguments[0]); - this._const.attrition = new averageRange(attrition); - this._const.revenue = new averageRange(revenue); - this._const.slaveWorkDescription = slaveWorkDescription; - } + //abstract virtual definitions + get fromMarket() { return true; } + get toMarket() { return false; } + get heldSlaves() { return 0; } + set heldSlaves(value) { throw "Cannot set held slaves of working division"; } + get activeSlaves() { return this.getStored("Slaves"); } + set activeSlaves(value) { this.setStored("Slaves", Math.trunc(value)); } + get processRate() { return this._const.attrition.center; } + get initialSlaveValue() { return null; } + get soldSlaveValue() { return null; } + get slaveAction() { + return this._const.slaveWorkDescription; + } + get nounFinishedSlave() { throw "Cannot get finished slave in working division, since they don't produce finished slaves."; } + get nounSlaveFromMarket() { return this._const.slaveWorkDescription.market; } + messageSlaveCount() { + return shared.MessageProcessedSlaves(this, `has to replace`, 'red'); + } + messageSlaveOutput() { + /* TODO: originally some divisions had a slight description for what the work was; ie, "the escorts generate" */ + return `The division generates <span class="yellowgreen">${cashFormat(this.slaveRevenue)}</span> per slave on average.`; + } + endWeek_Slaves(divLedger) { + let slaves = shared.EndWeekProcessing_Slaves(this.activeSlaves, this._const.attrition); + this.activeSlaves -= slaves.value; + return divLedger.slaves.apply(slaves); + } + message_endWeek_Slaves(divLedger) { + let lostSlaves = divLedger.slaves.value; + let retval = '';//The division + if (this.activeSlaves <= 0) { + retval += `has <span class="red">no slaves</span> to ${this._const.slaveWorkDescription.future}`; + } else { + retval += `is ${this._const.slaveWorkDescription.present} <span class="green">${numberWithPlural(this.activeSlaves, 'slave')}</span>`; + } + if (lostSlaves > 0) { + retval += `. During operations <span class="red">${numberWithPlural(lostSlaves, 'slave')}</span> ${this._const.slaveWorkDescription.past}`; + } + return retval; + } - //abstract virtual definitions - get fromMarket() { return true; } - get toMarket() { return false; } - get heldSlaves() { return 0; } - set heldSlaves(value) { throw "Cannot set held slaves of working division"; } - get activeSlaves() { return this.getStored("Slaves"); } - set activeSlaves(value) { this.setStored("Slaves", Math.trunc(value)); } - get processRate() { return this._const.attrition.center; } - get initialSlaveValue() { return null; } - get soldSlaveValue() { return null; } - get slaveAction() { - return this._const.slaveWorkDescription; - } - get nounFinishedSlave() { throw "Cannot get finished slave in working division, since they don't produce finished slaves."; } - get nounSlaveFromMarket() { return this._const.slaveWorkDescription.market; } - messageSlaveCount() { - return shared.MessageProcessedSlaves(this, `has to replace`, 'red'); - } - messageSlaveOutput() { - /* TODO: originally some divisions had a slight description for what the work was; ie, "the escorts generate" */ - return `The division generates <span class="yellowgreen">${cashFormat(this.slaveRevenue)}</span> per slave on average.`; - } - endWeek_Slaves(divLedger) { - let slaves = shared.EndWeekProcessing_Slaves(this.activeSlaves, this._const.attrition); - this.activeSlaves -= slaves.value; - return divLedger.slaves.apply(slaves); - } - message_endWeek_Slaves(divLedger) { - let lostSlaves = divLedger.slaves.value; - let retval = '';//The division - if(this.activeSlaves <= 0) { - retval += `has <span class="red">no slaves</span> to ${this._const.slaveWorkDescription.future}`; - } - else { - retval += `is ${this._const.slaveWorkDescription.present} <span class="green">${numberWithPlural(this.activeSlaves, 'slave')}</span>`; - } - if(lostSlaves > 0) { - retval += `. During operations <span class="red">${numberWithPlural(lostSlaves, 'slave')}</span> ${this._const.slaveWorkDescription.past}`; - } - return retval; - } + //virtual override + get developmentCount() { return super.developmentCount; } + set developmentCount(value) { + super.developmentCount = value; + shared.SellOverflowSlaves(this); + } + dissolve() { + super.dissolve(); + delete V[this._const.corpId + "Slaves"]; + } + getAutoSendToMarket() { + return false; + } + setAutoSendToMarket(value) { + throw "Working divisions cannot sell to market"; + } + endweek_Revenue(divLedger) { + let {roll, value} = this._const.revenue.roll(); + let revenue = Math.trunc(this.activeSlaves * value); + divLedger.revenue.apply({value: revenue, efficiency: roll}); + } + endWeek_Transfer(divLedger) { + //Working divisions don't do transfers + } - //virtual override - get developmentCount() { return super.developmentCount; } - set developmentCount(value) { - super.developmentCount = value; - shared.SellOverflowSlaves(this); - } - dissolve() { - super.dissolve(); - delete V[this._const.corpId + "Slaves"]; - } - getAutoSendToMarket() { - return false; - } - setAutoSendToMarket(value) { - throw "Working divisions cannot sell to market"; - } - endweek_Revenue(divLedger) { - let {roll, value} = this._const.revenue.roll(); - let revenue = Math.trunc(this.activeSlaves * value); - divLedger.revenue.apply({value: revenue, efficiency: roll }); - } - endWeek_Transfer(divLedger) { - //Working divisions don't do transfers - } + get slaveRevenue() { + return this._const.revenue.center; + } + get maintenanceSlaves() { + //maintenance is paid on working slaves, not worked slaves. + return this.activeSlaves; + } - get slaveRevenue() { - return this._const.revenue.center; - } - get maintenanceSlaves() { - //maintenance is paid on working slaves, not worked slaves. - return this.activeSlaves; - } - - get foundingCostSlaves() { return this._const.founding.size * this.purchasedSlaveValue; } - get foundingCost() { return this.foundingCostDivision + this.foundingCostSlaves; } - create() { - super.create(); - App.Corporate.chargeAsset(this.foundingCostSlaves * 1000, "slaves"); - this.activeSlaves = this._const.founding.size; - shared.FoundingSetupAutoBuy(this); - } - }; -} + get foundingCostSlaves() { return this._const.founding.size * this.purchasedSlaveValue; } + get foundingCost() { return this.foundingCostDivision + this.foundingCostSlaves; } + create() { + super.create(); + App.Corporate.chargeAsset(this.foundingCostSlaves * 1000, "slaves"); + this.activeSlaves = this._const.founding.size; + shared.FoundingSetupAutoBuy(this); + } + }; +}; diff --git a/src/Corporation/corporate.js b/src/Corporation/corporate.js index 8171f2489c5..c45f21fc683 100644 --- a/src/Corporation/corporate.js +++ b/src/Corporation/corporate.js @@ -1,924 +1,917 @@ window.averageRange = class { - constructor({center, range}) { - this._const = { - center, - range - }; - } - get center() { return this._const.center; } - get range() { return this._const.range; } - roll() { - let roll = Math.clamp(gaussianPair(0, 0.2)[0], -0.5, 0.5); - return { roll, value: (roll * this.range) + this.center}; - } - rollInt() { - let retval = this.roll(); - retval.value = Math.trunc(retval.value); - return retval; - } -} + constructor({center, range}) { + this._const = { + center, + range + }; + } + get center() { return this._const.center; } + get range() { return this._const.range; } + roll() { + let roll = Math.clamp(gaussianPair(0, 0.2)[0], -0.5, 0.5); + return {roll, value: (roll * this.range) + this.center}; + } + rollInt() { + let retval = this.roll(); + retval.value = Math.trunc(retval.value); + return retval; + } +}; window.evenFillArray = function(array, amount, lookupAmount) { - let perItem, changed; - let retval = []; - do { - let newArray = []; - changed = false; - perItem = Math.trunc(amount / array.length); - for(let item of array) { - let itemValue = lookupAmount(item); - if(itemValue >= perItem) { - newArray.push(item); - continue; - } - - amount -= itemValue; - retval.push({item, value:itemValue}); - changed = true; - } - array = newArray; - } while (changed); - let remainder = amount % array.length; - for(let item of array) { - let extra = 0; - if(remainder > 0) { - remainder--; - extra = 1; - } - retval.push({item, value: perItem + extra }); - } - return retval; -} + let perItem, changed; + let retval = []; + do { + let newArray = []; + changed = false; + perItem = Math.trunc(amount / array.length); + for (let item of array) { + let itemValue = lookupAmount(item); + if (itemValue >= perItem) { + newArray.push(item); + continue; + } + + amount -= itemValue; + retval.push({item, value: itemValue}); + changed = true; + } + array = newArray; + } while (changed); + let remainder = amount % array.length; + for (let item of array) { + let extra = 0; + if (remainder > 0) { + remainder--; + extra = 1; + } + retval.push({item, value: perItem + extra}); + } + return retval; +}; window.typeHiddenMembers = class { - constructor() { - this._const = {}; - this._var = {}; - this._cache = {}; - } -} + constructor() { + this._const = {}; + this._var = {}; + this._cache = {}; + } +}; App.Corporate.Init = function() { - const Ledger = class { - constructor(corp, suffix="") { - this.corp = corp; - this.suffix = suffix; - this.clear(); - } - get operations( ) { return this.getStored('OpCost' ); } - set operations(value) { return this.setStored('OpCost' , value); } - - get localRevenue( ) { return this.getStored('Rev' ); } - set localRevenue(value) { return this.setStored('Rev' , value); } - - get development( ) { return this.getStored('AssetsDev' ); } - set development(value) { return this.setStored('AssetsDev' , value); } - - get slaves( ) { return this.getStored('AssetsSlave' ); } - set slaves(value) { return this.setStored('AssetsSlave' , value); } - - get overhead( ) { return this.getStored('Overhead' ); } - set overhead(value) { return this.setStored('Overhead' , value); } - - get economicBoost( ) { return this.getStored('EconBonus' ); } - set economicBoost(value) { return this.setStored('EconBonus' , value); } - - get economy( ) { return this.getStored('Econ' ); } - set economy(value) { return this.setStored('Econ' , value); } - - get foreignRevenue( ) { return this.getStored('NeighborBonus' ); } - set foreignRevenue(value) { return this.setStored('NeighborBonus', value); } - - copy(ledger) { - this.operations = ledger.operations; - this.localRevenue = ledger.localRevenue; - this.foreignRevenue = ledger.foreignRevenue; - this.development = ledger.development; - this.slaves = ledger.slaves; - this.overhead = ledger.overhead; - this.economicBoost = ledger.economicBoost; - this.economy = ledger.economy; - } - clear() { - this.operations = 0; - this.localRevenue = 0; - this.foreignRevenue = 0; - this.development = 0; - this.slaves = 0; - this.overhead = 0; - this.economicBoost = 0; - this.economy = 0; - } - release() { - this.deleteStored('OpCost'); - this.deleteStored('Rev'); - this.deleteStored('AssetsDev'); - this.deleteStored('AssetsSlave'); - this.deleteStored('Overhead'); - this.deleteStored('EconBonus'); - this.deleteStored('Econ'); - this.deleteStored('NeighborBonus'); - } - get profit() { - return this.revenue + this.economicBoost + const Ledger = class { + constructor(corp, suffix="") { + this.corp = corp; + this.suffix = suffix; + this.clear(); + } + get operations( ) { return this.getStored('OpCost' ); } + set operations(value) { return this.setStored('OpCost', value); } + + get localRevenue( ) { return this.getStored('Rev' ); } + set localRevenue(value) { return this.setStored('Rev', value); } + + get development( ) { return this.getStored('AssetsDev' ); } + set development(value) { return this.setStored('AssetsDev', value); } + + get slaves( ) { return this.getStored('AssetsSlave' ); } + set slaves(value) { return this.setStored('AssetsSlave', value); } + + get overhead( ) { return this.getStored('Overhead' ); } + set overhead(value) { return this.setStored('Overhead', value); } + + get economicBoost( ) { return this.getStored('EconBonus' ); } + set economicBoost(value) { return this.setStored('EconBonus', value); } + + get economy( ) { return this.getStored('Econ' ); } + set economy(value) { return this.setStored('Econ', value); } + + get foreignRevenue( ) { return this.getStored('NeighborBonus' ); } + set foreignRevenue(value) { return this.setStored('NeighborBonus', value); } + + copy(ledger) { + this.operations = ledger.operations; + this.localRevenue = ledger.localRevenue; + this.foreignRevenue = ledger.foreignRevenue; + this.development = ledger.development; + this.slaves = ledger.slaves; + this.overhead = ledger.overhead; + this.economicBoost = ledger.economicBoost; + this.economy = ledger.economy; + } + clear() { + this.operations = 0; + this.localRevenue = 0; + this.foreignRevenue = 0; + this.development = 0; + this.slaves = 0; + this.overhead = 0; + this.economicBoost = 0; + this.economy = 0; + } + release() { + this.deleteStored('OpCost'); + this.deleteStored('Rev'); + this.deleteStored('AssetsDev'); + this.deleteStored('AssetsSlave'); + this.deleteStored('Overhead'); + this.deleteStored('EconBonus'); + this.deleteStored('Econ'); + this.deleteStored('NeighborBonus'); + } + get profit() { + return this.revenue + this.economicBoost - this.development - this.slaves - this.overhead - this.operations; - } - get revenue() { - return this.localRevenue + this.foreignRevenue; - } - setEconomy(economy) { - this.economy = economy; - - //NOTE: Set economicBoost to 0 so it doesn't affect this.profit! - this.economicBoost = 0; // <-- DO NOT delete - this.economicBoost = Math.trunc(this.profit * (economy - 100) / 100); - } - //private access - getStored(key) { - return this.corp.getStored(key + this.suffix); - } - setStored(key, value) { - return this.corp.setStored(key + this.suffix, value); - } - deleteStored(key){ - this.corp.deleteStored(key + this.suffix); - } - }; - const WeekProcessingEffeciencyLine = class { - constructor() { - this.value = 0; - this.efficiency = 0; - } - apply(pair) { - this.value = pair.value; - this.efficiency = pair.efficiency; - } - }; - const WeekProcessingTransfer = class extends typeHiddenMembers { - constructor(divLedger) { - super(); - this._const.divLedger = divLedger; - this._var.divisions = []; - this._var.in = 0; - this._var.out = 0; - } - addDivision(division, fill) { - const otherLedger = this._const.divLedger.weekLedger.getDivision(division); - - this._var.out += fill; - otherLedger.transfer.in += fill; - - this._var.divisions.push({division, fill}); - } - get in() { - return this._var.in; - } - set in(value) { - if(value == this._var.in) return; - if(this._const.divLedger.market.canBuy) { - this._const.divLedger.market.buy -= value - this._var.in; - } - this._var.in = value; - } - get total() { - return this._var.out; - } - get divisions() { - return this._var.divisions; - } - } - const WeekProcessingMarket = class extends typeHiddenMembers { - constructor(divLedger) { - super(); - - this._const.divLedger = divLedger; - this._var.canBuy = false; - this._var.buy = 0; - this._var.sell = 0; - } - get buy() { - return this._var.buy; - } - set buy(value) { - //Note: canBuy merely means we've set buy to some value, even 0. - //Setting to 0 after setting to another value happens when we tried to buy some number, but couldn't afford it. - this._var.canBuy = true; - this._var.buy = value; - this._cache.buyValue = null; - } - get sell() { - return this._var.sell; - } - set sell(value) { - this._var.sell = value; - this._cache.sellValue = null; - } - get sellValue() { - if(this._cache.sellValue == null) - this._cache.sellValue = App.Corporate.slaveMarketSellValue(this.division, this.sell); - return this._cache.sellValue; - } - get buyValue() { - if(this._cache.buyValue == null) - this._cache.buyValue = App.Corporate.slaveMarketPurchaseValue(this.division, this.buy); - return this._cache.buyValue; - } - get canBuy() { - return this._var.canBuy; - } - - get divisionLedger() { - return this._const.divLedger; - } - get division() { - return this.divisionLedger.division; - } - }; - const WeekProcessingDivision = class extends typeHiddenMembers { - constructor(division, weekLedger) { - super(); - - this._const.division = division; - this._const.ledger = weekLedger; - this._var.slaves = new WeekProcessingEffeciencyLine(); - this._var.revenue = new WeekProcessingEffeciencyLine(); - this._var.transfer = new WeekProcessingTransfer(this); - this._var.market = new WeekProcessingMarket(this); - } - get slaves() { - return this._var.slaves; - } - get revenue() { - return this._var.revenue; - } - get transfer() { - return this._var.transfer; - } - get market() { - return this._var.market; - } - get division() { - return this._const.division; - } - get weekLedger() { - return this._const.ledger; - } - } - const WeekProcessingOverheadCategory = class extends typeHiddenMembers { - constructor(categoryId) { - super(); - - this._const.category = App.Corporate.maintenance.divisionCategories[categoryId]; - if(this._const.category == null) { debugger; throw new "Invalid category id: " + categoryId; } - this._var.divisions = []; - } - addDivision(division) { - this._var.divisions.push(division); - } - get cost() { - const category = this._const.category; - const ownedDivisionCount = this._var.divisions.length - category.freeDivisions; - const developmentCount = this._var.divisions.reduce((r, div) => r + div.developmentCount, 0) - category.freeDevelopment; - - const divisionCost = Math.trunc(Math.pow(Math.max(ownedDivisionCount, 0), 2) * category.divisionCost ); - const developmentCost = Math.trunc(Math.pow(Math.max(developmentCount , 0), 2) * category.developmentCost); - - return divisionCost + developmentCost; - } - }; - const WeekProcessingLedger = class extends typeHiddenMembers { - constructor() { - super(); - - this._var.divisions = {}; - this._var.maintenanceCategories = {}; - this._var.operatingCost = 0; - this._var.canExpandNow = false; - this._var.canSpecializeNow = false; - this._var.dividend = 0; - this._var.payout = 0; - } - - getDivision(division) { - if(!(division.id in this._var.divisions)) { - this._var.divisions[division.id] = new WeekProcessingDivision(division, this); - } - return this._var.divisions[division.id]; - } - get divisionLedgers() { - return this._var.divisions; - } - - registerMaintenanceForDivision(division) { - let categoryId = division.maintenanceCategory; - if(!(categoryId in this._var.maintenanceCategories)) { - this._var.maintenanceCategories[categoryId] = new WeekProcessingOverheadCategory(categoryId); - } - let category = this._var.maintenanceCategories[categoryId]; - category.addDivision(division); - } - get maintenanceCategories() { - return this._var.maintenanceCategories; - } - - get operatingCost() { - return this._var.operatingCost; - } - set operatingCost(value) { - if(!Number.isFinite(value)) { debugger; throw "Operating cost wasn't finite "; } - this._var.operatingCost = Math.trunc(value); - } - get overhead() { - const divCount = App.Corporate.numDivisions; - if(divCount <= 1) return 0; - - const divisionOverhead = Object.values(this.maintenanceCategories).reduce((r, categoryLedger) => r + categoryLedger.cost, 0); - const corpMaintInfo = App.Corporate.maintenance.corporate; - let corpOverhead = Math.pow(Math.max(divCount - corpMaintInfo.freeDivisions, 0), 2) * corpMaintInfo.divisionCost; - let retval = divisionOverhead + corpOverhead; - if(App.Corporate.easyMode) { - retval /= 2; - } - return Math.trunc(retval); - } - get canExpandNow() { return this._var.canExpandNow; } - set canExpandNow(value) { this._var.canExpandNow = value; } - - get hasDividend() { return this._var.dividend > 0; } - get dividend() { return this._var.dividend; } - set dividend(value) { this._var.dividend = value; } - - get hasPayout() { return this._var.payout > 0; } - get payout() { return this._var.payout; } - set payout(value) { this._var.payout = value; } - - get canSpecializeNow() { return this._var.canSpecializeNow; } - set canSpecializeNow(value) { this._var.canSpecializeNow = value; } - } - App.Corporate.Division = {}; - const shared = { - RelatedDivisionType: class { - constructor() { - this._var = { - to: [], - from: [], - all: [] - }; - } - get to() { return this._var.to ; } - get from() { return this._var.from; } - get all() { return this._var.all ; } - addTo(value) { - this._var.to.push(value); - this._var.all.push(value); - } - addFrom(value) { - this._var.from.push(value); - this._var.all.push(value); - } - get anyFounded() { return this.all.some(div=>div.founded); } - }, - FoundingType: class { - constructor(division, {corporateCash, startingSize = 10}) { - this._const = { - division, - cash: corporateCash, - size: startingSize - }; - } - get cash() { return this._const.cash; } - get size() { return this._const.size; } - get startingPrice() { - let div = this._const.division; - return this._const.cash + div.foundingCost; - } - }, - SellOverflowSlaves: function(division) { - const slavesToSell = division.activeSlaves - division.developmentCount; - if(slavesToSell > 0) { - const slaveProcCost = Math.trunc(App.Corporate.slaveMarketPurchaseValue(division, -slavesToSell)); - App.Corporate.chargeAsset(slaveProcCost, "slaves"); - division.activeSlaves -= slavesToSell; - V.menialDemandFactor -= slavesToSell; - } - }, - SellUnhousedSlaves: function(division, divLedger, rate) { - if(divLedger.market.sell != 0) return; - - let housing = 2 * rate * division.developmentCount; - let unhoused = division.heldSlaves - housing; - if(unhoused <= 0) return; - - divLedger.market.sell = unhoused; - }, - MessageProcessedSlaves: function(division, verbPhrase, color) { - let procCount = Math.trunc(division.developmentCount * division.processRate); - let slaveCountedNoun = numberWithPluralNonZero(procCount, "slave"); - - return `It ${verbPhrase} approximately <span class="${color}">${slaveCountedNoun}</span> each week when operating at capacity (${division.developmentCount})`; - }, - MessageSlaveToMarket: function(division) { - return `The slaves from this division can be sold for <span class='yellowgreen'>${cashFormat(Math.trunc(division.soldSlaveValue * menialSlaveCost()))}</span> each.`; - }, - EndWeekProcessing_Slaves: function(processingCount, rate) { - const perDevPair = rate.roll(); - let slaveIncrease = perDevPair.value * processingCount; - if(slaveIncrease < 1) { - slaveIncrease = (slaveIncrease > Math.random() ? 1 : 0); - } - return {efficiency: perDevPair.roll, value: Math.trunc(slaveIncrease) }; - }, - FoundingSetupAutoBuy: function(division) { - let foundedFrom = division.relatedDivisions.from.filter(div=>div.founded); - if(foundedFrom.length == 0) { - division.setAutoBuyFromMarket(true); - } - else { - for(let otherDiv of foundedFrom) { - if(otherDiv.getAutoSendToMarket()) { - otherDiv.setAutoSendToDivision(division, true); - } - } - } - - }, - FoundingSetupAutoSell: function(division) { - let foundedTo = division.relatedDivisions.to.filter(div=>div.founded); - if(foundedTo.length == 0) { - division.setAutoSendToMarket(true); - } - else { - for(let otherDiv of foundedTo) { - if(otherDiv.getAutoBuyFromMarket()) { - division.setAutoSendToDivision(otherDiv, true); - } - } - } - } - }; - App.Corporate.Init_DivisionBase(shared); - App.Corporate.Init_DivisionAcquiring(shared); - App.Corporate.Init_DivisionProcessing(shared); - App.Corporate.Init_DivisionWorking(shared); - - App.Corporate.InitConstants(); - let divisions = App.Corporate.divisions = mapIdList(App.Corporate.divisionList); - App.Corporate.maintenance.divisionCategories = mapIdList(App.Corporate.maintenance.divisionCategoriesList); - - for(const divInfo of App.Corporate.divisionList.filter(div=>div.nextDivisions != null)) { - const div = divisions[divInfo.id]; - for(const nextDepId of divInfo.nextDivisions) { - let nextDiv = divisions[nextDepId]; - div.relatedDivisions.addTo(nextDiv); - nextDiv.relatedDivisions.addFrom(div); - } - } - let asDivision = function(division) { - if(_.isObject(division)) return division; - return App.Corporate.divisions[division]; - } - App.Corporate.getStored = function(key ) { return V[`corp${key}`]; } - App.Corporate.setStored = function(key, value) { V[`corp${key}`] = value; } - App.Corporate.deleteStored = function(key ) { delete V[`corp${key}`]; } - - //Integer properties starting with corp - const propertyToStoryInt = { - cash: "Cash", - numDivisions: 'Div', - foundedDate: 'Founded', - dividend: "Dividend", - specializations: "Spec", - specializationTokens: "SpecToken", - specializationTimer: "SpecTimer", - } - for(const property in propertyToStoryInt) { - const key = propertyToStoryInt[property]; - Object.defineProperty(App.Corporate, property, { - get: function( ) { return this.getStored(key); }, - set: function(value) { - if(!Number.isFinite(value)) throw "Unreal number " + key; - this.setStored(key, Math.trunc(value)); - } - }); - } - - //Boolean properties starting with corp (true == 1, false == 0) - const propertyToStoryBool = { - founded: "Incorporated", - hasMarket: "Market", - payoutCash: "CashDividend", - easyMode: "Easy", - canExpand: 'ExpandToken', - } - for(const property in propertyToStoryBool) { - const key = propertyToStoryBool[property]; - Object.defineProperty(App.Corporate, property, { - get: function( ) { return this.getStored(key) === 1; }, - set: function(value) { this.setStored(key, value == true ? 1 : 0); } - }); - } - - //Abnormal properties - Object.defineProperty(App.Corporate, "value", { - get: function() { - if(!this.founded) return 0; - let corpAssets = App.Corporate.divisionList - .filter(div=>div.founded) - .reduce((v, div)=>v + div.value, 0); - return corpAssets + this.dividend + this.cash; - } - }); - Object.defineProperty(App.Corporate, "dividendRatio", { - get: function( ) { return V.dividendRatio ; }, - set: function(value) { V.dividendRatio = value; } - }); - Object.defineProperty(App.Corporate, "dividendTimer", { - get: function( ) { return V.dividendTimer ; }, - set: function(value) { V.dividendTimer = value; } - }); - Object.defineProperty(App.Corporate, "payoutAfterCash", { - get: function() { - return Math.max(Math.trunc(this.payoutCorpValueMultiplier * this.value), this.payoutMinimumCash); - } - }); - - const SharesType = class { - get personal() { return V.personalShares ; } - set personal(value) { V.personalShares = value; } - get public() { return V.publicShares ; } - set public(value) { V.publicShares = value; } - get total() { return this.personal + this.public; } - }; - App.Corporate.shares = new SharesType(); - App.Corporate.ledger = { - current: new Ledger(App.Corporate), - old: new Ledger(App.Corporate, "Old"), - swap: function() { - this.old.copy(this.current); - this.current.clear(); - }, - clear: function() { - this.old.clear(); - this.current.clear(); - }, - release: function() { - this.old.release(); - this.current.release(); - } - }; - App.Corporate.foundingCostToPlayer = function(division, personalShares, publicShares) { - division = asDivision(division); - let costToPlayer = Math.trunc((division.foundingCash / (personalShares + publicShares)) * personalShares); - return costToPlayer; - } - App.Corporate.create = function(division, personalShares, publicShares) { - this.shares.personal = personalShares; - this.shares.public = publicShares; - V.dividendTimer = 13; - this.founded = true; - this.foundedDate = V.week; - this.dividend = 0; - this.dividendRatio = 0; - this.specializationTimer = 4; - - this.ledger.clear(); - - //this will be updated by division.create - this.numDivisions = 0; - this.expansionTokens = 1; - - division = asDivision(division); - cashX(forceNeg(App.Corporate.foundingCostToPlayer(division, personalShares, publicShares)), 'stocksTraded'); - this.cash = division.foundingCash; - - division.create(this); - App.Corporate.ledger.swap(); - }; - App.Corporate.dissolve = function() { - for(let division of this.divisionList.filter(x=>x.founded)) { - division.dissolve(); - } - this.founded = false; - this.numDivisions = 0; - this.expansionTokens = 0; - this.setStored("Expand", 0); - this.specializations = 0; - this.specializationTokens = 0; - this.setStored("SpecRaces", []); - this.ledger.release(); - - // Some of these will need to be refactored into App.Corporate.Specialization - const toDelete = [ - "corpCash", - "personalShares", - "publicShares", - "corpDividend", - "dividendTimer", - "corpSpecAccent", - "corpSpecAge", - "corpSpecAmputee", - "corpSpecBalls", - "corpSpecDevotion", - "corpSpecDick", - "corpSpecEducation", - "corpSpecGender", - "corpSpecGenitalia", - "corpSpecWeight", - "corpSpecHeight", - "corpSpecHormones", - "corpSpecImplants", - "corpSpecInjection", - "corpSpecIntelligence", - "corpSpecMilk", - "corpSpecMuscle", - "corpSpecPussy", - "corpSpecSexEd", - "corpSpecTrust", - "corpSpecVirgin" - ]; - toDelete.forEach(id => delete V[id]); - - if(this.hasMarket) { - let corporateMarketIndex = V.sectors.findIndex(sector => sector.type === "CorporateMarket"); - V.sectors[corporateMarketIndex].type = "Markets"; - this.hasMarket = false; - } - }; - App.Corporate.expandedDivision = function() { - this.numDivisions += 1; - this.canExpand = false; - }; - App.Corporate.dissolvedDivision = function() { - this.numDivisions -= 1; - }; - App.Corporate.chargeAsset = function(cost, type) { - if(!Number.isFinite(cost)) throw "The cost provided was not a real number"; - cost = Math.trunc(cost); - if(!(type in this.ledger.current)) throw `Ledger doesn't record '${type}' category.`; - if(cost == 0) return; - - this.ledger.current[type] += cost; - this.cash -= cost; - }; - App.Corporate.earnRevenue = function(cost, locality) { - if(!Number.isFinite(cost)) throw "The cost provided was not real"; - cost = Math.trunc(cost); - let current = this.ledger.current; - let key = `${locality}Revenue`; - if(!(key in current)) throw `Unknown locality '${locality}'`; - current[key] += cost; - this.cash += cost; - }; - App.Corporate.chargeDividend = function(cost, weekLedger) { - if(!Number.isFinite(cost)) throw "The cost provided was not real"; - cost = Math.trunc(cost); - if(weekLedger == null) { - debugger; - throw "No weekLedger provided"; - } - this.dividend += cost; - this.cash -= cost; - weekLedger.dividend += cost; - } - App.Corporate.creditEconomy = function() { - this.ledger.current.setEconomy(V.localEcon); - this.cash += this.ledger.current.economicBoost; - } - /* Need to prevent skipping intermediaries if they exist, ie break->surgery->train, you can skip surgery only if you don't have it.*/ - App.Corporate.ownsIntermediaryDivision = function(fromDivision, toDivision) { - for(let intermediateDiv of toDivision.relatedDivisions - .from - .filter(iDep => iDep.id != fromDivision.id + } + get revenue() { + return this.localRevenue + this.foreignRevenue; + } + setEconomy(economy) { + this.economy = economy; + + //NOTE: Set economicBoost to 0 so it doesn't affect this.profit! + this.economicBoost = 0; // <-- DO NOT delete + this.economicBoost = Math.trunc(this.profit * (economy - 100) / 100); + } + //private access + getStored(key) { + return this.corp.getStored(key + this.suffix); + } + setStored(key, value) { + return this.corp.setStored(key + this.suffix, value); + } + deleteStored(key) { + this.corp.deleteStored(key + this.suffix); + } + }; + const WeekProcessingEffeciencyLine = class { + constructor() { + this.value = 0; + this.efficiency = 0; + } + apply(pair) { + this.value = pair.value; + this.efficiency = pair.efficiency; + } + }; + const WeekProcessingTransfer = class extends typeHiddenMembers { + constructor(divLedger) { + super(); + this._const.divLedger = divLedger; + this._var.divisions = []; + this._var.in = 0; + this._var.out = 0; + } + addDivision(division, fill) { + const otherLedger = this._const.divLedger.weekLedger.getDivision(division); + + this._var.out += fill; + otherLedger.transfer.in += fill; + + this._var.divisions.push({division, fill}); + } + get in() { + return this._var.in; + } + set in(value) { + if (value == this._var.in) { return; } + if (this._const.divLedger.market.canBuy) { + this._const.divLedger.market.buy -= value - this._var.in; + } + this._var.in = value; + } + get total() { + return this._var.out; + } + get divisions() { + return this._var.divisions; + } + }; + const WeekProcessingMarket = class extends typeHiddenMembers { + constructor(divLedger) { + super(); + + this._const.divLedger = divLedger; + this._var.canBuy = false; + this._var.buy = 0; + this._var.sell = 0; + } + get buy() { + return this._var.buy; + } + set buy(value) { + //Note: canBuy merely means we've set buy to some value, even 0. + //Setting to 0 after setting to another value happens when we tried to buy some number, but couldn't afford it. + this._var.canBuy = true; + this._var.buy = value; + this._cache.buyValue = null; + } + get sell() { + return this._var.sell; + } + set sell(value) { + this._var.sell = value; + this._cache.sellValue = null; + } + get sellValue() { + if (this._cache.sellValue == null) { + this._cache.sellValue = App.Corporate.slaveMarketSellValue(this.division, this.sell); + } + return this._cache.sellValue; + } + get buyValue() { + if (this._cache.buyValue == null) { + this._cache.buyValue = App.Corporate.slaveMarketPurchaseValue(this.division, this.buy); + } + return this._cache.buyValue; + } + get canBuy() { + return this._var.canBuy; + } + + get divisionLedger() { + return this._const.divLedger; + } + get division() { + return this.divisionLedger.division; + } + }; + const WeekProcessingDivision = class extends typeHiddenMembers { + constructor(division, weekLedger) { + super(); + + this._const.division = division; + this._const.ledger = weekLedger; + this._var.slaves = new WeekProcessingEffeciencyLine(); + this._var.revenue = new WeekProcessingEffeciencyLine(); + this._var.transfer = new WeekProcessingTransfer(this); + this._var.market = new WeekProcessingMarket(this); + } + get slaves() { + return this._var.slaves; + } + get revenue() { + return this._var.revenue; + } + get transfer() { + return this._var.transfer; + } + get market() { + return this._var.market; + } + get division() { + return this._const.division; + } + get weekLedger() { + return this._const.ledger; + } + }; + const WeekProcessingOverheadCategory = class extends typeHiddenMembers { + constructor(categoryId) { + super(); + + this._const.category = App.Corporate.maintenance.divisionCategories[categoryId]; + if (this._const.category == null) { debugger; throw new "Invalid category id: " + categoryId; } + this._var.divisions = []; + } + addDivision(division) { + this._var.divisions.push(division); + } + get cost() { + const category = this._const.category; + const ownedDivisionCount = this._var.divisions.length - category.freeDivisions; + const developmentCount = this._var.divisions.reduce((r, div) => r + div.developmentCount, 0) - category.freeDevelopment; + + const divisionCost = Math.trunc(Math.pow(Math.max(ownedDivisionCount, 0), 2) * category.divisionCost ); + const developmentCost = Math.trunc(Math.pow(Math.max(developmentCount, 0), 2) * category.developmentCost); + + return divisionCost + developmentCost; + } + }; + const WeekProcessingLedger = class extends typeHiddenMembers { + constructor() { + super(); + + this._var.divisions = {}; + this._var.maintenanceCategories = {}; + this._var.operatingCost = 0; + this._var.canExpandNow = false; + this._var.canSpecializeNow = false; + this._var.dividend = 0; + this._var.payout = 0; + } + + getDivision(division) { + if (!(division.id in this._var.divisions)) { + this._var.divisions[division.id] = new WeekProcessingDivision(division, this); + } + return this._var.divisions[division.id]; + } + get divisionLedgers() { + return this._var.divisions; + } + + registerMaintenanceForDivision(division) { + let categoryId = division.maintenanceCategory; + if (!(categoryId in this._var.maintenanceCategories)) { + this._var.maintenanceCategories[categoryId] = new WeekProcessingOverheadCategory(categoryId); + } + let category = this._var.maintenanceCategories[categoryId]; + category.addDivision(division); + } + get maintenanceCategories() { + return this._var.maintenanceCategories; + } + + get operatingCost() { + return this._var.operatingCost; + } + set operatingCost(value) { + if (!Number.isFinite(value)) { debugger; throw "Operating cost wasn't finite "; } + this._var.operatingCost = Math.trunc(value); + } + get overhead() { + const divCount = App.Corporate.numDivisions; + if (divCount <= 1) { return 0; } + + const divisionOverhead = Object.values(this.maintenanceCategories).reduce((r, categoryLedger) => r + categoryLedger.cost, 0); + const corpMaintInfo = App.Corporate.maintenance.corporate; + let corpOverhead = Math.pow(Math.max(divCount - corpMaintInfo.freeDivisions, 0), 2) * corpMaintInfo.divisionCost; + let retval = divisionOverhead + corpOverhead; + if (App.Corporate.easyMode) { + retval /= 2; + } + return Math.trunc(retval); + } + get canExpandNow() { return this._var.canExpandNow; } + set canExpandNow(value) { this._var.canExpandNow = value; } + + get hasDividend() { return this._var.dividend > 0; } + get dividend() { return this._var.dividend; } + set dividend(value) { this._var.dividend = value; } + + get hasPayout() { return this._var.payout > 0; } + get payout() { return this._var.payout; } + set payout(value) { this._var.payout = value; } + + get canSpecializeNow() { return this._var.canSpecializeNow; } + set canSpecializeNow(value) { this._var.canSpecializeNow = value; } + }; + App.Corporate.Division = {}; + const shared = { + RelatedDivisionType: class { + constructor() { + this._var = { + to: [], + from: [], + all: [] + }; + } + get to() { return this._var.to; } + get from() { return this._var.from; } + get all() { return this._var.all; } + addTo(value) { + this._var.to.push(value); + this._var.all.push(value); + } + addFrom(value) { + this._var.from.push(value); + this._var.all.push(value); + } + get anyFounded() { return this.all.some(div=>div.founded); } + }, + FoundingType: class { + constructor(division, {corporateCash, startingSize = 10}) { + this._const = { + division, + cash: corporateCash, + size: startingSize + }; + } + get cash() { return this._const.cash; } + get size() { return this._const.size; } + get startingPrice() { + let div = this._const.division; + return this._const.cash + div.foundingCost; + } + }, + SellOverflowSlaves: function(division) { + const slavesToSell = division.activeSlaves - division.developmentCount; + if (slavesToSell > 0) { + const slaveProcCost = Math.trunc(App.Corporate.slaveMarketPurchaseValue(division, -slavesToSell)); + App.Corporate.chargeAsset(slaveProcCost, "slaves"); + division.activeSlaves -= slavesToSell; + V.menialDemandFactor -= slavesToSell; + } + }, + SellUnhousedSlaves: function(division, divLedger, rate) { + if (divLedger.market.sell != 0) { return; } + + let housing = 2 * rate * division.developmentCount; + let unhoused = division.heldSlaves - housing; + if (unhoused <= 0) { return; } + + divLedger.market.sell = unhoused; + }, + MessageProcessedSlaves: function(division, verbPhrase, color) { + let procCount = Math.trunc(division.developmentCount * division.processRate); + let slaveCountedNoun = numberWithPluralNonZero(procCount, "slave"); + + return `It ${verbPhrase} approximately <span class="${color}">${slaveCountedNoun}</span> each week when operating at capacity (${division.developmentCount})`; + }, + MessageSlaveToMarket: function(division) { + return `The slaves from this division can be sold for <span class='yellowgreen'>${cashFormat(Math.trunc(division.soldSlaveValue * menialSlaveCost()))}</span> each.`; + }, + EndWeekProcessing_Slaves: function(processingCount, rate) { + const perDevPair = rate.roll(); + let slaveIncrease = perDevPair.value * processingCount; + if (slaveIncrease < 1) { + slaveIncrease = (slaveIncrease > Math.random() ? 1 : 0); + } + return {efficiency: perDevPair.roll, value: Math.trunc(slaveIncrease)}; + }, + FoundingSetupAutoBuy: function(division) { + let foundedFrom = division.relatedDivisions.from.filter(div=>div.founded); + if (foundedFrom.length == 0) { + division.setAutoBuyFromMarket(true); + } else { + for (let otherDiv of foundedFrom) { + if (otherDiv.getAutoSendToMarket()) { + otherDiv.setAutoSendToDivision(division, true); + } + } + } + }, + FoundingSetupAutoSell: function(division) { + let foundedTo = division.relatedDivisions.to.filter(div=>div.founded); + if (foundedTo.length == 0) { + division.setAutoSendToMarket(true); + } else { + for (let otherDiv of foundedTo) { + if (otherDiv.getAutoBuyFromMarket()) { + division.setAutoSendToDivision(otherDiv, true); + } + } + } + } + }; + App.Corporate.Init_DivisionBase(shared); + App.Corporate.Init_DivisionAcquiring(shared); + App.Corporate.Init_DivisionProcessing(shared); + App.Corporate.Init_DivisionWorking(shared); + + App.Corporate.InitConstants(); + let divisions = App.Corporate.divisions = mapIdList(App.Corporate.divisionList); + App.Corporate.maintenance.divisionCategories = mapIdList(App.Corporate.maintenance.divisionCategoriesList); + + for (const divInfo of App.Corporate.divisionList.filter(div=>div.nextDivisions != null)) { + const div = divisions[divInfo.id]; + for (const nextDepId of divInfo.nextDivisions) { + let nextDiv = divisions[nextDepId]; + div.relatedDivisions.addTo(nextDiv); + nextDiv.relatedDivisions.addFrom(div); + } + } + let asDivision = function(division) { + if (_.isObject(division)) { return division; } + return App.Corporate.divisions[division]; + }; + App.Corporate.getStored = function(key ) { return V[`corp${key}`]; }; + App.Corporate.setStored = function(key, value) { V[`corp${key}`] = value; }; + App.Corporate.deleteStored = function(key ) { delete V[`corp${key}`]; }; + + //Integer properties starting with corp + const propertyToStoryInt = { + cash: "Cash", + numDivisions: 'Div', + foundedDate: 'Founded', + dividend: "Dividend", + specializations: "Spec", + specializationTokens: "SpecToken", + specializationTimer: "SpecTimer", + }; + for (const property in propertyToStoryInt) { + const key = propertyToStoryInt[property]; + Object.defineProperty(App.Corporate, property, { + get: function( ) { return this.getStored(key); }, + set: function(value) { + if (!Number.isFinite(value)) { throw "Unreal number " + key; } + this.setStored(key, Math.trunc(value)); + } + }); + } + + //Boolean properties starting with corp (true == 1, false == 0) + const propertyToStoryBool = { + founded: "Incorporated", + hasMarket: "Market", + payoutCash: "CashDividend", + easyMode: "Easy", + canExpand: 'ExpandToken', + }; + for (const property in propertyToStoryBool) { + const key = propertyToStoryBool[property]; + Object.defineProperty(App.Corporate, property, { + get: function( ) { return this.getStored(key) === 1; }, + set: function(value) { this.setStored(key, value == true ? 1 : 0); } + }); + } + + //Abnormal properties + Object.defineProperty(App.Corporate, "value", { + get: function() { + if (!this.founded) { return 0; } + let corpAssets = App.Corporate.divisionList + .filter(div=>div.founded) + .reduce((v, div)=>v + div.value, 0); + return corpAssets + this.dividend + this.cash; + } + }); + Object.defineProperty(App.Corporate, "dividendRatio", { + get: function( ) { return V.dividendRatio; }, + set: function(value) { V.dividendRatio = value; } + }); + Object.defineProperty(App.Corporate, "dividendTimer", { + get: function( ) { return V.dividendTimer; }, + set: function(value) { V.dividendTimer = value; } + }); + Object.defineProperty(App.Corporate, "payoutAfterCash", { + get: function() { + return Math.max(Math.trunc(this.payoutCorpValueMultiplier * this.value), this.payoutMinimumCash); + } + }); + + const SharesType = class { + get personal() { return V.personalShares; } + set personal(value) { V.personalShares = value; } + get public() { return V.publicShares; } + set public(value) { V.publicShares = value; } + get total() { return this.personal + this.public; } + }; + App.Corporate.shares = new SharesType(); + App.Corporate.ledger = { + current: new Ledger(App.Corporate), + old: new Ledger(App.Corporate, "Old"), + swap: function() { + this.old.copy(this.current); + this.current.clear(); + }, + clear: function() { + this.old.clear(); + this.current.clear(); + }, + release: function() { + this.old.release(); + this.current.release(); + } + }; + App.Corporate.foundingCostToPlayer = function(division, personalShares, publicShares) { + division = asDivision(division); + let costToPlayer = Math.trunc((division.foundingCash / (personalShares + publicShares)) * personalShares); + return costToPlayer; + }; + App.Corporate.create = function(division, personalShares, publicShares) { + this.shares.personal = personalShares; + this.shares.public = publicShares; + V.dividendTimer = 13; + this.founded = true; + this.foundedDate = V.week; + this.dividend = 0; + this.dividendRatio = 0; + this.specializationTimer = 4; + + this.ledger.clear(); + + //this will be updated by division.create + this.numDivisions = 0; + this.expansionTokens = 1; + + division = asDivision(division); + cashX(forceNeg(App.Corporate.foundingCostToPlayer(division, personalShares, publicShares)), 'stocksTraded'); + this.cash = division.foundingCash; + + division.create(this); + App.Corporate.ledger.swap(); + }; + App.Corporate.dissolve = function() { + for (let division of this.divisionList.filter(x=>x.founded)) { + division.dissolve(); + } + this.founded = false; + this.numDivisions = 0; + this.expansionTokens = 0; + this.setStored("Expand", 0); + this.specializations = 0; + this.specializationTokens = 0; + this.setStored("SpecRaces", []); + this.ledger.release(); + + // Some of these will need to be refactored into App.Corporate.Specialization + const toDelete = [ + "corpCash", + "personalShares", + "publicShares", + "corpDividend", + "dividendTimer", + "corpSpecAccent", + "corpSpecAge", + "corpSpecAmputee", + "corpSpecBalls", + "corpSpecDevotion", + "corpSpecDick", + "corpSpecEducation", + "corpSpecGender", + "corpSpecGenitalia", + "corpSpecWeight", + "corpSpecHeight", + "corpSpecHormones", + "corpSpecImplants", + "corpSpecInjection", + "corpSpecIntelligence", + "corpSpecMilk", + "corpSpecMuscle", + "corpSpecPussy", + "corpSpecSexEd", + "corpSpecTrust", + "corpSpecVirgin" + ]; + toDelete.forEach(id => delete V[id]); + + if (this.hasMarket) { + let corporateMarketIndex = V.sectors.findIndex(sector => sector.type === "CorporateMarket"); + V.sectors[corporateMarketIndex].type = "Markets"; + this.hasMarket = false; + } + }; + App.Corporate.expandedDivision = function() { + this.numDivisions += 1; + this.canExpand = false; + }; + App.Corporate.dissolvedDivision = function() { + this.numDivisions -= 1; + }; + App.Corporate.chargeAsset = function(cost, type) { + if (!Number.isFinite(cost)) { throw "The cost provided was not a real number"; } + cost = Math.trunc(cost); + if (!(type in this.ledger.current)) { throw `Ledger doesn't record '${type}' category.`; } + if (cost == 0) { return; } + + this.ledger.current[type] += cost; + this.cash -= cost; + }; + App.Corporate.earnRevenue = function(cost, locality) { + if (!Number.isFinite(cost)) { throw "The cost provided was not real"; } + cost = Math.trunc(cost); + let current = this.ledger.current; + let key = `${locality}Revenue`; + if (!(key in current)) { throw `Unknown locality '${locality}'`; } + current[key] += cost; + this.cash += cost; + }; + App.Corporate.chargeDividend = function(cost, weekLedger) { + if (!Number.isFinite(cost)) { throw "The cost provided was not real"; } + cost = Math.trunc(cost); + if (weekLedger == null) { + debugger; + throw "No weekLedger provided"; + } + this.dividend += cost; + this.cash -= cost; + weekLedger.dividend += cost; + }; + App.Corporate.creditEconomy = function() { + this.ledger.current.setEconomy(V.localEcon); + this.cash += this.ledger.current.economicBoost; + }; + /* Need to prevent skipping intermediaries if they exist, ie break->surgery->train, you can skip surgery only if you don't have it.*/ + App.Corporate.ownsIntermediaryDivision = function(fromDivision, toDivision) { + for (let intermediateDiv of toDivision.relatedDivisions + .from + .filter(iDep => iDep.id != fromDivision.id && fromDivision.relatedDivisions.to.includes(iDep))) { - if(intermediateDiv.founded) return true; - } - return false; - }; - App.Corporate.slaveMarketPurchaseValue = function(division, count) { - division = asDivision(division); - let slaveValue = division.purchasedSlaveValue; - let totalValue = slaveValue * count * menialSlaveCost(count); - return Math.trunc(totalValue); - }; - App.Corporate.slaveMarketSellValue = function(division, count) { - division = asDivision(division); - let slaveValue = division.soldSlaveValue; - let totalValue = slaveValue * count * menialSlaveCost(count); - return Math.trunc(totalValue); - }; - App.Corporate.buySlaves = function(division, count) { - if(count <= 0) return 0; - - division = asDivision(division); - let purchasePrice = this.slaveMarketPurchaseValue(division, count); - if(this.cash < purchasePrice) { - throw "Attempted purchase without enough money"; - } - - this.chargeAsset(purchasePrice, "slaves"); - division.activeSlaves += count; - V.menialSupplyFactor -= count; - return purchasePrice; - }; - App.Corporate.sellSlaves = function(division, count) { - if(count <= 0) return 0; - - division = asDivision(division); - if(division.heldSlaves < count) { throw "Attempted to sell more slaves than held."; } - - let sellPrice = this.slaveMarketSellValue(division, count); - this.earnRevenue(sellPrice, "local"); - division.heldSlaves -= count; - V.menialDemandFactor -= count; - return sellPrice; - }; - App.Corporate.transferSlaves = function(fromDivision, toDivision, count) { - fromDivision = asDivision(fromDivision); - toDivision = asDivision(toDivision); - // TODO: validate the from and to departments are directly connected. - - if(fromDivision.heldSlaves < count) throw `Tried to move ${count} slaves out of ${fromDivision.name}, but it only had ${fromDivision.heldSlaves}`; - - fromDivision.heldSlaves -= count; - toDivision.activeSlaves += count; - }; - - App.Corporate.buyDevelopment = function(division, count) { - division = asDivision(division); - - let cost = Math.trunc(division.sizeCost * count * 1000); - - this.chargeAsset(cost, "development"); - division.developmentCount += count; - }; - App.Corporate.sellDevelopment = function(division, count) { - division = asDivision(division); - - const devCount = division.developmentCount; - count = count || devCount; - if(count > devCount) throw `Attempted to sell more of a division ${division.id} than exists (${count} of ${devCount})`; - const developmentCost = Math.trunc(count * division.sizeCost * 800); - this.chargeAsset(-developmentCost, "development"); - division.developmentCount -= count; - }; - App.Corporate.setAutoSendToDivision = function(fromDivision, toDivision, value) { - fromDivision = asDivision(fromDivision); - toDivision = asDivision(toDivision); - - fromDivision.setAutoSendToDivision(toDivision, value); - }; - App.Corporate.setAutoSendToMarket = function(division, value) { - division = asDivision(division); - division.setAutoSendToMarket(value); - }; - App.Corporate.setAutoBuyFromMarket = function(division, value) { - division = asDivision(division); - division.setAutoBuyFromMarket(value); - }; - App.Corporate.calculateDividend = function(weekLedger) - { - let profit = this.ledger.current.profit; - if(this.dividendRatio > 0 && profit > 0) - { - this.chargeDividend(profit * this.dividendRatio, weekLedger); - } - //Payout leftover cash should be the last thing the corporation does - //in a week so that its cash will be at the payout amount. - if(this.payoutCash) - { - let payoutAfter = this.payoutAfterCash; - if(this.cash > payoutAfter) - { - this.chargeDividend(this.cash - payoutAfter, weekLedger); - } - } - - if(this.dividendTimer <= 1) - { - weekLedger.payout = Math.trunc(this.dividend * this.shares.personal / this.shares.total); - cashX(weekLedger.payout, "stocks"); - this.dividendTimer = 14;//13 for each quarter, but +1 because we're subtracting one below. - this.dividend = 0; - } - - this.dividendTimer--; - }; - App.Corporate.endWeek = function() { - let ledger = new WeekProcessingLedger(); - //Prepare requests - for(let div of this.divisionList.filter(div=>div.founded)) { - let divLedger = ledger.getDivision(div) - - ledger.operatingCost += div.maintenanceCost; - ledger.registerMaintenanceForDivision(div); - - div.endweek_Revenue(divLedger); - div.endWeek_Slaves(divLedger); - } - for(let divLedger of Object.values(ledger.divisionLedgers)) { - let div = divLedger.division; - div.endWeek_Transfer(divLedger); - div.endWeek_Market(divLedger); - } - this.chargeAsset(ledger.operatingCost, "operations"); - this.chargeAsset(ledger.overhead, "overhead"); - //Execute sales requests, transfers, and earned revenue - for(let divLedger of Object.values(ledger.divisionLedgers)) { - let div = divLedger.division; - this.earnRevenue(divLedger.revenue.value, "local"); - if(div.activeSlaves > 0) - { - shared.SellOverflowSlaves(div); - } - - for(let otherDivPair of divLedger.transfer.divisions) { - let otherDiv = otherDivPair.division; - let count = otherDivPair.fill; - if(count == 0) continue; - - this.transferSlaves(div, otherDiv, count); - } - if(divLedger.market.sell > 0) { - divLedger.market.finalSale = this.sellSlaves(div, divLedger.market.sell); - } - } - - //Execute purchase requests - //todo: Make a switch to allow the user to control purchasing behavior. - //todo: Expensive first - //todo: Cheapest first - //Even purchase requsts: - let purchaseValues = evenFillArray(Object.values(ledger.divisionLedgers) - .filter(divLedger=>divLedger.market.buy > 0) - , this.cash - , divLedger=>divLedger.market.buyValue); - for(let divLedgerPair of purchaseValues) { - let divLedger = divLedgerPair.item; - let purchaseCost = divLedgerPair.value; - let div = divLedger.division; - - if(divLedger.market.buyValue > purchaseCost) { - //Estimate how many slaves we can afford within the purchase cost - let perSlaveEstimate = Math.trunc(divLedger.market.buyValue / divLedger.market.buy); - let numSlavesEstimate = Math.trunc(purchaseCost / perSlaveEstimate); - - if(numSlavesEstimate < 1) { - divLedger.market.originalBuy = divLedger.market.buy; - divLedger.market.buyShortMoney = divLedger.market.buyValue; - divLedger.market.buyShortSlaves = divLedger.market.buy; - divLedger.market.buy = 0; - } - else { - divLedger.market.originalBuy = divLedger.market.buy; - divLedger.market.buyShortMoney = divLedger.market.buyValue - purchaseCost; - divLedger.market.buyShortSlaves = divLedger.market.buy - numSlavesEstimate; - divLedger.market.buy = numSlavesEstimate; - } - } - divLedger.market.finalPurchase = this.buySlaves(div, divLedger.market.buy); - } - this.creditEconomy(); - - if(this.numDivisions < this.divisionList.length && !this.canExpand) - { - let expansionValue = Math.trunc(Math.pow(this.numDivisions, 1.5) + (5 * this.numDivisions + 2) / 4); - if(this.value > expansionValue * 1000000) - { - ledger.canExpandNow = true; - this.canExpand = true; - } - } - let specializationExpansion = 1.6 * Math.pow(1.25, this.specializations) - 1.2; - if(this.value > specializationExpansion * 1000000){ - this.specializationTokens++; - this.specializations++; - ledger.canSpecializeNow = true; - } - if(this.specializationTimer > 0) - { - this.specializationTimer--; - } - this.calculateDividend(ledger); - - return ledger; - }; - App.Corporate.cheatCash = function(userCash) { - userCash = Math.trunc(Number(userCash)) - if(Number.isFinite(userCash)) { - this.cash = userCash; - V.cheater = 1 - } - } - - App.Corporate.Backcompat = function(){ - //current foreignRevenue used to be used for old foreignRevenue - App.Corporate.ledger.old.foreignRevenue = App.Corporate.ledger.current.foreignRevenue; - }; - - if(V.corpDivTrainSurgeryTimer !== undefined) { - let timer = V.corpDivTrainSurgeryTimer; - // Note: originally the timer was capped at 20, so the founding week isn't guaranteed to be correct. - V.corpDivSurgeryFounded = V.week - timer; - delete V.corpDivTrainSurgeryTimer; - } + if (intermediateDiv.founded) { return true; } + } + return false; + }; + App.Corporate.slaveMarketPurchaseValue = function(division, count) { + division = asDivision(division); + let slaveValue = division.purchasedSlaveValue; + let totalValue = slaveValue * count * menialSlaveCost(count); + return Math.trunc(totalValue); + }; + App.Corporate.slaveMarketSellValue = function(division, count) { + division = asDivision(division); + let slaveValue = division.soldSlaveValue; + let totalValue = slaveValue * count * menialSlaveCost(count); + return Math.trunc(totalValue); + }; + App.Corporate.buySlaves = function(division, count) { + if (count <= 0) { return 0; } + + division = asDivision(division); + let purchasePrice = this.slaveMarketPurchaseValue(division, count); + if (this.cash < purchasePrice) { + throw "Attempted purchase without enough money"; + } + + this.chargeAsset(purchasePrice, "slaves"); + division.activeSlaves += count; + V.menialSupplyFactor -= count; + return purchasePrice; + }; + App.Corporate.sellSlaves = function(division, count) { + if (count <= 0) { return 0; } + + division = asDivision(division); + if (division.heldSlaves < count) { throw "Attempted to sell more slaves than held."; } + + let sellPrice = this.slaveMarketSellValue(division, count); + this.earnRevenue(sellPrice, "local"); + division.heldSlaves -= count; + V.menialDemandFactor -= count; + return sellPrice; + }; + App.Corporate.transferSlaves = function(fromDivision, toDivision, count) { + fromDivision = asDivision(fromDivision); + toDivision = asDivision(toDivision); + // TODO: validate the from and to departments are directly connected. + + if (fromDivision.heldSlaves < count) { + throw `Tried to move ${count} slaves out of ${fromDivision.name}, but it only had ${fromDivision.heldSlaves}`; + } + + fromDivision.heldSlaves -= count; + toDivision.activeSlaves += count; + }; + + App.Corporate.buyDevelopment = function(division, count) { + division = asDivision(division); + + let cost = Math.trunc(division.sizeCost * count * 1000); + + this.chargeAsset(cost, "development"); + division.developmentCount += count; + }; + App.Corporate.sellDevelopment = function(division, count) { + division = asDivision(division); + + const devCount = division.developmentCount; + count = count || devCount; + if (count > devCount) { + throw `Attempted to sell more of a division ${division.id} than exists (${count} of ${devCount})`; + } + const developmentCost = Math.trunc(count * division.sizeCost * 800); + this.chargeAsset(-developmentCost, "development"); + division.developmentCount -= count; + }; + App.Corporate.setAutoSendToDivision = function(fromDivision, toDivision, value) { + fromDivision = asDivision(fromDivision); + toDivision = asDivision(toDivision); + + fromDivision.setAutoSendToDivision(toDivision, value); + }; + App.Corporate.setAutoSendToMarket = function(division, value) { + division = asDivision(division); + division.setAutoSendToMarket(value); + }; + App.Corporate.setAutoBuyFromMarket = function(division, value) { + division = asDivision(division); + division.setAutoBuyFromMarket(value); + }; + App.Corporate.calculateDividend = function(weekLedger) { + let profit = this.ledger.current.profit; + if (this.dividendRatio > 0 && profit > 0) { + this.chargeDividend(profit * this.dividendRatio, weekLedger); + } + //Payout leftover cash should be the last thing the corporation does + //in a week so that its cash will be at the payout amount. + if (this.payoutCash) { + let payoutAfter = this.payoutAfterCash; + if (this.cash > payoutAfter) { + this.chargeDividend(this.cash - payoutAfter, weekLedger); + } + } + + if (this.dividendTimer <= 1) { + weekLedger.payout = Math.trunc(this.dividend * this.shares.personal / this.shares.total); + cashX(weekLedger.payout, "stocks"); + this.dividendTimer = 14;//13 for each quarter, but +1 because we're subtracting one below. + this.dividend = 0; + } + + this.dividendTimer--; + }; + App.Corporate.endWeek = function() { + let ledger = new WeekProcessingLedger(); + //Prepare requests + for (let div of this.divisionList.filter(div=>div.founded)) { + let divLedger = ledger.getDivision(div); + + ledger.operatingCost += div.maintenanceCost; + ledger.registerMaintenanceForDivision(div); + + div.endweek_Revenue(divLedger); + div.endWeek_Slaves(divLedger); + } + for (let divLedger of Object.values(ledger.divisionLedgers)) { + let div = divLedger.division; + div.endWeek_Transfer(divLedger); + div.endWeek_Market(divLedger); + } + this.chargeAsset(ledger.operatingCost, "operations"); + this.chargeAsset(ledger.overhead, "overhead"); + //Execute sales requests, transfers, and earned revenue + for (let divLedger of Object.values(ledger.divisionLedgers)) { + let div = divLedger.division; + this.earnRevenue(divLedger.revenue.value, "local"); + if (div.activeSlaves > 0) { + shared.SellOverflowSlaves(div); + } + + for (let otherDivPair of divLedger.transfer.divisions) { + let otherDiv = otherDivPair.division; + let count = otherDivPair.fill; + if (count == 0) { continue; } + + this.transferSlaves(div, otherDiv, count); + } + if (divLedger.market.sell > 0) { + divLedger.market.finalSale = this.sellSlaves(div, divLedger.market.sell); + } + } + + //Execute purchase requests + //todo: Make a switch to allow the user to control purchasing behavior. + //todo: Expensive first + //todo: Cheapest first + //Even purchase requsts: + let purchaseValues = evenFillArray(Object.values(ledger.divisionLedgers) + .filter(divLedger=>divLedger.market.buy > 0) + , this.cash + , divLedger=>divLedger.market.buyValue); + for (let divLedgerPair of purchaseValues) { + let divLedger = divLedgerPair.item; + let purchaseCost = divLedgerPair.value; + let div = divLedger.division; + + if (divLedger.market.buyValue > purchaseCost) { + //Estimate how many slaves we can afford within the purchase cost + let perSlaveEstimate = Math.trunc(divLedger.market.buyValue / divLedger.market.buy); + let numSlavesEstimate = Math.trunc(purchaseCost / perSlaveEstimate); + + if (numSlavesEstimate < 1) { + divLedger.market.originalBuy = divLedger.market.buy; + divLedger.market.buyShortMoney = divLedger.market.buyValue; + divLedger.market.buyShortSlaves = divLedger.market.buy; + divLedger.market.buy = 0; + } else { + divLedger.market.originalBuy = divLedger.market.buy; + divLedger.market.buyShortMoney = divLedger.market.buyValue - purchaseCost; + divLedger.market.buyShortSlaves = divLedger.market.buy - numSlavesEstimate; + divLedger.market.buy = numSlavesEstimate; + } + } + divLedger.market.finalPurchase = this.buySlaves(div, divLedger.market.buy); + } + this.creditEconomy(); + + if (this.numDivisions < this.divisionList.length && !this.canExpand) { + let expansionValue = Math.trunc(Math.pow(this.numDivisions, 1.5) + (5 * this.numDivisions + 2) / 4); + if (this.value > expansionValue * 1000000) { + ledger.canExpandNow = true; + this.canExpand = true; + } + } + let specializationExpansion = 1.6 * Math.pow(1.25, this.specializations) - 1.2; + if (this.value > specializationExpansion * 1000000) { + this.specializationTokens++; + this.specializations++; + ledger.canSpecializeNow = true; + } + if (this.specializationTimer > 0) { + this.specializationTimer--; + } + this.calculateDividend(ledger); + + return ledger; + }; + App.Corporate.cheatCash = function(userCash) { + userCash = Math.trunc(Number(userCash)); + if (Number.isFinite(userCash)) { + this.cash = userCash; + V.cheater = 1; + } + }; + + App.Corporate.Backcompat = function() { + //current foreignRevenue used to be used for old foreignRevenue + App.Corporate.ledger.old.foreignRevenue = App.Corporate.ledger.current.foreignRevenue; + }; + + if (V.corpDivTrainSurgeryTimer !== undefined) { + let timer = V.corpDivTrainSurgeryTimer; + // Note: originally the timer was capped at 20, so the founding week isn't guaranteed to be correct. + V.corpDivSurgeryFounded = V.week - timer; + delete V.corpDivTrainSurgeryTimer; + } }; @@ -926,24 +919,24 @@ App.Corporate.Init = function() { // A positive q means adding shares to the market, negative means removing them window.corpSharePrice = function(q = 0, personalShares = null, publicShares = null) { - if (V.corpIncorporated === 0) { - return 0; - } - personalShares = personalShares || V.personalShares; - publicShares = publicShares || V.publicShares; - return Math.trunc(1000 * (App.Corporate.value / (personalShares + publicShares + q))); + if (V.corpIncorporated === 0) { + return 0; + } + personalShares = personalShares || V.personalShares; + publicShares = publicShares || V.publicShares; + return Math.trunc(1000 * (App.Corporate.value / (personalShares + publicShares + q))); }; // Corporation race blacklisting/whitelisting // race is the lowercase string representing the race, 'blacklist' is either 1 or 0. 1 means we are blacklisting and 0 means we are whitelisting said race window.corpBlacklistRace = function(race, blacklist) { - let raceArray = State.variables.corpSpecRaces; - if (raceArray.length > 0 && blacklist === 1) { - raceArray.delete(race); - } else if (blacklist === 1) { - raceArray = setup.filterRacesLowercase.filter(x => x !== race); - } else { - raceArray.push(race); - } - return raceArray; + let raceArray = State.variables.corpSpecRaces; + if (raceArray.length > 0 && blacklist === 1) { + raceArray.delete(race); + } else if (blacklist === 1) { + raceArray = setup.filterRacesLowercase.filter(x => x !== race); + } else { + raceArray.push(race); + } + return raceArray; }; diff --git a/src/debugging/debugJS.js b/src/debugging/debugJS.js index efce11a2103..5fb2964a99e 100644 --- a/src/debugging/debugJS.js +++ b/src/debugging/debugJS.js @@ -57,7 +57,7 @@ window.diffFlatten = function diffFlatten(data) { // eslint-disable-next-line no-var for (var i=0, l=cur.length; i<l; i++) { // don't change the "var" to "let" recurse(cur[i], prop + "[" + i + "]"); - } + } // eslint-disable-next-line block-scoped-var if (l === 0) { result[prop] = []; } } else { diff --git a/src/endWeek/saNanny.js b/src/endWeek/saNanny.js index fc3685f8c18..5cc9cdf0e41 100644 --- a/src/endWeek/saNanny.js +++ b/src/endWeek/saNanny.js @@ -5,162 +5,162 @@ window.saNanny = function saNanny(slave) { "use strict"; const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); - let t = `works as a nanny. ${He} ${V.nurseryBabies ? `looks after the child${V.nurseryBabies > 0 ? `ren` : ``} in ${V.nurseryName}, ensuring their needs are met and that they are being raised as ${V.nurseryBabies === 1 ? `a good future slave` : `good future slaves`}. ` : `keeps ${V.nurseryName} neat and tidy for the children it will one day support`}. `; + let t = `works as a nanny. ${He} ${V.nurseryBabies ? `looks after the child${V.nurseryBabies > 0 ? `ren` : ``} in ${V.nurseryName}, ensuring their needs are met and that they are being raised as ${V.nurseryBabies === 1 ? `a good future slave` : `good future slaves`}. ` : `keeps ${V.nurseryName} neat and tidy for the children it will one day support`}. `; - // TODO: - t += ` ${He} is `; - if (slave.trust < -20) { - t += `frightened of punishment and works very hard, <span class="yellowgreen">reducing the upkeep</span> of ${V.nurseryName}${V.nurseryBabies ? ` and the children within` : ``}.`; - } else if (slave.devotion <= 20) { - t += `hesitant, requiring your other slaves to demand ${his} services, and only slightly <span class="yellowgreen">reduces upkeep</span> of your slaves.`; - } else if (slave.devotion <= 50) { - t += `obedient, offering your other slaves ${his} services, and moderately <span class="yellowgreen">reduces the upkeep</span> of your slaves.`; - } else if (slave.devotion <= 95) { - t += `devoted, happily giving your other slaves ${his} services, and <span class="yellowgreen">reduces the upkeep</span> of your slaves.`; - } else { - t += `so happy to serve your other slaves that ${he} often sees to their needs before they know they have them, and greatly <span class="yellowgreen">reduces the upkeep</span> of your slaves.`; - } + // TODO: + t += ` ${He} is `; + if (slave.trust < -20) { + t += `frightened of punishment and works very hard, <span class="yellowgreen">reducing the upkeep</span> of ${V.nurseryName}${V.nurseryBabies ? ` and the children within` : ``}.`; + } else if (slave.devotion <= 20) { + t += `hesitant, requiring your other slaves to demand ${his} services, and only slightly <span class="yellowgreen">reduces upkeep</span> of your slaves.`; + } else if (slave.devotion <= 50) { + t += `obedient, offering your other slaves ${his} services, and moderately <span class="yellowgreen">reduces the upkeep</span> of your slaves.`; + } else if (slave.devotion <= 95) { + t += `devoted, happily giving your other slaves ${his} services, and <span class="yellowgreen">reduces the upkeep</span> of your slaves.`; + } else { + t += `so happy to serve your other slaves that ${he} often sees to their needs before they know they have them, and greatly <span class="yellowgreen">reduces the upkeep</span> of your slaves.`; + } - // TODO: - if (slave.releaseRules !== "chastity") { - const oral = jsRandom(5, 10); - slave.counter.oral += oral; - V.oralTotal += oral; - } + // TODO: + if (slave.releaseRules !== "chastity") { + const oral = jsRandom(5, 10); + slave.counter.oral += oral; + V.oralTotal += oral; + } - // TODO: - if (slave.relationship === -2) { - t += ` ${He} does ${his} best to perfect your domesticity due to ${his} emotional bond to you.`; - } else if (slave.relationship === -3 && slave.devotion > 50) { - t += ` ${He} does ${his} very best to be the perfect housewife, making ${him} an outstanding servant.`; - } + // TODO: + if (slave.relationship === -2) { + t += ` ${He} does ${his} best to perfect your domesticity due to ${his} emotional bond to you.`; + } else if (slave.relationship === -3 && slave.devotion > 50) { + t += ` ${He} does ${his} very best to be the perfect housewife, making ${him} an outstanding servant.`; + } - // TODO: - if (setup.servantCareers.includes(slave.career)) { - t += ` ${He} has experience with house keeping from ${his} life before ${he} was a slave, making ${him} more effective.`; - } else if (slave.skill.servant >= V.masteredXP) { - t += ` ${He} has experience with house keeping from working for you, making ${him} more effective.`; - } else { - slave.skill.servant += jsRandom(1, Math.ceil((slave.intelligence + slave.intelligenceImplant) / 15) + 8); - } + // TODO: + if (setup.servantCareers.includes(slave.career)) { + t += ` ${He} has experience with house keeping from ${his} life before ${he} was a slave, making ${him} more effective.`; + } else if (slave.skill.servant >= V.masteredXP) { + t += ` ${He} has experience with house keeping from working for you, making ${him} more effective.`; + } else { + slave.skill.servant += jsRandom(1, Math.ceil((slave.intelligence + slave.intelligenceImplant) / 15) + 8); + } - // TODO: - if (slave.fetishStrength > 60) { - if (slave.fetish === "submissive" && slave.fetishKnown === 1) { - t += ` ${His} natural affinity for submission increases ${his} effectiveness.`; - } else if (slave.fetishKnown === 1 && slave.fetish === "dom") { - t += ` ${His} sexual appetite for domination reduces ${his} effectiveness.`; - } - } - // TODO: - if (slave.energy < 20) { - t += ` ${His} frigidity allows ${him} to ignore the intercourse all around ${him}, making ${him} very efficient.`; - } else if (slave.energy < 40) { - t += ` ${His} low sex drive keeps ${him} from becoming too distracted by the intercourse all around ${him}, making ${him} more efficient.`; - } - // TODO: - if ((slave.eyes <= -1 && slave.eyewear !== "corrective glasses" && slave.eyewear !== "corrective contacts") || (slave.eyewear === "blurring glasses") || (slave.eyewear === "blurring contacts")) { - t += ` ${His} bad vision makes ${him} a worse nanny.`; + // TODO: + if (slave.fetishStrength > 60) { + if (slave.fetish === "submissive" && slave.fetishKnown === 1) { + t += ` ${His} natural affinity for submission increases ${his} effectiveness.`; + } else if (slave.fetishKnown === 1 && slave.fetish === "dom") { + t += ` ${His} sexual appetite for domination reduces ${his} effectiveness.`; } + } + // TODO: + if (slave.energy < 20) { + t += ` ${His} frigidity allows ${him} to ignore the intercourse all around ${him}, making ${him} very efficient.`; + } else if (slave.energy < 40) { + t += ` ${His} low sex drive keeps ${him} from becoming too distracted by the intercourse all around ${him}, making ${him} more efficient.`; + } + // TODO: + if ((slave.eyes <= -1 && slave.eyewear !== "corrective glasses" && slave.eyewear !== "corrective contacts") || (slave.eyewear === "blurring glasses") || (slave.eyewear === "blurring contacts")) { + t += ` ${His} bad vision makes ${him} a worse nanny.`; + } - if (V.showVignettes === 1 && (slave.assignment === Job.NANNY)) { - const vignette = GetVignette(slave); - t += ` <u>This week</u> ${vignette.text} `; - if (vignette.type === "cash") { - let modifier = FResult(slave); - if (vignette.effect > 0) { - t += `<span class="yellowgreen">making you an extra ${cashFormat(Math.trunc(modifier * vignette.effect))}.</span>`; - } else if (vignette.effect < 0) { - t += `<span class="red">losing you ${cashFormat(Math.abs(Math.trunc(modifier * vignette.effect)))}.</span>`; + if (V.showVignettes === 1 && (slave.assignment === Job.NANNY)) { + const vignette = GetVignette(slave); + t += ` <u>This week</u> ${vignette.text} `; + if (vignette.type === "cash") { + let modifier = FResult(slave); + if (vignette.effect > 0) { + t += `<span class="yellowgreen">making you an extra ${cashFormat(Math.trunc(modifier * vignette.effect))}.</span>`; + } else if (vignette.effect < 0) { + t += `<span class="red">losing you ${cashFormat(Math.abs(Math.trunc(modifier * vignette.effect)))}.</span>`; + } else { + t += `an incident without lasting effect.`; + } + cashX(Math.trunc(modifier * vignette.effect), "houseServant", slave); + } else if (vignette.type === "devotion") { + if (vignette.effect > 0) { + if (slave.devotion > 50) { + t += `<span class="hotpink">increasing ${his} devotion to you.</span>`; + } else if (slave.devotion >= -20) { + t += `<span class="hotpink">increasing ${his} acceptance of you.</span>`; + } else if (slave.devotion > -10) { + t += `<span class="hotpink">reducing ${his} dislike of you.</span>`; } else { - t += `an incident without lasting effect.`; + t += `<span class="hotpink">reducing ${his} hatred of you.</span>`; } - cashX(Math.trunc(modifier * vignette.effect), "houseServant", slave); - } else if (vignette.type === "devotion") { - if (vignette.effect > 0) { - if (slave.devotion > 50) { - t += `<span class="hotpink">increasing ${his} devotion to you.</span>`; - } else if (slave.devotion >= -20) { - t += `<span class="hotpink">increasing ${his} acceptance of you.</span>`; - } else if (slave.devotion > -10) { - t += `<span class="hotpink">reducing ${his} dislike of you.</span>`; - } else { - t += `<span class="hotpink">reducing ${his} hatred of you.</span>`; - } - } else if (vignette.effect < 0) { - if (slave.devotion > 50) { - t += `<span class="mediumorchid">reducing ${his} devotion to you.</span>`; - } else if (slave.devotion >= -20) { - t += `<span class="mediumorchid">reducing ${his} acceptance of you.</span>`; - } else if (slave.devotion > -10) { - t += `<span class="mediumorchid">increasing ${his} dislike of you.</span>`; - } else { - t += `<span class="mediumorchid">increasing ${his} hatred of you.</span>`; - } + } else if (vignette.effect < 0) { + if (slave.devotion > 50) { + t += `<span class="mediumorchid">reducing ${his} devotion to you.</span>`; + } else if (slave.devotion >= -20) { + t += `<span class="mediumorchid">reducing ${his} acceptance of you.</span>`; + } else if (slave.devotion > -10) { + t += `<span class="mediumorchid">increasing ${his} dislike of you.</span>`; } else { - t += `an incident without lasting effect.`; + t += `<span class="mediumorchid">increasing ${his} hatred of you.</span>`; } - slave.devotion += (1 * vignette.effect); - } else if (vignette.type === "trust") { - if (vignette.effect > 0) { - if (slave.trust > 20) { - t += `<span class="mediumaquamarine">increasing ${his} trust in you.</span>`; - } else if (slave.trust > -10) { - t += `<span class="mediumaquamarine">reducing ${his} fear of you.</span>`; - } else { - t += `<span class="mediumaquamarine">reducing ${his} terror of you.</span>`; - } - } else if (vignette.effect < 0) { - if (slave.trust > 20) { - t += `<span class="gold">reducing ${his} trust in you.</span>`; - } else if (slave.trust >= -20) { - t += `<span class="gold">increasing ${his} fear of you.</span>`; - } else { - t += `<span class="gold">increasing ${his} terror of you.</span>`; - } + } else { + t += `an incident without lasting effect.`; + } + slave.devotion += (1 * vignette.effect); + } else if (vignette.type === "trust") { + if (vignette.effect > 0) { + if (slave.trust > 20) { + t += `<span class="mediumaquamarine">increasing ${his} trust in you.</span>`; + } else if (slave.trust > -10) { + t += `<span class="mediumaquamarine">reducing ${his} fear of you.</span>`; } else { - t += `an incident without lasting effect.`; + t += `<span class="mediumaquamarine">reducing ${his} terror of you.</span>`; } - slave.trust += (1 * vignette.effect); - } else if (vignette.type === "health") { - if (vignette.effect > 0) { - t += `<span class="green">improving ${his} health.</span>`; - } else if (vignette.effect < 0) { - t += `<span class="red">affecting ${his} health.</span>`; + } else if (vignette.effect < 0) { + if (slave.trust > 20) { + t += `<span class="gold">reducing ${his} trust in you.</span>`; + } else if (slave.trust >= -20) { + t += `<span class="gold">increasing ${his} fear of you.</span>`; } else { - t += `an incident without lasting effect.`; + t += `<span class="gold">increasing ${his} terror of you.</span>`; } - slave.health += (2 * vignette.effect); } else { - let modifier = FResult(slave); - if (vignette.effect > 0) { - t += `<span class="green">gaining you a bit of reputation.</span>`; - } else if (vignette.effect < 0) { - t += `<span class="red">losing you a bit of reputation.</span>`; - } else { - t += `an incident without lasting effect.`; - } - repX((modifier * vignette.effect * 0.1), "vignette", slave); + t += `an incident without lasting effect.`; } - } - - if (V.Matron) { - t += `While there, ${he} benefits from ${V.Matron.slaveName}'s `; - if (V.Matron.physicalAge < 21) { - t += `youthful energy`; + slave.trust += (1 * vignette.effect); + } else if (vignette.type === "health") { + if (vignette.effect > 0) { + t += `<span class="green">improving ${his} health.</span>`; + } else if (vignette.effect < 0) { + t += `<span class="red">affecting ${his} health.</span>`; } else { - t += `care`; + t += `an incident without lasting effect.`; } - if (V.Matron.skill.oral) { // TODO: keep this? replace with something else? - t += ` and talented tongue`; + slave.health += (2 * vignette.effect); + } else { + let modifier = FResult(slave); + if (vignette.effect > 0) { + t += `<span class="green">gaining you a bit of reputation.</span>`; + } else if (vignette.effect < 0) { + t += `<span class="red">losing you a bit of reputation.</span>`; + } else { + t += `an incident without lasting effect.`; } - t += `. `; - /* TODO: farmer is often not set and makes no sense here. What should this be? LCD. + repX((modifier * vignette.effect * 0.1), "vignette", slave); + } + } + + if (V.Matron) { + t += `While there, ${he} benefits from ${V.Matron.slaveName}'s `; + if (V.Matron.physicalAge < 21) { + t += `youthful energy`; + } else { + t += `care`; + } + if (V.Matron.skill.oral) { // TODO: keep this? replace with something else? + t += ` and talented tongue`; + } + t += `. `; + /* TODO: farmer is often not set and makes no sense here. What should this be? LCD. if (slave.devotion < V.FarmerDevotionThreshold) { slave.devotion += V.FarmerDevotionBonus; } @@ -170,7 +170,7 @@ window.saNanny = function saNanny(slave) { if (slave.health < 100) { slave.health += V.FarmerHealthBonus; }*/ - } + } return t; }; diff --git a/src/endWeek/saRules.js b/src/endWeek/saRules.js index 450a0d8ba93..9161aae9959 100644 --- a/src/endWeek/saRules.js +++ b/src/endWeek/saRules.js @@ -13,10 +13,10 @@ $(function() { */ function saRules(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let release = slave.releaseRules; @@ -54,7 +54,8 @@ $(function() { r += `is routinely relieved of any built up tension by ${Matron.slaveName} and ${his}`; if (canPenetrate(slave) && V.Matron.boobs >= 500) { r += `luscious breasts. `; - slave.counter.mammary += 14, V.mammaryTotal += 14; + slave.counter.mammary += 14; + V.mammaryTotal += 14; } else { if (slave.lips > 40) { r += `luscious lips. `; @@ -63,7 +64,8 @@ $(function() { } else { r += `willing mouth. `; } - slave.counter.oral += 14, V.oralTotal += 14; + slave.counter.oral += 14; + V.oralTotal += 14; } slave.need = -60; } else { @@ -87,20 +89,26 @@ $(function() { if (slave.devotion <= 20) { if (slave.trust > -20) { r += `takes solace in ${his} permission to masturbate rather than being forced to beg for sex, <span class="mediumaquamarine">reducing ${his} fear</span> of you. `; - slave.trust += 2, slave.need = 0; + slave.trust += 2; + slave.need = 0; } else { r += `enjoys being allowed to masturbate rather than trading sex with other slaves, <span class="mediumaquamarine">slightly reducing ${his} fear</span> of you but <span class="mediumorchid">allowing ${him} to remain in control of ${him} sexuality. </span>`; - slave.devotion--, slave.trust++, slave.need = 0; + slave.devotion--; + slave.trust++; + slave.need = 0; } } else if (slave.devotion <= 50) { r += `accepts having to relieve ${himself} solely through masturbation. `; slave.need = 0; } else if (slave.devotion <= 80) { r += `is a little disappointed that ${he}'s limited to ${his} hands and toys, but <span class="mediumaquamarine">trusts you know what's best for ${him}. </span>`; - slave.trust++, slave.need = 0; + slave.trust++; + slave.need = 0; } else { r += `<span class="mediumaquamarine">trusts your judgment</span> that only ${he} really knows how to pleasure ${himself}, though ${he} <span class="mediumorchid">often wonders why you don't use ${him}. </span>`; - slave.devotion -= 2, slave.trust++, slave.need = 0; + slave.devotion -= 2; + slave.trust++; + slave.need = 0; } if (slave.devotion >= 20) { @@ -113,52 +121,64 @@ $(function() { if (slave.trust > -20) { if (release === "permissive") { r += `masturbates whenever ${he} can find a private moment to take care of the urges induced by the food, <span class="mediumaquamarine">slightly reducing ${his} fear</span> of you. `; - slave.trust++, slave.need = 0; + slave.trust++; + slave.need = 0; } else { r += `refuses to ask other slaves for sex, and is <span class="gold">severely punished</span> for illicit masturbation. `; - slave.trust -= 2, slave.need -= 10; + slave.trust -= 2; + slave.need -= 10; } } else { if (release === "permissive") { r += `prefers to masturbate rather than demanding sex from other slaves, <span class="mediumaquamarine">slightly reducing ${his} fear</span> of you. `; - slave.trust++, slave.need = 0; + slave.trust++; + slave.need = 0; } else { r += `is forced by the urges induced by the food to demand sex from other slaves, and <span class="hotpink">hates ${himself}</span> for it. `; - slave.devotion++, slave.need = 0; + slave.devotion++; + slave.need = 0; } } } else if (slave.devotion <= 50) { r += `<span class="hotpink">accepts the need</span> to ${rapeFetish(slave)} ${rapeDiscoversFetish(slave)}`; - slave.devotion++, slave.need = 0; + slave.devotion++; + slave.need = 0; } else { r += `happily <span class="mediumaquamarine">avails ${himself}</span> of your permission to ${rapeFetish(slave)} ${rapeDiscoversFetish(slave)}`; - slave.trust++, slave.need = 0; + slave.trust++; + slave.need = 0; } } else { if (slave.devotion <= 20) { if (slave.trust > -20) { if (release === "permissive") { r += `prefers to masturbate rather than asking other slaves for sex or giving free samples, <span class="mediumaquamarine">slightly reducing ${his} fear</span> of you. `; - slave.trust++, slave.need = 0; + slave.trust++; + slave.need = 0; } else { r += `refuses to ask other slaves for sex, and is <span class="gold">severely punished</span> for illicit masturbation. `; - slave.trust -= 2, slave.need -= 10; + slave.trust -= 2; + slave.need -= 10; } } else { if (release === "permissive") { r += `prefers to masturbate rather than trading sex with other slaves, <span class="mediumaquamarine">slightly reducing ${his} fear</span> of you. `; - slave.trust++, slave.need = 0; + slave.trust++; + slave.need = 0; } else { r += `is forced by the urges induced by the food to swap sex with other slaves, and <span class="hotpink">hates ${himself}</span> for it. `; - slave.devotion++, slave.need *= 0.5; + slave.devotion++; + slave.need *= 0.5; } } } else if (slave.devotion <= 50) { r += `<span class="hotpink">accepts having to ask</span> other slaves for sex, ${consentFetish(slave)} ${consentDiscoversFetish(slave)}`; - slave.devotion++, slave.need = 0; + slave.devotion++; + slave.need = 0; } else { r += `<span class="mediumaquamarine">relies</span> on your other slaves for mutual satisfaction, ${consentFetish(slave)} ${consentDiscoversFetish(slave)}`; - slave.trust++, slave.need = 0; + slave.trust++; + slave.need = 0; } } r += `${permissiveDrugEffects(slave)}`; @@ -462,10 +482,10 @@ $(function() { function playerFetishPlay(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``; @@ -490,7 +510,9 @@ $(function() { case "boobs": r += `fondle ${his} breasts`; if (slave.lactation > 0) { - slave.lactationDuration = 2, slave.boobs -= slave.boobsMilk, slave.boobsMilk = 0; + slave.lactationDuration = 2; + slave.boobs -= slave.boobsMilk; + slave.boobsMilk = 0; } break; case "sadist": @@ -523,10 +545,10 @@ $(function() { function playerEnergy(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``; @@ -540,11 +562,13 @@ $(function() { } else { r += `<span class="hotpink">eagerly looks forward</span> to each climax ${he} shares with you. `; } - slave.devotion += 2, slave.need = 0; + slave.devotion += 2; + slave.need = 0; SimpleSexAct.Player(slave, 10); } else if (energy === 2) { r += `You have surplus sexual energy to fuck ${him} whenever <<if $slaves[$i].relationship == -3>> you notice ${his} need<<else>>${he} forces ${himself} to ask<</if>>, and ${he} is <span class="hotpink">sexually dependent</span> on you. `; - slave.devotion++, slave.need -= 40; + slave.devotion++; + slave.need -= 40; SimpleSexAct.Player(slave, 5); } else if (slave.relationship === -3) { r += `You have little surplus sexual energy, but you make sure to keep your wife's needs in mind<<if $slaves[$i].devotion < -20>>, even if ${he} doesn't want it<</if>>. `; @@ -565,10 +589,10 @@ $(function() { function playerDiscoversFetish(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``; @@ -630,10 +654,10 @@ $(function() { function playerDrugEffects(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``; @@ -711,10 +735,10 @@ $(function() { function masturbationFetishPlay(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``; @@ -745,7 +769,9 @@ $(function() { case "boobs": r += `pays extra attention to ${his} breasts and nipples. `; if (slave.lactation) { - slave.lactationDuration = 2, slave.boobs -= slave.boobsMilk, slave.boobsMilk = 0; + slave.lactationDuration = 2; + slave.boobs -= slave.boobsMilk; + slave.boobsMilk = 0; } else { induceLactation(slave); } @@ -793,10 +819,10 @@ $(function() { function masturbationDiscoversFetish(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``; @@ -822,7 +848,9 @@ $(function() { case "boobs": r += `${he} always has a hand to ${his} nipples; <span class="lightcoral">${he}'s a boob fetishist!</span>`; if (slave.lactation) { - slave.lactationDuration = 2, slave.boobs -= slave.boobsMilk, slave.boobsMilk = 0; + slave.lactationDuration = 2; + slave.boobs -= slave.boobsMilk; + slave.boobsMilk = 0; } else { induceLactation(slave); } @@ -854,10 +882,10 @@ $(function() { function masturbationDrugEffects(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``; @@ -912,10 +940,12 @@ $(function() { r += `<span class="lime">${He} is so baby crazed ${he} takes ${his} own virginity. </span>`; slave.vagina++; } - slave.devotion -= 3, slave.trust -= 2; + slave.devotion -= 3; + slave.trust -= 2; } else if (slave.devotion >= -20) { r += `leaving ${him} <span class="mediumorchid">completely unfulfilled</span> since <span class="gold">you won't <<if $PC.dick == 1>>give ${him}<<else>>let ${him} find<</if>> the dick ${he} needs. </span>`; - slave.devotion -= 3, slave.trust -= 2; + slave.devotion -= 3; + slave.trust -= 2; } else { r += `leaving ${him} desperate for a thorough seeding <span class="mediumorchid">that you've forbidden ${him} from having. </span>`; slave.devotion -= 3; @@ -932,10 +962,10 @@ $(function() { function rapeFetish(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``, @@ -950,7 +980,8 @@ $(function() { if ((slave.anus * 40) - (averageDick * 5) < jsRandom(1, 100)) { r += `<span class="lime">${His} asshole is loosened</span> during sex with other slaves, since most of the cocks ${he} enticed a dominating buttfuck from are `; slave.anus++; - slave.counter.anal += 3, V.analTotal += 3; + slave.counter.anal += 3; + V.analTotal += 3; } if (averageDick > 5) { @@ -958,7 +989,8 @@ $(function() { if ((slave.vagina * 40) - (averageDick * 5) < jsRandom(1, 100)) { r += `Since most of the slaves ${he} enticed a pounding from are extremely hung, <span class="lime">${his} cunt gets stretched out. </span>`; slave.vagina++; - slave.counter.vaginal += 3, V.vaginalTotal += 3; + slave.counter.vaginal += 3; + V.vaginalTotal += 3; } } } @@ -969,7 +1001,8 @@ $(function() { case "cumslut": r += `suck or be sucked by any slave ${he} fancies. `; fuckCount = jsRandom(5, 15); - slave.counter.oral += fuckCount, V.oralTotal += fuckCount; + slave.counter.oral += fuckCount; + V.oralTotal += fuckCount; break; case "humiliation": r += `demand that other slaves let ${him} fuck them in public. `; @@ -985,11 +1018,15 @@ $(function() { if (rival.assignmentVisible || rival.assignment === slave.assignment) { if (rival.devotion <= 20 && rival.trust < -20) { r += `Craving a rush, ${he} repeatedly forces a reluctant <<= SlaveFullName($slaves[_j])>> to have sex with ${him} in public. $slaves[_j].slaveName resents this, and $slaves[$i].slaveName's ongoing sexual abuse <span class="lightsalmon">starts a rivalry</span> between them. `; - slave.rivalry = 1, rival.rivalry = 1, slave.rivalryTarget = rival.ID, rival.rivalryTarget = slave.ID; + slave.rivalry = 1; + rival.rivalry = 1; + slave.rivalryTarget = rival.ID; + rival.rivalryTarget = slave.ID; SimpleSexAct.Slave(rival, 4); if (canPenetrate(rival)) { fuckCount = jsRandom(1, 3); - rival.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + rival.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } } } @@ -1000,7 +1037,8 @@ $(function() { SimpleSexAct.Slave(slave, 4); if (canPenetrate(slave)) { fuckCount = jsRandom(1, 3); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } break; case "buttslut": @@ -1014,18 +1052,21 @@ $(function() { } } fuckCount = jsRandom(5, 12); - slave.counter.anal += fuckCount, V.analTotal += fuckCount; + slave.counter.anal += fuckCount; + V.analTotal += fuckCount; break; case "boobs": r += `demand that other slaves massage ${his} breasts. `; if (slave.lactation) { slave.lactationDuration = 2; - slave.boobs -= slave.boobsMilk, slave.boobsMilk = 0; + slave.boobs -= slave.boobsMilk; + slave.boobsMilk = 0; } else { induceLactation(slave); } fuckCount = jsRandom(10, 25); - slave.counter.mammary += fuckCount, V.mammaryTotal += fuckCount; + slave.counter.mammary += fuckCount; + V.mammaryTotal += fuckCount; break; case "sadist": r += `force the most reluctant slaves to let ${him} fuck them. `; @@ -1070,11 +1111,15 @@ $(function() { break; } r += `and the sexual abuse <span class="lightsalmon">starts a rivalry</span> between them. `; - slave.rivalry = 1, rival.rivalry = 1, slave.rivalryTarget = rival.ID, rival.rivalryTarget = slave.ID; + slave.rivalry = 1; + rival.rivalry = 1; + slave.rivalryTarget = rival.ID; + rival.rivalryTarget = slave.ID; SimpleSexAct.Slave(rival, 4); if (canPenetrate(rival)) { fuckCount = jsRandom(1, 3); - rival.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + rival.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } } } @@ -1086,7 +1131,8 @@ $(function() { SimpleSexAct.Slave(slave, 4); if (canPenetrate(slave)) { fuckCount = jsRandom(1, 3); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } break; case "masochist": @@ -1096,7 +1142,8 @@ $(function() { if ((slave.anus * 30) - (averageDick * 5) < jsRandom(1, 100)) { r += `<span class="lime">${His} asshole is loosened</span> during sex with hung slaves, since ${he} often relies on painal to address ${his} needs. `; slave.anus++; - slave.counter.anal += 3, V.analTotal += 3; + slave.counter.anal += 3; + V.analTotal += 3; } } @@ -1105,7 +1152,8 @@ $(function() { if ((slave.vagina * 30) - (averageDick * 5) < jsRandom(1, 100)) { r += `Since ${he} usually demands that hung slaves fuck ${him} hard enough to make ${his} pussy hurt, <span class="lime">${his} cunt gets stretched out. </span>`; slave.vagina++; - slave.counter.vaginal += 3, V.vaginalTotal += 3; + slave.counter.vaginal += 3; + V.vaginalTotal += 3; } } } @@ -1126,7 +1174,10 @@ $(function() { if (rival.assignmentVisible || rival.assignment === slave.assignment) { if (rival.devotion <= 20 && rival.trust < -20) { r += `${He} repeatedly rapes a reluctant <<= SlaveFullName($slaves[_j])>>; ${he} can't seem to keep ${his} hands off the poor slave, who can't avoid ${him}. Not surprisingly, $slaves[_j].slaveName resents this, and $slaves[$i].slaveName's ongoing sexual abuse <span class="lightsalmon">starts a rivalry</span> between them. `; - slave.rivalry = 1, rival.rivalry = 1, slave.rivalryTarget = rival.ID, rival.rivalryTarget = slave.ID; + slave.rivalry = 1; + rival.rivalry = 1; + slave.rivalryTarget = rival.ID; + rival.rivalryTarget = slave.ID; SimpleSexAct.Slave(rival, 4); } } @@ -1137,7 +1188,8 @@ $(function() { SimpleSexAct.Slave(slave, 7); if (canPenetrate(slave)) { fuckCount = jsRandom(6, 9); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } break; case "pregnancy": @@ -1149,7 +1201,8 @@ $(function() { r += `Since ${he} constantly demands to be fucked deeply to get ${his} womb filled with cum, <span class="lime">${his} cunt gets stretched out. </span>`; slave.vagina++; fuckCount = jsRandom(7, 14); - slave.counter.vaginal += fuckCount, V.vaginalTotal += fuckCount; + slave.counter.vaginal += fuckCount; + V.vaginalTotal += fuckCount; } } } else { @@ -1158,7 +1211,8 @@ $(function() { r += `Since ${he} constantly demands to be fucked deeply to get ${his} womb filled with cum, <span class="lime">${his} ass gets stretched out. </span>`; slave.anus++; fuckCount = jsRandom(7, 14); - slave.counter.anal += fuckCount, V.analTotal += fuckCount; + slave.counter.anal += fuckCount; + V.analTotal += fuckCount; } } } @@ -1166,7 +1220,8 @@ $(function() { if (canPenetrate(slave)) { fuckCount = jsRandom(6, 9); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } break; default: @@ -1177,7 +1232,8 @@ $(function() { if ((slave.anus * 30) - (averageDick * 5) < jsRandom(1, 100)) { r += `<span class="lime">${His} asshole is loosened</span> during sex with well endowed slaves, since ${he}'s so addicted to sex all ${his} holes see heavy traffic. `; slave.anus++; - slave.counter.anus += 3, slave.counter.anal += 3; + slave.counter.anus += 3; + slave.counter.anal += 3; } } if (averageDick > 5) { @@ -1185,7 +1241,8 @@ $(function() { if ((slave.vagina * 30) - (averageDick * 5) < jsRandom(1, 100)) { r += `${He} indulges in non-stop sex with your well endowed slaves, so much so that <span class="lime">${his} cunt gets stretched out. </span>`; slave.vagina++; - slave.counter.vaginal += 3, V.vaginalTotal += 3; + slave.counter.vaginal += 3; + V.vaginalTotal += 3; } } } @@ -1193,14 +1250,16 @@ $(function() { SimpleSexAct.Slave(slave, 7); if (canPenetrate(slave)) { fuckCount = jsRandom(3, 6); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } } else { r += `demand that other slaves have sex with ${him}. `; SimpleSexAct.Slave(slave, 7); if (canPenetrate(slave)) { fuckCount = jsRandom(3, 6); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } } break; @@ -1210,7 +1269,8 @@ $(function() { SimpleSexAct.Slave(slave, 7); if (canPenetrate(slave)) { fuckCount = jsRandom(3, 6); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } } @@ -1219,10 +1279,10 @@ $(function() { function rapeDiscoversFetish(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``; @@ -1241,17 +1301,19 @@ $(function() { r += `use ${him} in public; <span class="lightcoral">${he}'s a humiliation fetishist!</span>`; break; case "buttslut": - if (slave.anus > 0) { - r += `<<if canDoAnal($slaves[$i])>>fuck ${his} butt<<else>>tease ${his} anus<</if>>;`; - } else { - r += `tease ${his} virgin anus;`; - } - r += `<span class="lightcoral">${he}'s an anal slut!</span>`; - break; + if (slave.anus > 0) { + r += `<<if canDoAnal($slaves[$i])>>fuck ${his} butt<<else>>tease ${his} anus<</if>>;`; + } else { + r += `tease ${his} virgin anus;`; + } + r += `<span class="lightcoral">${he}'s an anal slut!</span>`; + break; case "boobs": r += `fondle ${his} breasts; <span class="lightcoral">${he}'s a boob fetishist!</span>`; if (slave.lactation) { - slave.lactationDuration = 2, slave.boobs -= slave.boobsMilk, slave.boobsMilk = 0; + slave.lactationDuration = 2; + slave.boobs -= slave.boobsMilk; + slave.boobsMilk = 0; } else { induceLactation(slave); } @@ -1284,10 +1346,10 @@ $(function() { function consentFetish(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``; @@ -1297,12 +1359,14 @@ $(function() { r += `usually pairing off with a more dominant slave. `; if (largeDicks(slave, 40)) { r += `<span class="lime">${His} asshole is loosened</span> during sex with other slaves, since most of the cocks ${he} lets dominate ${his} backdoor are very `; - slave.anus++; - slave.counter.anal += 3, V.analTotal += 3; + slave.anus++; + slave.counter.anal += 3; + V.analTotal += 3; if (hugeDicks(slave, 40)) { r += `Since most of the slaves ${he} takes a pounding from are extremely hung, <span class="lime">${his} cunt gets stretched out .</span>`; - slave.vagina++; - slave.counter.vagina += 3, V.vaginalTotal += 3; + slave.vagina++; + slave.counter.vagina += 3; + V.vaginalTotal += 3; } } SimpleSexAct.Slave(slave, 7); @@ -1310,14 +1374,16 @@ $(function() { case "cumslut": r += `and is popular for ${his} willingness to give oral. `; fuckCount = jsRandom(5, 15); - slave.counter.oral += fuckCount, V.oralTotal += fuckCount; + slave.counter.oral += fuckCount; + V.oralTotal += fuckCount; break; case "humiliation": r += `usually asking them to fuck out in the open. `; SimpleSexAct.Slave(slave, 7); if (canPenetrate(slave)) { fuckCount = jsRandom(1, 3); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } break; case "buttslut": @@ -1326,7 +1392,8 @@ $(function() { if (canDoAnal(slave)) { r += `penetrate`; fuckCount = jsRandom(5, 12); - slave.counter.anal += fuckCount, V.analTotal += fuckCount; + slave.counter.anal += fuckCount; + V.analTotal += fuckCount; } else { r += `tease`; } @@ -1342,19 +1409,23 @@ $(function() { case "boobs": r += `seeing to anyone who will show ${his} breasts some love. `; if (slave.lactation) { - slave.lactationDuration = 2, slave.boobs -= slave.boobsMilk, slave.boobsMilk = 0; + slave.lactationDuration = 2; + slave.boobs -= slave.boobsMilk; + slave.boobsMilk = 0; } else { induceLactation(slave); } fuckCount = jsRandom(10, 25); - slave.counter.mammary += fuckCount, V.mammaryTotal += fuckCount; + slave.counter.mammary += fuckCount; + V.mammaryTotal += fuckCount; break; case "sadist": r += `usually pairing off with a masochistic slave willing to accept ${his} abuse. `; SimpleSexAct.Slave(slave, 7); if (canPenetrate(slave)) { fuckCount = jsRandom(1, 3); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } break; case "masochist": @@ -1362,7 +1433,8 @@ $(function() { if (largeDicks(slave, 30)) { r += `<span class="lime">${His} asshole is loosened,</span> since ${he} begs hung slaves to fuck ${his} butt until ${he} cries. `; slave.anus++; - slave.counter.anal += 3, V.analTotal += 3; + slave.counter.anal += 3; + V.analTotal += 3; if (hugeDicks(slave, 30)) { r += `Since ${he} eagerly begs hung slaves to fuck ${him} until ${he} cries, <span class="lime">${his} cunt gets stretched out .</span>`; slave.vagina++; @@ -1376,7 +1448,8 @@ $(function() { SimpleSexAct.Slave(slave, 6); if (canPenetrate(slave)) { fuckCount = jsRandom(1, 3); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } break; case "pregnancy": @@ -1385,19 +1458,22 @@ $(function() { if (hugeDicks(slave, 40)) { r += `${He} also takes cock whenever ${he} can, begging to be fucked deeply to get ${his} womb filled with cum, so <span class="lime">${his} cunt gets stretched out. </span>`; slave.vagina++; - slave.counter.vagina += 3, V.vaginalTotal += 3; + slave.counter.vagina += 3; + V.vaginalTotal += 3; } } else { if (hugeDicks(slave, 40)) { r += `${He} also takes cock whenever ${he} can, begging to be fucked deeply to get ${his} womb filled with cum, so <span class="lime">${his} ass gets stretched out. </span>`; slave.anus++; - slave.counter.anal += 3, V.analTotal += 3; + slave.counter.anal += 3; + V.analTotal += 3; } } SimpleSexAct.Slave(slave, 7); if (canPenetrate(slave)) { fuckCount = jsRandom(6, 9); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } break; default: @@ -1406,24 +1482,28 @@ $(function() { if (largeDicks(slave, 30)) { r += `<span class="lime">${His} asshole is loosened</span> during sex with well endowed slaves, since ${he}'s so addicted to sex all ${his} holes see heavy traffic. `; slave.anus++; - slave.counter.anal += 3, V.analTotal += 3; + slave.counter.anal += 3; + V.analTotal += 3; if (hugeDicks(slave, 30)) { r += `${He} indulges in non-stop sex with your well endowed slaves, so much so that <span class="lime">${his} cunt gets stretched out. </span>`; slave.vagina++; - slave.counter.vaginal += 3, V.vaginalTotal += 3; + slave.counter.vaginal += 3; + V.vaginalTotal += 3; } } SimpleSexAct.Slave(slave, 7); if (canPenetrate(slave)) { fuckCount = jsRandom(3, 6); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } } else { r += `doing ${his} best to get off and move on. `; SimpleSexAct.Slave(slave, 7); if (canPenetrate(slave)) { fuckCount = jsRandom(3, 6); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } } break; @@ -1433,7 +1513,8 @@ $(function() { SimpleSexAct.Slave(slave, 7); if (canPenetrate(slave)) { fuckCount = jsRandom(3, 6); - slave.counter.penetrative += fuckCount, V.penetrativeTotal += fuckCount; + slave.counter.penetrative += fuckCount; + V.penetrativeTotal += fuckCount; } } @@ -1442,10 +1523,10 @@ $(function() { function consentDiscoversFetish(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``; @@ -1474,7 +1555,9 @@ $(function() { case "boobs": r += `fondles ${his} breasts, and ${he} loves it; <span class="lightcoral">${he}'s a boob fetishist!</span>`; if (slave.lactation) { - slave.lactationDuration = 2, slave.boobs -= slave.boobsMilk, slave.boobsMilk = 0; + slave.lactationDuration = 2; + slave.boobs -= slave.boobsMilk; + slave.boobsMilk = 0; } else { induceLactation(slave); } @@ -1506,10 +1589,10 @@ $(function() { function permissiveDrugEffects(slave) { const - { + { // eslint-disable-next-line no-unused-vars - he, him, his, hers, himself, boy, He, His - } = getPronouns(slave); + he, him, his, hers, himself, boy, He, His + } = getPronouns(slave); let r = ``; diff --git a/src/endWeek/saServeThePublic.js b/src/endWeek/saServeThePublic.js index ae046a5bbf7..279e166e739 100644 --- a/src/endWeek/saServeThePublic.js +++ b/src/endWeek/saServeThePublic.js @@ -1,6 +1,6 @@ window.saServeThePublic = (function saServeThePublic() { "use strict"; - + let T; let r; let arcology; diff --git a/src/endWeek/saWhore.js b/src/endWeek/saWhore.js index 1d96fc5f3fa..e9f2ce3b42a 100644 --- a/src/endWeek/saWhore.js +++ b/src/endWeek/saWhore.js @@ -1,6 +1,6 @@ window.saWhore = (function saWhore() { "use strict"; - + let T; let r; let arcology; @@ -480,7 +480,7 @@ window.saWhore = (function saWhore() { } else { let canA = canDoAnal(slave); let canV = canDoVaginal(slave); - let skilltarget = (100 + ((slave.skill.anal - 100)*canA*(1.5 - .5*canV) + (slave.skill.vaginal - 100)*canV*(1.5 - .5*canA) + (slave.skill.oral - 100)*(3 - 1.5*canA - 1.5*canV + canA*canV))*3/10); + let skilltarget = (100 + ((slave.skill.anal - 100)*canA*(1.5 - 0.5*canV) + (slave.skill.vaginal - 100)*canV*(1.5 - 0.5*canA) + (slave.skill.oral - 100)*(3 - 1.5*canA - 1.5*canV + canA*canV))*3/10); // Complicated, I know - but it should automatically account for what acts are possible to scale the injury risk smoothly between 90% when totally unskilled // and 0% when perfectly skilled in the relevant method or methods. if (jsRandom(1, 100) > skilltarget) { diff --git a/src/endWeek/saWorkAGloryHole.js b/src/endWeek/saWorkAGloryHole.js index 19cb42461f0..2a2f510f60c 100644 --- a/src/endWeek/saWorkAGloryHole.js +++ b/src/endWeek/saWorkAGloryHole.js @@ -1,6 +1,6 @@ window.saWorkAGloryHole = (function saWorkAGloryHole() { "use strict"; - + let T; let r; let beauty; -- GitLab