From 0bb70db08d8232661c2a88dbc2df6bdab536b71c Mon Sep 17 00:00:00 2001 From: Supamiu Date: Tue, 4 Jan 2022 20:58:24 +0100 Subject: [PATCH] fix(core): fixed float32 precision again... --- src/model/actions/crafting-action.ts | 4 ++-- test/simulation.spec.ts | 34 ++++++++++++++++------------ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/model/actions/crafting-action.ts b/src/model/actions/crafting-action.ts index 1c8ce0a6..3b97376d 100644 --- a/src/model/actions/crafting-action.ts +++ b/src/model/actions/crafting-action.ts @@ -177,7 +177,7 @@ export abstract class CraftingAction { const stats = simulation.crafterStats; const baseValue = (stats.craftsmanship * 10) / simulation.recipe.progressDivider + 2; if (Tables.LEVEL_TABLE[stats.level] <= simulation.recipe.rlvl) { - return (baseValue * (simulation.recipe.progressModifier || 100)) / 100; + return baseValue * (simulation.recipe.progressModifier || 100) * Math.fround(0.01); } return baseValue; } @@ -186,7 +186,7 @@ export abstract class CraftingAction { const stats = simulation.crafterStats; const baseValue = (stats.getControl(simulation) * 10) / simulation.recipe.qualityDivider + 35; if (Tables.LEVEL_TABLE[stats.level] <= simulation.recipe.rlvl) { - return (baseValue * (simulation.recipe.qualityModifier || 100)) / 100; + return baseValue * (simulation.recipe.qualityModifier || 100) * Math.fround(0.01); } return baseValue; } diff --git a/test/simulation.spec.ts b/test/simulation.spec.ts index 2f912abf..a212b9ad 100644 --- a/test/simulation.spec.ts +++ b/test/simulation.spec.ts @@ -105,6 +105,25 @@ describe('Craft simulator tests', () => { simulation.run(true); expect(simulation.quality).toBe(827); + + const simulation2 = new Simulation( + generateStarRecipe(580, 3900, 10920, 130, 115, 80, 70), + [ + new MuscleMemory(), + new Veneration(), + new Groundwork(), + new Groundwork(), + new Observe(), + new Observe(), + new CarefulSynthesis(), + ], + generateStats(90, 3289, 3420, 400) + ); + + simulation2.run(true); + + expect(simulation2.steps[0].addedProgression).toBe(609); + expect(simulation2.progression).toBe(3897); }); it('Should not combo AdvancedTouch if StandardTouch was not combo itself', () => { @@ -262,21 +281,6 @@ describe('Craft simulator tests', () => { expect(result2.simulation.durability).toBe(70 - 3); }); - it('Should use floor correctly with MALLEABLE step state', () => { - const simulation = new Simulation( - generateStarRecipe(513, 12046, 81447, 140, 130, 80, 70, true), - [new Veneration(), new RapidSynthesis()], - generateStats(80, 2763, 2800, 554), - [], - { - 1: StepState.MALLEABLE, - } - ); - - const result = simulation.run(true); - expect(result.simulation.progression).toBe(2238); - }); - xit('Should floor control bonuses properly', () => { const simulation = new Simulation( generateRecipe(480, 6178, 36208, 110, 90),