Round sub velocity to thousandths place, fix bug in round function (Fixes #1348) (#1353)

* Round velocity to thousandths place, fix bug in round function

* Prettier application
This commit is contained in:
PM.Net JDS 2023-04-22 04:31:35 -04:00 committed by GitHub
parent 25391899b4
commit 40e56d2b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -1040,7 +1040,7 @@ const SUB_WEAPON_STATS = [
{
analyzedBuildKey: "subVelocity",
abilityValuesKey: "SpawnSpeedZSpecUp",
type: "NO_CHANGE",
type: "SUB_VELOCITY",
},
{
analyzedBuildKey: "subFirstPhaseDuration",
@ -1092,6 +1092,8 @@ export function subStats(
switch (type) {
case "NO_CHANGE":
return roundToNDecimalPlaces(effect);
case "SUB_VELOCITY":
return roundToNDecimalPlaces(effect, 3);
case "HP":
return roundToNDecimalPlaces(hpDivided(effect), 1);
case "TIME":

View File

@ -1,5 +1,5 @@
export function roundToNDecimalPlaces(num: number, n = 2) {
return Number((Math.round(num * 100) / 100).toFixed(n));
return Number((Math.round(num * 10 ** n) / 10 ** n).toFixed(n));
}
export function cutToNDecimalPlaces(num: number, n = 2) {