Skip to content

Commit

Permalink
Merge pull request xiv-gear-planner#181 from xiv-gear-planner/fix-dot…
Browse files Browse the repository at this point in the history
…-tick-variance

Fix variance calc for DoT ticks
  • Loading branch information
xpdota authored Jul 3, 2024
2 parents 77fcf88 + 2ee47bc commit f27b7db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/sims/cycle_sim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
STANDARD_ANIMATION_LOCK
} from "@xivgear/xivmath/xivconstants";
import {CooldownMode, CooldownTracker} from "./common/cooldown_manager";
import {addValues, fixedValue, multiplyFixed, ValueWithDev} from "@xivgear/xivmath/deviation";
import {addValues, fixedValue, multiplyFixed, multiplyIndependent, ValueWithDev} from "@xivgear/xivmath/deviation";
import {abilityEquals, appDelay, completeComboData, FinalizedComboData} from "./ability_helpers";
import {abilityToDamageNew, combineBuffEffects} from "./sim_utils";
import {BuffSettingsExport} from "./common/party_comp_settings";
Expand Down Expand Up @@ -670,7 +670,7 @@ export class CycleProcessor {
const partialRate = record.totalTimeTaken > 0 ? Math.max(0, Math.min(1, (this.totalTime - record.usedAt) / record.totalTimeTaken)) : 1;
const directDamage = multiplyFixed(record.directDamage, partialRate);
const dot = record.dot;
const dotDmg = dot ? multiplyFixed(dot.damagePerTick, dot.actualTickCount) : fixedValue(0);
const dotDmg = dot ? multiplyIndependent(dot.damagePerTick, dot.actualTickCount) : fixedValue(0);
const totalDamage = addValues(directDamage, dotDmg);
const totalPotency = record.ability.potency + ('dot' in record.ability ? record.ability.dot.tickPotency * record.dot.actualTickCount : 0);
return {
Expand Down
14 changes: 13 additions & 1 deletion packages/xivmath/src/test/std_dev_tests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expect} from 'chai';
import {addValues, multiplyValues, ValueWithDev} from "../deviation";
import {addValues, multiplyIndependent, multiplyValues, ValueWithDev} from "../deviation";

describe('ValueWithDev calculations', () => {

Expand Down Expand Up @@ -84,5 +84,17 @@ describe('ValueWithDev calculations', () => {
expect(result.stdDev).to.be.closeTo(Math.sqrt(expectedVariance), 0.000000001);
});
});
describe('multiplyIndependent', () => {
it('should return expected value and standard deviation for independent values', () => {
const value: ValueWithDev = {
expected: 10,
stdDev: 5
};
const result1 = multiplyIndependent(value, 4);
expect(result1.expected).to.equal(40); // 2 * 4 * 5
expect(result1.stdDev).to.equal(10); // 2 * 4 * 5
});

});

});

0 comments on commit f27b7db

Please sign in to comment.