Skip to content

Commit

Permalink
Merge pull request #1284 from wowsims/fix/suggest-reforge-error-fallback
Browse files Browse the repository at this point in the history
[UI] Add previous gear fallback on error
  • Loading branch information
1337LutZ authored Jan 3, 2025
2 parents d35ff71 + f86a8f7 commit 7a31a51
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ui/core/components/suggest_reforges_action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class ReforgeOptimizer {
readonly freezeItemSlotsChangeEmitter = new TypedEvent<void>();
protected freezeItemSlots = false;
protected frozenItemSlots = new Map<ItemSlot, boolean>();
protected previousGear: Gear | null = null;
protected previousReforges = new Map<ItemSlot, ReforgeData>();
protected currentReforges = new Map<ItemSlot, ReforgeData>();

Expand Down Expand Up @@ -742,9 +743,9 @@ export class ReforgeOptimizer {
console.log('The following slots will not be cleared:');
console.log(Array.from(this.frozenItemSlots.keys()).filter(key => this.frozenItemSlots.get(key)));
}
const previousGear = this.player.getGear();
this.previousReforges = previousGear.getAllReforges();
const baseGear = previousGear.withoutReforges(this.player.canDualWield2H(), this.frozenItemSlots);
this.previousGear = this.player.getGear();
this.previousReforges = this.previousGear.getAllReforges();
const baseGear = this.previousGear.withoutReforges(this.player.canDualWield2H(), this.frozenItemSlots);
const baseStats = await this.updateGear(baseGear);

// Compute effective stat caps for just the Reforge contribution
Expand Down Expand Up @@ -916,10 +917,15 @@ export class ReforgeOptimizer {
tolerance: 0.01,
};
const solution = solve(model, options);

if (isDevMode()) {
console.log('LP solution for this iteration:');
console.log(solution);
}

if (solution.status === 'timedout') {
throw solution
}
// Apply the current solution
const updatedGear = await this.applyLPSolution(gear, solution);

Expand Down Expand Up @@ -1172,6 +1178,7 @@ export class ReforgeOptimizer {
onReforgeError(error: any) {
if (isDevMode()) console.log(error);

if (this.previousGear) this.updateGear(this.previousGear);
new Toast({
variant: 'error',
body: 'Reforge optimization failed. Please try again, or report the issue if it persists.',
Expand Down

0 comments on commit 7a31a51

Please sign in to comment.