Skip to content

Commit

Permalink
fix(core): fixed float32 precision again...
Browse files Browse the repository at this point in the history
  • Loading branch information
Supamiu committed Jan 4, 2022
1 parent 076b0f4 commit 0bb70db
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/model/actions/crafting-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
34 changes: 19 additions & 15 deletions test/simulation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 0bb70db

Please sign in to comment.