From cab8dbf5d90f6df35a11d78eac9ca35ba73885fe Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 19 Jun 2018 00:37:56 -0400 Subject: [PATCH] made skill calculation smoother --- src/Gang.js | 16 ++++++++-------- src/Player.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Gang.js b/src/Gang.js index d76d950c2..484f61b57 100644 --- a/src/Gang.js +++ b/src/Gang.js @@ -336,17 +336,17 @@ function GangMember(name) { } //Same formula for Player -GangMember.prototype.calculateSkill = function(exp) { - return Math.max(Math.floor(32 * Math.log(exp + 534.5) - 200), 1); +GangMember.prototype.calculateSkill = function(exp, mult=1) { + return Math.max(Math.floor(mult*(32 * Math.log(exp + 534.5) - 200)), 1); } GangMember.prototype.updateSkillLevels = function() { - this.hack = Math.floor(this.calculateSkill(this.hack_exp) * this.hack_mult); - this.str = Math.floor(this.calculateSkill(this.str_exp) * this.str_mult); - this.def = Math.floor(this.calculateSkill(this.def_exp) * this.def_mult); - this.dex = Math.floor(this.calculateSkill(this.dex_exp) * this.dex_mult); - this.agi = Math.floor(this.calculateSkill(this.agi_exp) * this.agi_mult); - this.cha = Math.floor(this.calculateSkill(this.cha_exp) * this.cha_mult); + this.hack = this.calculateSkill(this.hack_exp, this.hack_mult); + this.str = this.calculateSkill(this.str_exp, this.str_mult); + this.def = this.calculateSkill(this.def_exp, this.def_mult); + this.dex = this.calculateSkill(this.dex_exp, this.dex_mult); + this.agi = this.calculateSkill(this.agi_exp, this.agi_mult); + this.cha = this.calculateSkill(this.cha_exp, this.cha_mult); } GangMember.prototype.calculatePower = function() { diff --git a/src/Player.js b/src/Player.js index bdbf12df8..f84cbaa6c 100644 --- a/src/Player.js +++ b/src/Player.js @@ -422,17 +422,17 @@ PlayerObject.prototype.receiveInvite = function(factionName) { } //Calculates skill level based on experience. The same formula will be used for every skill -PlayerObject.prototype.calculateSkill = function(exp) { - return Math.max(Math.floor(32 * Math.log(exp + 534.5) - 200), 1); +PlayerObject.prototype.calculateSkill = function(exp, mult=1) { + return Math.max(Math.floor(mult*(32 * Math.log(exp + 534.5) - 200)), 1); } PlayerObject.prototype.updateSkillLevels = function() { - this.hacking_skill = Math.max(1, Math.floor(this.calculateSkill(this.hacking_exp) * this.hacking_mult * BitNodeMultipliers.HackingLevelMultiplier)); - this.strength = Math.floor(this.calculateSkill(this.strength_exp) * this.strength_mult); - this.defense = Math.floor(this.calculateSkill(this.defense_exp) * this.defense_mult); - this.dexterity = Math.floor(this.calculateSkill(this.dexterity_exp) * this.dexterity_mult); - this.agility = Math.floor(this.calculateSkill(this.agility_exp) * this.agility_mult); - this.charisma = Math.floor(this.calculateSkill(this.charisma_exp) * this.charisma_mult); + this.hacking_skill = Math.max(1, Math.floor(this.calculateSkill(this.hacking_exp, this.hacking_mult) * BitNodeMultipliers.HackingLevelMultiplier)); + this.strength = this.calculateSkill(this.strength_exp, this.strength_mult); + this.defense = this.calculateSkill(this.defense_exp, this.defense_mult); + this.dexterity = this.calculateSkill(this.dexterity_exp, this.dexterity_mult); + this.agility = this.calculateSkill(this.agility_exp, this.agility_mult); + this.charisma = this.calculateSkill(this.charisma_exp, this.charisma_mult); if (this.intelligence > 0) { this.intelligence = Math.floor(this.calculateSkill(this.intelligence_exp));