Skip to content

Commit

Permalink
fix faction filtering of buffs
Browse files Browse the repository at this point in the history
  • Loading branch information
kayla-glick committed Feb 2, 2024
1 parent 4254cb2 commit d8f6a62
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 44 deletions.
6 changes: 3 additions & 3 deletions ui/core/components/icon_inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ interface TristateInputConfig<T, ModObject> {
actionId: (modObj: ModObject) => ActionId | null
impId: ActionId
fieldName: keyof T
faction?: Faction
showWhen?: (modObj: ModObject) => boolean
}

export function makeTristateRaidBuffInput<SpecType extends Spec>(config: TristateInputConfig<RaidBuffs, Player<SpecType>>): InputHelpers.TypedIconPickerConfig<Player<SpecType>, number> {
return InputHelpers.makeTristateIconInput<any, RaidBuffs, Player<SpecType>>({
getModObject: (player: Player<SpecType>) => player,
showWhen: (player: Player<SpecType>) => (!config.faction || config.faction == player.getFaction()),
showWhen: (player: Player<SpecType>) => (!config.showWhen || config.showWhen(player)),
getValue: (player: Player<SpecType>) => player.getRaid()!.getBuffs(),
setValue: (eventID: EventID, player: Player<SpecType>, newVal: RaidBuffs) => player.getRaid()!.setBuffs(eventID, newVal),
changeEmitter: (player: Player<SpecType>) => TypedEvent.onAny([player.getRaid()!.buffsChangeEmitter, player.levelChangeEmitter, player.raceChangeEmitter]),
Expand All @@ -111,7 +111,7 @@ export function makeTristateRaidBuffInput<SpecType extends Spec>(config: Tristat
export function makeTristateIndividualBuffInput<SpecType extends Spec>(config: TristateInputConfig<IndividualBuffs, Player<SpecType>>): InputHelpers.TypedIconPickerConfig<Player<SpecType>, number> {
return InputHelpers.makeTristateIconInput<any, IndividualBuffs, Player<SpecType>>({
getModObject: (player: Player<SpecType>) => player,
showWhen: (player: Player<SpecType>) => (!config.faction || config.faction == player.getFaction()),
showWhen: (player: Player<SpecType>) => (!config.showWhen || config.showWhen(player)),
getValue: (player: Player<SpecType>) => player.getBuffs(),
setValue: (eventID: EventID, player: Player<SpecType>, newVal: IndividualBuffs) => player.setBuffs(eventID, newVal),
changeEmitter: (player: Player<SpecType>) => TypedEvent.onAny([player.buffsChangeEmitter, player.levelChangeEmitter, player.raceChangeEmitter])
Expand Down
61 changes: 28 additions & 33 deletions ui/core/components/inputs/buffs_debuffs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ export const AllStatsBuff = withLabel(
);

// Separate Strength buffs allow us to use a boolean pickers for Horde specifically
export const AllStatsPercentBuffAlliance = InputHelpers.makeMultiIconInput([
makeBooleanIndividualBuffInput({actionId: () => ActionId.fromSpellId(20217), fieldName: 'blessingOfKings'}),
makeBooleanRaidBuffInput({actionId: () => ActionId.fromSpellId(409580), fieldName: 'aspectOfTheLion'}),
export const AllStatsPercentBuff = InputHelpers.makeMultiIconInput([
makeBooleanIndividualBuffInput({
actionId: () => ActionId.fromSpellId(20217),
fieldName: 'blessingOfKings',
showWhen: (player) => player.getFaction() == Faction.Alliance,
}),
makeBooleanRaidBuffInput({
actionId: () => ActionId.fromSpellId(409580),
fieldName: 'aspectOfTheLion',
}),
], 'Stats %');

export const AllStatsPercentBuffHorde = withLabel(
makeBooleanRaidBuffInput({actionId: () => ActionId.fromSpellId(409580), fieldName: 'aspectOfTheLion'}),
'Stats %'
);

export const ArmorBuff = InputHelpers.makeMultiIconInput([
makeTristateRaidBuffInput({
actionId: (player) => player.getMatchingSpellActionId([
Expand Down Expand Up @@ -128,8 +130,13 @@ export const PaladinPhysicalBuff = InputHelpers.makeMultiIconInput([
]),
impId: ActionId.fromSpellId(20048),
fieldName: 'blessingOfMight',
showWhen: (player) => player.getFaction() == Faction.Alliance,
}),
makeBooleanRaidBuffInput({
actionId: () => ActionId.fromSpellId(425600),
fieldName: 'hornOfLordaeron',
showWhen: (player) => player.getFaction() == Faction.Alliance,
}),
makeBooleanRaidBuffInput({actionId: () => ActionId.fromSpellId(425600), fieldName: 'hornOfLordaeron'}),
], 'Paladin Physical');

export const StrengthBuffHorde = withLabel(
Expand All @@ -142,10 +149,12 @@ export const StrengthBuffHorde = withLabel(
{ id: 25361, minLevel: 60 },
]),
impId: ActionId.fromSpellId(16295),
fieldName: 'strengthOfEarthTotem'
fieldName: 'strengthOfEarthTotem',
showWhen: (player) => player.getFaction() == Faction.Horde,
}),
'Strength',
);;

export const GraceOfAir = withLabel(
makeTristateRaidBuffInput({
actionId: (player) => player.getMatchingSpellActionId([
Expand All @@ -155,6 +164,7 @@ export const GraceOfAir = withLabel(
]),
impId: ActionId.fromSpellId(16295),
fieldName: 'graceOfAirTotem',
showWhen: (player) => player.getFaction() == Faction.Horde,
}),
'Agility',
);
Expand Down Expand Up @@ -324,6 +334,7 @@ export const BlessingOfWisdom = withLabel(
]),
impId: ActionId.fromSpellId(20245),
fieldName: 'blessingOfWisdom',
showWhen: (player) => player.getFaction() == Faction.Alliance,
}),
'Blessing of Wisdom',
);
Expand All @@ -338,6 +349,7 @@ export const ManaSpringTotem = withLabel(
]),
impId: ActionId.fromSpellId(16208),
fieldName: 'manaSpringTotem',
showWhen: (player) => player.getFaction() == Faction.Horde,
}),
'Mana Spring Totem',
);
Expand Down Expand Up @@ -378,6 +390,7 @@ export const RetributionAura = withLabel(
]),
impId: ActionId.fromSpellId(20092),
fieldName: 'retributionAura',
showWhen: (player) => player.getFaction() == Faction.Alliance,
}),
'Retribution Aura',
);
Expand Down Expand Up @@ -671,6 +684,7 @@ export const JudgementOfWisdom = withLabel(
{ id: 20355, minLevel: 58 },
]),
fieldName: 'judgementOfWisdom',
showWhen: (player) => player.getFaction() == Faction.Alliance,
}),
'Judgement of Wisdom',
);
Expand All @@ -684,6 +698,7 @@ export const JudgementOfLight = makeBooleanDebuffInput({
{ id: 20346, minLevel: 60 },
]),
fieldName: 'judgementOfLight',
showWhen: (player) => player.getFaction() == Faction.Alliance,
});
export const CurseOfVulnerability = makeBooleanDebuffInput({
actionId: (player) => player.getMatchingSpellActionId([
Expand Down Expand Up @@ -722,16 +737,9 @@ export const RAID_BUFFS_CONFIG = [
stats: []
},
{
config: AllStatsPercentBuffAlliance,
config: AllStatsPercentBuff,
picker: MultiIconPicker,
stats: [],
faction: Faction.Alliance,
},
{
config: AllStatsPercentBuffHorde,
picker: IconPicker,
stats: [],
faction: Faction.Horde,
},
{
config: ArmorBuff,
Expand All @@ -747,19 +755,16 @@ export const RAID_BUFFS_CONFIG = [
config: PaladinPhysicalBuff,
picker: MultiIconPicker,
stats: [Stat.StatStrength, Stat.StatAgility, Stat.StatAttackPower],
faction: Faction.Alliance,
},
{
config: StrengthBuffHorde,
picker: IconPicker,
stats: [Stat.StatStrength],
faction: Faction.Horde,
},
{
config: GraceOfAir,
picker: IconPicker,
stats: [Stat.StatAgility],
faction: Faction.Horde,
},
{
config: IntellectBuff,
Expand Down Expand Up @@ -805,7 +810,6 @@ export const RAID_BUFFS_CONFIG = [
config: DamageReductionPercentBuff,
picker: IconPicker,
stats: [Stat.StatArmor],
faction: Faction.Alliance,
},
{
config: ResistanceBuff,
Expand All @@ -821,13 +825,11 @@ export const RAID_BUFFS_CONFIG = [
config: BlessingOfWisdom,
picker: IconPicker,
stats: [Stat.StatMP5],
faction: Faction.Alliance,
},
{
config: ManaSpringTotem,
picker: IconPicker,
stats: [Stat.StatMP5],
faction: Faction.Horde,
},

// // Misc Buffs
Expand Down Expand Up @@ -868,10 +870,7 @@ export const WORLD_BUFFS_CONFIG = [
{
config: AshenvalePvpBuff,
picker: IconPicker,
stats: [
Stat.StatAttackPower,
Stat.StatSpellPower,
]
stats: [Stat.StatAttackPower, Stat.StatSpellPower,],
},
{
config: FengusFerocity,
Expand Down Expand Up @@ -906,11 +905,7 @@ export const WORLD_BUFFS_CONFIG = [
{
config: WarchiefsBlessing,
picker: IconPicker,
stats: [
Stat.StatHealth,
Stat.StatMeleeHaste,
Stat.StatMP5,
]
stats: [Stat.StatHealth, Stat.StatMeleeHaste, Stat.StatMP5]
},
] as PickerStatOptions[];

Expand Down
4 changes: 1 addition & 3 deletions ui/core/components/inputs/consumables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ function makeConsumeInputFactory<T extends number>(args: ConsumeInputFactoryArgs
return {
actionId: option.config.actionId,
value: option.config.value,
showWhen: (player: Player<any>) =>
(!option.config.showWhen || option.config.showWhen(player)) &&
(option.config.faction || player.getFaction()) == player.getFaction(),
showWhen: (player: Player<any>) => !option.config.showWhen || option.config.showWhen(player)
} as IconEnumValueConfig<Player<any>, T>;
})),
equals: (a: T, b: T) => a == b,
Expand Down
6 changes: 1 addition & 5 deletions ui/core/components/inputs/stat_options.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IndividualSimUI } from "../../individual_sim_ui";
import { Player } from "../../player";
import { Faction, Spec, Stat } from "../../proto/common";
import { Spec, Stat } from "../../proto/common";
import { ActionId } from "../../proto_utils/action_id";

import { IconEnumPicker, IconEnumPickerConfig } from "../icon_enum_picker";
Expand All @@ -12,13 +12,11 @@ export interface ActionInputConfig<T> {
value: T
minLevel?: number
maxLevel?: number
faction?: Faction
showWhen?: (player: Player<Spec>) => boolean
}

export interface StatOption {
stats: Array<Stat>,
faction?: Faction
}

export interface ItemStatOption<T> extends StatOption {
Expand Down Expand Up @@ -55,8 +53,6 @@ export function relevantStatOptions<T, OptionsType extends ItemStatOptions<T> |
): StatOptions<T, OptionsType> {
return options
.filter(option =>
// Filter by faction if there's a faction restriction
(!option.faction || option.faction == simUI.player.getFaction()) &&
// Filter out excluded options
!simUI.individualConfig.excludeBuffDebuffInputs.includes(option.config) &&
(
Expand Down

0 comments on commit d8f6a62

Please sign in to comment.