infiltration now scale exp gained by some factor to prevent some abuse

This commit is contained in:
Olivier Gagnon 2019-03-23 14:27:11 -04:00 committed by danielyxie
parent 227bcf146e
commit 2ce4af2498
3 changed files with 60 additions and 20 deletions

@ -126,6 +126,7 @@ export let CONSTANTS: IMap<any> = {
InfiltrationBribeBaseAmount: 100e3, //Amount per clearance level InfiltrationBribeBaseAmount: 100e3, //Amount per clearance level
InfiltrationMoneyValue: 5e3, //Convert "secret" value to money InfiltrationMoneyValue: 5e3, //Convert "secret" value to money
InfiltrationRepValue: 1.4, //Convert "secret" value to faction reputation InfiltrationRepValue: 1.4, //Convert "secret" value to faction reputation
InfiltrationExpPow: 0.7,
//Stock market constants //Stock market constants
WSEAccountCost: 200e6, WSEAccountCost: 200e6,

@ -52,41 +52,81 @@ function InfiltrationInstance(companyName, startLevel, val, maxClearance, diff)
this.intExpGained = 0; 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) { InfiltrationInstance.prototype.gainHackingExp = function(amt) {
if (isNaN(amt)) {return;} if (isNaN(amt)) {return;}
this.hackingExpGained += amt; 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) { InfiltrationInstance.prototype.gainStrengthExp = function(amt) {
if (isNaN(amt)) {return;} if (isNaN(amt)) {return;}
this.strExpGained += amt; 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) { InfiltrationInstance.prototype.gainDefenseExp = function(amt) {
if (isNaN(amt)) {return;} if (isNaN(amt)) {return;}
this.defExpGained += amt; 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) { InfiltrationInstance.prototype.gainDexterityExp = function(amt) {
if (isNaN(amt)) {return;} if (isNaN(amt)) {return;}
this.dexExpGained += amt; 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) { InfiltrationInstance.prototype.gainAgilityExp = function(amt) {
if (isNaN(amt)) {return;} if (isNaN(amt)) {return;}
this.agiExpGained += amt; 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) { InfiltrationInstance.prototype.gainCharismaExp = function(amt) {
if (isNaN(amt)) {return;} if (isNaN(amt)) {return;}
this.chaExpGained += amt; 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) { InfiltrationInstance.prototype.gainIntelligenceExp = function(amt) {
if (isNaN(amt)) {return;} if (isNaN(amt)) {return;}
this.intExpGained += amt; 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) { function beginInfiltration(companyName, startLevel, val, maxClearance, diff) {
var inst = new InfiltrationInstance(companyName, startLevel, val, maxClearance, diff); var inst = new InfiltrationInstance(companyName, startLevel, val, maxClearance, diff);
clearInfiltrationStatusText(); clearInfiltrationStatusText();
@ -477,12 +517,12 @@ function updateInfiltrationLevelText(inst) {
"Total value of stolen secrets<br>" + "Total value of stolen secrets<br>" +
"Reputation:       <span class='light-yellow'>" + formatNumber(totalValue, 3) + "</span><br>" + "Reputation:       <span class='light-yellow'>" + formatNumber(totalValue, 3) + "</span><br>" +
"Money:           <span class='money-gold'>$" + formatNumber(totalMoneyValue, 2) + "</span><br><br>" + "Money:           <span class='money-gold'>$" + formatNumber(totalMoneyValue, 2) + "</span><br><br>" +
"Hack exp gained:  " + formatNumber(inst.hackingExpGained * expMultiplier, 3) + "<br>" + "Hack exp gained:  " + formatNumber(inst.calcGainedHackingExp(), 3) + "<br>" +
"Str exp gained:   " + formatNumber(inst.strExpGained * expMultiplier, 3) + "<br>" + "Str exp gained:   " + formatNumber(inst.calcGainedStrengthExp(), 3) + "<br>" +
"Def exp gained:   " + formatNumber(inst.defExpGained * expMultiplier, 3) + "<br>" + "Def exp gained:   " + formatNumber(inst.calcGainedDefenseExp(), 3) + "<br>" +
"Dex exp gained:   " + formatNumber(inst.dexExpGained * expMultiplier, 3) + "<br>" + "Dex exp gained:   " + formatNumber(inst.calcGainedDexterityExp(), 3) + "<br>" +
"Agi exp gained:   " + formatNumber(inst.agiExpGained * expMultiplier, 3) + "<br>" + "Agi exp gained:   " + formatNumber(inst.calcGainedAgilityExp(), 3) + "<br>" +
"Cha exp gained:   " + formatNumber(inst.chaExpGained * expMultiplier, 3); "Cha exp gained:   " + formatNumber(inst.calcGainedCharismaExp(), 3);
/* eslint-enable no-irregular-whitespace */ /* eslint-enable no-irregular-whitespace */
} }

@ -30,22 +30,21 @@ function infiltrationSetText(txt) {
//ram argument is in GB //ram argument is in GB
function infiltrationBoxCreate(inst) { function infiltrationBoxCreate(inst) {
//Gain exp //Gain exp
var expMultiplier = 2 * inst.clearanceLevel / inst.maxClearanceLevel; Player.gainHackingExp(inst.calcGainedHackingExp());
Player.gainHackingExp(inst.hackingExpGained * expMultiplier); Player.gainStrengthExp(inst.calcGainedStrengthExp());
Player.gainStrengthExp(inst.strExpGained * expMultiplier); Player.gainDefenseExp(inst.calcGainedDefenseExp());
Player.gainDefenseExp(inst.defExpGained * expMultiplier); Player.gainDexterityExp(inst.calcGainedDexterityExp());
Player.gainDexterityExp(inst.dexExpGained * expMultiplier); Player.gainAgilityExp(inst.calcGainedAgilityExp());
Player.gainAgilityExp(inst.agiExpGained * expMultiplier); Player.gainCharismaExp(inst.calcGainedCharismaExp());
Player.gainCharismaExp(inst.chaExpGained * expMultiplier); Player.gainIntelligenceExp(inst.calcGainedIntelligenceExp());
Player.gainIntelligenceExp(inst.intExpGained * expMultiplier);
const expGainText = ["You gained:", const expGainText = ["You gained:",
`${formatNumber(inst.hackingExpGained * expMultiplier, 3)} hacking exp`, `${formatNumber(inst.calcGainedHackingExp(), 3)} hacking exp`,
`${formatNumber(inst.strExpGained * expMultiplier, 3)} str exp`, `${formatNumber(inst.calcGainedStrengthExp(), 3)} str exp`,
`${formatNumber(inst.defExpGained * expMultiplier, 3)} def exp`, `${formatNumber(inst.calcGainedDefenseExp(), 3)} def exp`,
`${formatNumber(inst.dexExpGained * expMultiplier, 3)} dex exp`, `${formatNumber(inst.calcGainedDexterityExp(), 3)} dex exp`,
`${formatNumber(inst.agiExpGained * expMultiplier, 3)} agi exp`, `${formatNumber(inst.calcGainedAgilityExp(), 3)} agi exp`,
`${formatNumber(inst.chaExpGained * expMultiplier, 3)} cha exp`].join("\n"); `${formatNumber(inst.calcGainedCharismaExp(), 3)} cha exp`].join("\n");
var totalValue = 0; var totalValue = 0;
for (var i = 0; i < inst.secretsStolen.length; ++i) { for (var i = 0; i < inst.secretsStolen.length; ++i) {