Skip to content

Commit

Permalink
Fix UI bug and expose Furious Howl as hunter APL MCD
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyt857 committed Jul 27, 2023
1 parent 2933981 commit 47c122f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
14 changes: 14 additions & 0 deletions sim/hunter/pet_abilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,20 @@ func (hp *HunterPet) newFuriousHowl() *core.Spell {
},
})

hp.hunterOwner.RegisterSpell(core.SpellConfig{
ActionID: actionID,
Flags: core.SpellFlagAPL | core.SpellFlagMCD,
Cast: core.CastConfig{
CD: howlSpell.CD,
},
ExtraCastCondition: func(sim *core.Simulation, target *core.Unit) bool {
return howlSpell.CanCast(sim, target)
},
ApplyEffects: func(sim *core.Simulation, target *core.Unit, _ *core.Spell) {
howlSpell.Cast(sim, target)
},
})

hp.hunterOwner.AddMajorCooldown(core.MajorCooldown{
Spell: howlSpell,
Type: core.CooldownTypeDPS,
Expand Down
20 changes: 12 additions & 8 deletions ui/core/components/detailed_results/results_filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export class ResultsFilter extends ResultComponent {
'player-filter-root',
],
changedEvent: (_filterData: FilterData) => this.changeEmitter,
sourceToValue: (src: UnitReference) => this.refToValue(src),
sourceToValue: (src: UnitReference|undefined) => this.refToValue(src),
valueToSource: (val: UnitValue) => val.value,
getValue: (filterData: FilterData) => this.numToRef(filterData.player, true),
setValue: (eventID: EventID, filterData: FilterData, newValue: UnitReference) => this.setPlayer(eventID, this.refToNum(newValue)),
setValue: (eventID: EventID, filterData: FilterData, newValue: UnitReference|undefined) => this.setPlayer(eventID, this.refToNum(newValue)),
values: [],
});

Expand All @@ -46,10 +46,10 @@ export class ResultsFilter extends ResultComponent {
'target-filter-root',
],
changedEvent: (_filterData: FilterData) => this.changeEmitter,
sourceToValue: (src: UnitReference) => this.refToValue(src),
sourceToValue: (src: UnitReference|undefined) => this.refToValue(src),
valueToSource: (val: UnitValue) => val.value,
getValue: (filterData: FilterData) => this.numToRef(filterData.target, false),
setValue: (eventID: EventID, filterData: FilterData, newValue: UnitReference) => this.setTarget(eventID, this.refToNum(newValue)),
setValue: (eventID: EventID, filterData: FilterData, newValue: UnitReference|undefined) => this.setTarget(eventID, this.refToNum(newValue)),
values: [],
});
}
Expand All @@ -76,8 +76,12 @@ export class ResultsFilter extends ResultComponent {
this.changeEmitter.emit(eventID);
}

