Skip to content

Commit

Permalink
Merge pull request #943 from wowsims/feature/migrate-old-encounter-ta…
Browse files Browse the repository at this point in the history
…rget

[FIX] default encounter target
  • Loading branch information
1337LutZ authored Aug 21, 2024
2 parents 6ec7068 + 580e64d commit f066a6a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
16 changes: 8 additions & 8 deletions ui/core/components/encounter_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
this.statPickers = ALL_TARGET_STATS.map(statData => {
const stat = statData.stat;
return new NumberPicker(section2, null, {
id: `target-picker-stats-${statData.stat}`,
id: `target-${this.targetIndex}-picker-stats-${statData.stat}`,
inline: true,
extraCssClasses: statData.extraCssClasses,
label: getStatName(stat),
Expand All @@ -399,7 +399,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
});

this.swingSpeedPicker = new NumberPicker(section3, null, {
id: 'target-picker-swing-speed',
id: `target-${this.targetIndex}-picker-swing-speed`,
label: 'Swing Speed',
labelTooltip: 'Time in seconds between auto attacks. Set to 0 to disable auto attacks.',
float: true,
Expand All @@ -411,7 +411,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
},
});
this.minBaseDamagePicker = new NumberPicker(section3, null, {
id: 'target-picker-min-base-damage',
id: `target-${this.targetIndex}-picker-min-base-damage`,
label: 'Min Base Damage',
labelTooltip: 'Base damage for auto attacks, i.e. lowest roll with 0 AP against a 0-armor Player.',
changedEvent: () => encounter.targetsChangeEmitter,
Expand All @@ -422,7 +422,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
},
});
this.damageSpreadPicker = new NumberPicker(section3, null, {
id: 'target-picker-damage-spread',
id: `target-${this.targetIndex}-picker-damage-spread`,
label: 'Damage Spread',
labelTooltip: 'Fractional spread between the minimum and maximum auto-attack damage from this enemy at 0 Attack Power.',
float: true,
Expand All @@ -434,7 +434,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
},
});
this.dualWieldPicker = new BooleanPicker(section3, null, {
id: 'target-picker-dual-wield',
id: `target-${this.targetIndex}-picker-dual-wield`,
label: 'Dual Wield',
labelTooltip: 'Uses 2 separate weapons to attack.',
inline: true,
Expand All @@ -447,7 +447,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
},
});
this.dwMissPenaltyPicker = new BooleanPicker(section3, null, {
id: 'target-picker-dw-miss-penalty',
id: `target-${this.targetIndex}-picker-dw-miss-penalty`,
label: 'DW Miss Penalty',
labelTooltip:
'Enables the Dual Wield Miss Penalty (+19% chance to miss) if dual wielding. Bosses in Hyjal/BT/SWP usually have this disabled to stop tanks from avoidance stacking.',
Expand All @@ -462,7 +462,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
enableWhen: () => this.getTarget().dualWield,
});
this.parryHastePicker = new BooleanPicker(section3, null, {
id: 'target-picker-parry-haste',
id: `target-${this.targetIndex}-picker-parry-haste`,
label: 'Parry Haste',
labelTooltip: 'Whether this enemy will gain parry haste when parrying attacks.',
inline: true,
Expand All @@ -475,7 +475,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
},
});
this.spellSchoolPicker = new EnumPicker<null>(section3, null, {
id: 'target-picker-spell-school',
id: `target-${this.targetIndex}-picker-spell-school`,
label: 'Spell School',
labelTooltip: 'Type of damage caused by auto attacks. This is usually Physical, but some enemies have elemental attacks.',
values: [
Expand Down
38 changes: 22 additions & 16 deletions ui/core/encounter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as Mechanics from './constants/mechanics.js';
import { CURRENT_API_VERSION } from './constants/other.js';
import { UnitMetadataList } from './player.js';
import { Encounter as EncounterProto, MobType, PresetEncounter, PresetTarget, SpellSchool, Stat, Target as TargetProto, TargetInput } from './proto/common.js';
import { Stats } from './proto_utils/stats.js';
import { Sim } from './sim.js';
import { EventID, TypedEvent } from './typed_event.js';
import * as Mechanics from './constants/mechanics';
import { CURRENT_API_VERSION } from './constants/other';
import { UnitMetadataList } from './player';
import { Encounter as EncounterProto, MobType, PresetEncounter, PresetTarget, SpellSchool, Stat, Target as TargetProto, TargetInput } from './proto/common';
import { Stats } from './proto_utils/stats';
import { Sim } from './sim';
import { EventID, TypedEvent } from './typed_event';

// Manages all the settings for an Encounter.
export class Encounter {
Expand Down Expand Up @@ -38,7 +38,7 @@ export class Encounter {
}

get primaryTarget(): TargetProto {
return TargetProto.clone(this.targets[0]);
return this.targets[0];
}

getDurationVariation(): number {
Expand Down Expand Up @@ -172,21 +172,27 @@ export class Encounter {
}

static defaultTargetProto(): TargetProto {
// Copy default raid target used as fallback for missing DB.
// https://github.com/wowsims/cata/blob/3570c4fcf1a4e2cd81926019d4a1b3182f613de1/sim/encounters/register_all.go#L24
return TargetProto.create({
id: 31146,
name: 'Raid Target',
level: Mechanics.BOSS_LEVEL,
mobType: MobType.MobTypeGiant,
tankIndex: 0,
swingSpeed: 1.5,
minBaseDamage: 65000,
dualWield: false,
dualWieldPenalty: false,
suppressDodge: false,
parryHaste: true,
spellSchool: SpellSchool.SpellSchoolPhysical,
stats: Stats.fromMap({
[Stat.StatArmor]: 11977,
[Stat.StatAttackPower]: 805,
[Stat.StatHealth]: 120016403,
}).asProtoArray(),
minBaseDamage: 210000,
damageSpread: 0.4,
tankIndex: 0,
swingSpeed: 2.5,
suppressDodge: false,
parryHaste: false,
dualWield: false,
dualWieldPenalty: false,
spellSchool: SpellSchool.SpellSchoolPhysical,
targetInputs: new Array<TargetInput>(0),
});
}
Expand Down

0 comments on commit f066a6a

Please sign in to comment.