Skip to content

Commit

Permalink
ui: fix wowhead tooltip when first gems are missing
Browse files Browse the repository at this point in the history
Signed-off-by: jarves <[email protected]>
  • Loading branch information
jarveson committed Nov 13, 2023
1 parent 5c9b71f commit 89dd236
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ui/core/components/exporters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class IndividualWowheadGearPlannerExporter<SpecType extends Spec> extends
slotId = slotId | 0b10000000;
}
bytes.push(slotId);
bytes.push(item.curGems(isBlacksmithing).length << 5);
bytes.push(item.curEquippedGems(isBlacksmithing).length << 5);
bytes = bytes.concat(to2Bytes(item.item.id));

if (item.enchant) {
Expand Down
7 changes: 5 additions & 2 deletions ui/core/proto_utils/equipped_item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,11 @@ export class EquippedItem {
return this.hasExtraSocket(isBlacksmithing) ? this._item.gemSockets.concat([GemColor.GemColorPrismatic]) : this._item.gemSockets;
}

curGems(isBlacksmithing: boolean): Array<Gem> {
return (this._gems.filter(g => g != null) as Array<Gem>).slice(0, this.numSockets(isBlacksmithing));
curGems(isBlacksmithing: boolean): Array<Gem|null> {
return this._gems.slice(0, this.numSockets(isBlacksmithing));
}
curEquippedGems(isBlacksmithing: boolean): Array<Gem> {
return this.curGems(isBlacksmithing).filter(g => g != null) as Array<Gem>;
}

getProfessionRequirements(): Array<Profession> {
Expand Down
4 changes: 2 additions & 2 deletions ui/core/proto_utils/gear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class Gear extends BaseGear {

getAllGems(isBlacksmithing: boolean): Array<Gem> {
return this.asArray()
.map(ei => ei == null ? [] : ei.curGems(isBlacksmithing))
.map(ei => ei == null ? [] : ei.curEquippedGems(isBlacksmithing))
.flat();
}

Expand Down Expand Up @@ -377,7 +377,7 @@ export class ItemSwapGear extends BaseGear {
return SimDatabase.create({
items: distinct(equippedItems.map(ei => ItemSwapGear.itemToDB(ei.item))),
enchants: distinct(equippedItems.filter(ei => ei.enchant).map(ei => ItemSwapGear.enchantToDB(ei.enchant!))),
gems: distinct(equippedItems.map(ei => ei.curGems(true).map(gem => ItemSwapGear.gemToDB(gem))).flat()),
gems: distinct(equippedItems.map(ei => ei.curEquippedGems(true).map(gem => ItemSwapGear.gemToDB(gem))).flat()),
});
}
}

0 comments on commit 89dd236

Please sign in to comment.