From 2ce4af24982ca8e5d9061d4805b24c4f918ac7fb Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Sat, 23 Mar 2019 14:27:11 -0400 Subject: [PATCH] infiltration now scale exp gained by some factor to prevent some abuse --- src/Constants.ts | 1 + src/Infiltration.js | 52 +++++++++++++++++++++++++++++++++++----- utils/InfiltrationBox.js | 27 ++++++++++----------- 3 files changed, 60 insertions(+), 20 deletions(-) diff --git a/src/Constants.ts b/src/Constants.ts index 6f376fa50..a34343427 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -126,6 +126,7 @@ export let CONSTANTS: IMap = { InfiltrationBribeBaseAmount: 100e3, //Amount per clearance level InfiltrationMoneyValue: 5e3, //Convert "secret" value to money InfiltrationRepValue: 1.4, //Convert "secret" value to faction reputation + InfiltrationExpPow: 0.7, //Stock market constants WSEAccountCost: 200e6, diff --git a/src/Infiltration.js b/src/Infiltration.js index 697481b74..d856d8252 100644 --- a/src/Infiltration.js +++ b/src/Infiltration.js @@ -52,41 +52,81 @@ function InfiltrationInstance(companyName, startLevel, val, maxClearance, diff) this.intExpGained = 0; } +InfiltrationInstance.prototype.expMultiplier = function() { + if (!this.clearanceLevel || isNaN(this.clearanceLevel) || !this.maxClearanceLevel ||isNaN(this.maxClearanceLevel)) return 1; + return 2 * this.clearanceLevel / this.maxClearanceLevel; +} + InfiltrationInstance.prototype.gainHackingExp = function(amt) { if (isNaN(amt)) {return;} this.hackingExpGained += amt; } +InfiltrationInstance.prototype.calcGainedHackingExp = function() { + if(!this.hackingExpGained || isNaN(this.hackingExpGained)) return 0; + return Math.pow(this.hackingExpGained*this.expMultiplier(), CONSTANTS.InfiltrationExpPow); +} + InfiltrationInstance.prototype.gainStrengthExp = function(amt) { if (isNaN(amt)) {return;} this.strExpGained += amt; } +InfiltrationInstance.prototype.calcGainedStrengthExp = function() { + if(!this.strExpGained || isNaN(this.strExpGained)) return 0; + return Math.pow(this.strExpGained*this.expMultiplier(), CONSTANTS.InfiltrationExpPow); +} + InfiltrationInstance.prototype.gainDefenseExp = function(amt) { if (isNaN(amt)) {return;} this.defExpGained += amt; } +InfiltrationInstance.prototype.calcGainedDefenseExp = function() { + if(!this.defExpGained || isNaN(this.defExpGained)) return 0; + return Math.pow(this.defExpGained*this.expMultiplier(), CONSTANTS.InfiltrationExpPow); +} + InfiltrationInstance.prototype.gainDexterityExp = function(amt) { if (isNaN(amt)) {return;} this.dexExpGained += amt; } +InfiltrationInstance.prototype.calcGainedDexterityExp = function() { + if(!this.dexExpGained || isNaN(this.dexExpGained)) return 0; + return Math.pow(this.dexExpGained*this.expMultiplier(), CONSTANTS.InfiltrationExpPow); +} + InfiltrationInstance.prototype.gainAgilityExp = function(amt) { if (isNaN(amt)) {return;} this.agiExpGained += amt; } +InfiltrationInstance.prototype.calcGainedAgilityExp = function() { + if(!this.agiExpGained || isNaN(this.agiExpGained)) return 0; + return Math.pow(this.agiExpGained*this.expMultiplier(), CONSTANTS.InfiltrationExpPow); +} + InfiltrationInstance.prototype.gainCharismaExp = function(amt) { if (isNaN(amt)) {return;} this.chaExpGained += amt; } +InfiltrationInstance.prototype.calcGainedCharismaExp = function() { + if(!this.chaExpGained || isNaN(this.chaExpGained)) return 0; + return Math.pow(this.chaExpGained*this.expMultiplier(), CONSTANTS.InfiltrationExpPow); +} + InfiltrationInstance.prototype.gainIntelligenceExp = function(amt) { if (isNaN(amt)) {return;} this.intExpGained += amt; } +InfiltrationInstance.prototype.calcGainedIntelligenceExp = function() { + if(!this.intExpGained || isNaN(this.intExpGained)) return 0; + return Math.pow(this.intExpGained*this.expMultiplier(), CONSTANTS.InfiltrationExpPow); +} + function beginInfiltration(companyName, startLevel, val, maxClearance, diff) { var inst = new InfiltrationInstance(companyName, startLevel, val, maxClearance, diff); clearInfiltrationStatusText(); @@ -477,12 +517,12 @@ function updateInfiltrationLevelText(inst) { "Total value of stolen secrets
" + "Reputation:       " + formatNumber(totalValue, 3) + "
" + "Money:           $" + formatNumber(totalMoneyValue, 2) + "

" + - "Hack exp gained:  " + formatNumber(inst.hackingExpGained * expMultiplier, 3) + "
" + - "Str exp gained:   " + formatNumber(inst.strExpGained * expMultiplier, 3) + "
" + - "Def exp gained:   " + formatNumber(inst.defExpGained * expMultiplier, 3) + "
" + - "Dex exp gained:   " + formatNumber(inst.dexExpGained * expMultiplier, 3) + "
" + - "Agi exp gained:   " + formatNumber(inst.agiExpGained * expMultiplier, 3) + "
" + - "Cha exp gained:   " + formatNumber(inst.chaExpGained * expMultiplier, 3); + "Hack exp gained:  " + formatNumber(inst.calcGainedHackingExp(), 3) + "
" + + "Str exp gained:   " + formatNumber(inst.calcGainedStrengthExp(), 3) + "
" + + "Def exp gained:   " + formatNumber(inst.calcGainedDefenseExp(), 3) + "
" + + "Dex exp gained:   " + formatNumber(inst.calcGainedDexterityExp(), 3) + "
" + + "Agi exp gained:   " + formatNumber(inst.calcGainedAgilityExp(), 3) + "
" + + "Cha exp gained:   " + formatNumber(inst.calcGainedCharismaExp(), 3); /* eslint-enable no-irregular-whitespace */ } diff --git a/utils/InfiltrationBox.js b/utils/InfiltrationBox.js index fb922fc63..59db25098 100644 --- a/utils/InfiltrationBox.js +++ b/utils/InfiltrationBox.js @@ -30,22 +30,21 @@ function infiltrationSetText(txt) { //ram argument is in GB function infiltrationBoxCreate(inst) { //Gain exp - var expMultiplier = 2 * inst.clearanceLevel / inst.maxClearanceLevel; - Player.gainHackingExp(inst.hackingExpGained * expMultiplier); - Player.gainStrengthExp(inst.strExpGained * expMultiplier); - Player.gainDefenseExp(inst.defExpGained * expMultiplier); - Player.gainDexterityExp(inst.dexExpGained * expMultiplier); - Player.gainAgilityExp(inst.agiExpGained * expMultiplier); - Player.gainCharismaExp(inst.chaExpGained * expMultiplier); - Player.gainIntelligenceExp(inst.intExpGained * expMultiplier); + Player.gainHackingExp(inst.calcGainedHackingExp()); + Player.gainStrengthExp(inst.calcGainedStrengthExp()); + Player.gainDefenseExp(inst.calcGainedDefenseExp()); + Player.gainDexterityExp(inst.calcGainedDexterityExp()); + Player.gainAgilityExp(inst.calcGainedAgilityExp()); + Player.gainCharismaExp(inst.calcGainedCharismaExp()); + Player.gainIntelligenceExp(inst.calcGainedIntelligenceExp()); const expGainText = ["You gained:", - `${formatNumber(inst.hackingExpGained * expMultiplier, 3)} hacking exp`, - `${formatNumber(inst.strExpGained * expMultiplier, 3)} str exp`, - `${formatNumber(inst.defExpGained * expMultiplier, 3)} def exp`, - `${formatNumber(inst.dexExpGained * expMultiplier, 3)} dex exp`, - `${formatNumber(inst.agiExpGained * expMultiplier, 3)} agi exp`, - `${formatNumber(inst.chaExpGained * expMultiplier, 3)} cha exp`].join("\n"); + `${formatNumber(inst.calcGainedHackingExp(), 3)} hacking exp`, + `${formatNumber(inst.calcGainedStrengthExp(), 3)} str exp`, + `${formatNumber(inst.calcGainedDefenseExp(), 3)} def exp`, + `${formatNumber(inst.calcGainedDexterityExp(), 3)} dex exp`, + `${formatNumber(inst.calcGainedAgilityExp(), 3)} agi exp`, + `${formatNumber(inst.calcGainedCharismaExp(), 3)} cha exp`].join("\n"); var totalValue = 0; for (var i = 0; i < inst.secretsStolen.length; ++i) {