From c4d932ec40eaa62230c5295917067f40bbbd1984 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sat, 8 Apr 2023 23:31:37 +0300 Subject: [PATCH] Fix Beakon Sub Power Up calculation Closes #1323 --- .../build-analyzer/core/stats.test.ts | 26 +++++++++++++++++ app/features/build-analyzer/core/stats.ts | 29 ++++++++++++------- app/features/build-analyzer/core/utils.ts | 2 +- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/app/features/build-analyzer/core/stats.test.ts b/app/features/build-analyzer/core/stats.test.ts index b23a91c0e..124df1516 100644 --- a/app/features/build-analyzer/core/stats.test.ts +++ b/app/features/build-analyzer/core/stats.test.ts @@ -103,4 +103,30 @@ AnalyzeBuild( } ); +const subPowerApToQuickSuperJumpAp = new Map([ + [0, 0], + [3, 4], + [6, 9], + [13, 18], + [28, 36], + [57, 57], +]); + +AnalyzeBuild("Sub Power Up Beakon AP boost matches Lean", () => { + for (const [subPowerAp, quickSuperJumpAp] of subPowerApToQuickSuperJumpAp) { + const analyzed = buildStats({ + weaponSplId: 1011, + abilityPoints: new Map([["BRU" as const, subPowerAp]]), + hasTacticooler: false, + }); + + assert.ok( + analyzed.stats.subQsjBoost?.value === quickSuperJumpAp, + `Wrong AP boost for ${subPowerAp}AP of Sub Power Up: ${ + analyzed.stats.subQsjBoost!.value + } (expected ${quickSuperJumpAp}))` + ); + } +}); + AnalyzeBuild.run(); diff --git a/app/features/build-analyzer/core/stats.ts b/app/features/build-analyzer/core/stats.ts index fd9a11e48..7a8d2c877 100644 --- a/app/features/build-analyzer/core/stats.ts +++ b/app/features/build-analyzer/core/stats.ts @@ -19,6 +19,7 @@ import { INK_CONSUME_TYPES } from "../analyzer-types"; import invariant from "tiny-invariant"; import { abilityPointsToEffects, + abilityValues, apFromMap, hasEffect, hpDivided, @@ -1142,18 +1143,26 @@ function subQsjBoost( } const SUB_QSJ_BOOST_KEY = "BRU"; - const { baseEffect, effect } = abilityPointsToEffects({ - abilityPoints: apFromMap({ - abilityPoints: args.abilityPoints, - ability: SUB_QSJ_BOOST_KEY, - }), - key: "SubSpecUpParam", - weapon: args.subWeaponParams, - }); + + // Lean: This is the base that is used with their weird formula (I didn't even bother renaming the vars and just used what my disassembler gave me) + const calculate = (ap: number) => { + const multiplier = abilityValues({ + key: "SubSpecUpParam", + weapon: args.subWeaponParams, + }); + + const v7 = + ((multiplier[1] - multiplier[2]) / multiplier[0] - 17.8 / multiplier[0]) / + ((17.8 / multiplier[0]) * (17.8 / multiplier[0] + -1.0)); + + const v8 = (ap / multiplier[0]) * ((ap / multiplier[0]) * v7 + (1.0 - v7)); + + return Math.floor(multiplier[2] + (multiplier[0] - multiplier[2]) * v8); + }; return { - baseValue: Math.floor(baseEffect), - value: Math.floor(effect), + baseValue: calculate(0), + value: calculate(args.abilityPoints.get(SUB_QSJ_BOOST_KEY) ?? 0), modifiedBy: SUB_QSJ_BOOST_KEY, }; } diff --git a/app/features/build-analyzer/core/utils.ts b/app/features/build-analyzer/core/utils.ts index 09498ba4c..2fd9aa0ee 100644 --- a/app/features/build-analyzer/core/utils.ts +++ b/app/features/build-analyzer/core/utils.ts @@ -69,7 +69,7 @@ export function apFromMap({ return abilityPoints.get(ability) ?? 0; } -function abilityValues({ +export function abilityValues({ key, weapon, }: {