Skip to content

Commit

Permalink
Merge pull request #342 from xiv-gear-planner/potion-fix
Browse files Browse the repository at this point in the history
Fix potion stat modifications
  • Loading branch information
xpdota authored Oct 7, 2024
2 parents d00c527 + a9b8265 commit 1ef8b8f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/src/sims/common/potion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function makeGemdraught(stat: RawStatKey, grade: GemdraughtGrade): Readon
strength: 44157,
dexterity: 44158,
intelligence: 44160,
}
};
const gradeToStatCap = [351, 392];

return makePotion(`Grade ${grade} Gemdraught of ${camel2title(stat)}`, stat, statToPotItemId[stat], 0.1, gradeToStatCap[grade - 1]);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/sims/sim_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function abilityToDamageNew(stats: ComputedSetStats, ability: Ability, co
}
// noinspection AssignmentToFunctionParameterJS
stats = combinedBuffEffects.modifyStats(stats);
// TODO: can we avoid having all of these separate stat modifications?
return {
directDamage: ability.potency ? potencyToDamage(stats, ability.potency, ability as DamagingAbility, combinedBuffEffects) : null,
dot: 'dot' in ability ? {
Expand Down
30 changes: 30 additions & 0 deletions packages/core/src/test/sims/cycle_processor_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from "@xivgear/core/sims/sim_types";
import {CycleProcessor, CycleSimResult, ExternalCycleSettings, Rotation} from "@xivgear/core/sims/cycle_sim";
import { BaseMultiCycleSim } from '@xivgear/core/sims/processors/sim_processors';
import {gemdraught1mind} from "../../sims/common/potion";

// Example of end-to-end simulation
// This one is testing the simulation engine itself, so it copies the full simulation code rather than
Expand Down Expand Up @@ -1566,4 +1567,33 @@ describe('gcd clipping check', () => {
canUse = cp.canUseWithoutClipping(pom);
assert.equal(canUse, false);
});
});

describe('potion logic', () => {
it('reflects potions', () => {
const cp = new CycleProcessor({
allBuffs: [],
cycleTime: 120,
stats: exampleGearSet.computedStats,
totalTime: 120,
useAutos: false
});
cp.use(filler);
cp.use(gemdraught1mind);
cp.use(filler);
cp.advanceTo(100);
cp.use(filler);
const displayRecords = cp.finalizedRecords;
const actualAbilities: FinalizedAbility[] = displayRecords.filter<FinalizedAbility>((record): record is FinalizedAbility => {
return 'ability' in record;
});
// console.log(actualAbilities);
// Unbuffed skill
assertClose(actualAbilities[0].directDamage, 15057.71, 0.01);
// Buffed skill
assertClose(actualAbilities[2].directDamage, 16627.44, 0.01);
// Unbuffed skill after it falls off
assertClose(actualAbilities[3].directDamage, 15057.71, 0.01);
});

});
1 change: 1 addition & 0 deletions packages/xivmath/src/xivstats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export class ComputedSetStatsImpl implements ComputedSetStats {
this.classJobStats,
this.partyBonus
);
Object.assign(out.finalBonusStats, this.finalBonusStats);
modifications(out, out.finalBonusStats);
return out;
}
Expand Down

0 comments on commit 1ef8b8f

Please sign in to comment.