private refToValue(ref: UnitReference): UnitValue {
if (ref.type == UnitType.AllPlayers) {
private refToValue(ref: UnitReference|undefined): UnitValue {
if (!ref || ref.type == UnitType.Unknown) {
return {
value: ref,
};
} else if (ref.type == UnitType.AllPlayers) {
return {
iconUrl: '',
text: 'All Players',
Expand Down Expand Up @@ -114,8 +118,8 @@ export class ResultsFilter extends ResultComponent {
};
}

private refToNum(ref: UnitReference): number {
return (ref.type == UnitType.AllPlayers || ref.type == UnitType.AllTargets) ? ALL_UNITS : ref.index;
private refToNum(ref: UnitReference|undefined): number {
return (!ref || ref.type == UnitType.AllPlayers || ref.type == UnitType.AllTargets) ? ALL_UNITS : ref.index;
}

private numToRef(idx: number, isPlayer: boolean): UnitReference {
Expand Down
12 changes: 6 additions & 6 deletions ui/core/components/individual_sim_ui/apl_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class APLUnitPicker extends UnitPicker<Player<any>> {
constructor(parent: HTMLElement, player: Player<any>, config: APLUnitPickerConfig) {
super(parent, player, {
...config,
sourceToValue: (src: UnitReference) => APLUnitPicker.refToValue(src, player),
sourceToValue: (src: UnitReference|undefined) => APLUnitPicker.refToValue(src, player),
valueToSource: (val: UnitValue) => val.value,
values: [],
});
Expand All @@ -172,8 +172,8 @@ export class APLUnitPicker extends UnitPicker<Player<any>> {
player.sim.unitMetadataEmitter.on(() => this.updateValues());
}

private static refToValue(ref: UnitReference, thisPlayer: Player<any>): UnitValue {
if (ref.type == UnitType.Unknown) {
private static refToValue(ref: UnitReference|undefined, thisPlayer: Player<any>): UnitValue {
if (!ref || ref.type == UnitType.Unknown) {
return {
value: ref,
text: 'fa-user',
Expand Down Expand Up @@ -235,7 +235,7 @@ export class APLUnitPicker extends UnitPicker<Player<any>> {

private updateValues() {
let values = [
UnitReference.create(),
undefined,
UnitReference.create({type: UnitType.Self}),
this.modObject.getPetMetadatas().asList().map((petMetadata, i) => UnitReference.create({type: UnitType.Pet, index: i, owner: UnitReference.create({type: UnitType.Self})})),
UnitReference.create({type: UnitType.CurrentTarget}),
Expand All @@ -245,7 +245,7 @@ export class APLUnitPicker extends UnitPicker<Player<any>> {
this.setOptions(values.map(v => {
return {
value: APLUnitPicker.refToValue(v, this.modObject),
submenu: v.type == UnitType.Pet ? [APLUnitPicker.refToValue(v.owner!, this.modObject)] : undefined,
submenu: v?.type == UnitType.Pet ? [APLUnitPicker.refToValue(v.owner!, this.modObject)] : undefined,
};
}));
}
Expand Down Expand Up @@ -355,7 +355,7 @@ export function actionIdFieldConfig(field: string, actionIdSet: ACTION_ID_SET, u
export function unitFieldConfig(field: string, options?: Partial<APLPickerBuilderFieldConfig<any, any>>): APLPickerBuilderFieldConfig<any, any> {
return {
field: field,
newValue: () => UnitReference.create(),
newValue: () => undefined,
factory: (parent, player, config) => new APLUnitPicker(parent, player, {
...config,
}),
Expand Down
3 changes: 2 additions & 1 deletion ui/core/components/individual_sim_ui/apl_rotation_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Player } from '../../player.js';
import { ListItemPickerConfig, ListPicker } from '../list_picker.js';
import { AdaptiveStringPicker } from '../string_picker.js';
import {
APLRotation,
APLListItem,
APLAction,
APLPrepullAction,
Expand Down Expand Up @@ -60,7 +61,7 @@ export class APLRotationPicker extends Component {
inlineMenuBar: true,
});

//modPlayer.rotationChangeEmitter.on(() => console.log('APL: ' + APLRotation.toJsonString(modPlayer.aplRotation)))
modPlayer.rotationChangeEmitter.on(() => console.log('APL: ' + APLRotation.toJsonString(modPlayer.aplRotation)))
}
}

Expand Down
8 changes: 4 additions & 4 deletions ui/core/components/unit_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import { ActionId } from '../proto_utils/action_id.js';
import { DropdownPicker, DropdownPickerConfig, DropdownValueConfig } from './dropdown_picker.js';

export interface UnitValue {
value: UnitReference,
value: UnitReference|undefined,
text?: string,
iconUrl?: string|ActionId,
color?: string,
}

export interface UnitValueConfig extends DropdownValueConfig<UnitValue> {}
export interface UnitPickerConfig<ModObject> extends Omit<DropdownPickerConfig<ModObject, UnitReference, UnitValue>, 'equals' | 'setOptionContent' | 'defaultLabel'> {
export interface UnitPickerConfig<ModObject> extends Omit<DropdownPickerConfig<ModObject, UnitReference|undefined, UnitValue>, 'equals' | 'setOptionContent' | 'defaultLabel'> {
}

export class UnitPicker<ModObject> extends DropdownPicker<ModObject, UnitReference, UnitValue> {
export class UnitPicker<ModObject> extends DropdownPicker<ModObject, UnitReference|undefined, UnitValue> {
constructor(parent: HTMLElement, modObject: ModObject, config: UnitPickerConfig<ModObject>) {
super(parent, modObject, {
...config,
equals: (a, b) => UnitReference.equals(a?.value, b?.value),
equals: (a, b) => UnitReference.equals(a?.value || UnitReference.create(), b?.value || UnitReference.create()),
defaultLabel: 'Unit',
setOptionContent: (button: HTMLButtonElement, valueConfig: DropdownValueConfig<UnitValue>) => {
const unitConfig = valueConfig.value;
Expand Down

0 comments on commit 47c122f

Please sign in to comment.