Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shamans and hunters can dual wield all the time #87

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions ui/core/components/gear_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
// eslint-disable-next-line unused-imports/no-unused-imports
import { element, fragment, ref } from 'tsx-vanilla';

import { canDualWield, itemTypeToSlotsMap } from '../proto_utils/utils.js';
import { itemTypeToSlotsMap } from '../proto_utils/utils.js';
import { Clusterize } from './virtual_scroll/clusterize.js';

const EP_TOOLTIP = `
Expand Down Expand Up @@ -263,17 +263,6 @@ export class ItemPicker extends Component {
});

player.levelChangeEmitter.on(loadItems)

// Shamans and Hunters can equip/unequip Dual Wield Specialization so we need to continuously update off-hands
if (slot == ItemSlot.ItemSlotOffHand) {
this.player.runeChangeEmitter.on((_eventId: EventID) => {
loadItems()
if (!canDualWield(player)) {
this.player.equipItem(TypedEvent.nextEventID(), this.slot, null);
}
})
}

player.gearChangeEmitter.on(() => this.item = player.getEquippedItem(slot));
player.professionChangeEmitter.on(() => {
if (this._equippedItem != null) {
Expand Down
14 changes: 2 additions & 12 deletions ui/core/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ export class Player<SpecType extends Spec> {
readonly consumesChangeEmitter = new TypedEvent<void>('PlayerConsumes');
readonly bonusStatsChangeEmitter = new TypedEvent<void>('PlayerBonusStats');
readonly gearChangeEmitter = new TypedEvent<void>('PlayerGear');
readonly runeChangeEmitter = new TypedEvent<void>('PlayerGearRune');
readonly itemSwapChangeEmitter = new TypedEvent<void>('PlayerItemSwap');
readonly professionChangeEmitter = new TypedEvent<void>('PlayerProfession');
readonly raceChangeEmitter = new TypedEvent<void>('PlayerRace');
Expand Down Expand Up @@ -318,7 +317,6 @@ export class Player<SpecType extends Spec> {
this.consumesChangeEmitter,
this.bonusStatsChangeEmitter,
this.gearChangeEmitter,
this.runeChangeEmitter,
this.itemSwapChangeEmitter,
this.professionChangeEmitter,
this.raceChangeEmitter,
Expand Down Expand Up @@ -598,11 +596,7 @@ export class Player<SpecType extends Spec> {
}

equipItem(eventID: EventID, slot: ItemSlot, newItem: EquippedItem | null) {
this.setGear(
eventID,
this.gear.withEquippedItem(slot, newItem, this.canDualWield2H()),
this.gear.getEquippedItem(slot)?.rune != newItem?.rune,
);
this.setGear(eventID, this.gear.withEquippedItem(slot, newItem, this.canDualWield2H()));
}

getEquippedItem(slot: ItemSlot): EquippedItem | null {
Expand All @@ -613,15 +607,11 @@ export class Player<SpecType extends Spec> {
return this.gear;
}

setGear(eventID: EventID, newGear: Gear, runeChanged=false) {
setGear(eventID: EventID, newGear: Gear) {
if (newGear.equals(this.gear))
return;

this.gear = newGear;

if (runeChanged) {
this.runeChangeEmitter.emit(eventID);
}
this.gearChangeEmitter.emit(eventID);
}

Expand Down
18 changes: 7 additions & 11 deletions ui/core/proto_utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,19 +1051,15 @@ export const specToEligibleRaces: Record<Spec, Array<Race>> = {

// Specs that can dual wield. This could be based on class, except that
// Enhancement Shaman learn dual wield from a talent.
const dualWieldSpecs: Array<Spec> = [
Spec.SpecHunter,
Spec.SpecRogue,
Spec.SpecWarrior,
Spec.SpecProtectionWarrior,
const dualWieldClasses: Array<Class> = [
Class.ClassHunter,
Class.ClassRogue,
Class.ClassShaman,
Class.ClassWarrior
];

export function canDualWield(player: Player<Spec>): boolean {
return (
dualWieldSpecs.includes(player.spec) ||
(player.getClass() == Class.ClassShaman && player.getEquippedItem(ItemSlot.ItemSlotChest)?.rune?.id == ShamanRune.RuneChestDualWieldSpec)
// TODO: Hunter Dual Wielding
// (player.getClass() == Class.ClassHunter && player.getEquippedItem(ItemSlot.ItemSlotChest)?.rune?.id == HunterRune.RuneFeetDualWieldSpe
);
return dualWieldClasses.includes(player.getClass());
}

const tankSpecs: Array<Spec> = [
Expand Down
Loading