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

Refactor RaidTarget --> UnitReference #3350

Merged
merged 2 commits into from
Jul 20, 2023
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
4 changes: 2 additions & 2 deletions proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ message Raid {
Debuffs debuffs = 5;

// Players who will be tanking mobs.
repeated RaidTarget tanks = 4;
repeated UnitReference tanks = 4;

// Staggers Stormstrike casts across Enhance Shaman to maximize charge usage.
bool stagger_stormstrikes = 3;
Expand Down Expand Up @@ -364,7 +364,7 @@ message StatWeightsRequest {
Debuffs debuffs = 9;
Encounter encounter = 4;
SimOptions sim_options = 5;
repeated RaidTarget tanks = 8;
repeated UnitReference tanks = 8;

repeated Stat stats_to_weigh = 6;
repeated PseudoStat pseudo_stats_to_weigh = 10;
Expand Down
21 changes: 19 additions & 2 deletions proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -758,9 +758,26 @@ message SimGem {
repeated double stats = 4;
}

message RaidTarget {
message UnitReference {
enum Type {
Unknown = 0;
Player = 1;
Target = 2;
Pet = 3;
}

// The type of unit being referenced.
Type type = 2;

// Index of the player/target/pet/etc depending on value of type.
int32 index = 3;

// Reference to the owner, only used iff this is a pet.
UnitReference owner = 4;

// Raid index of the player to target. A value of -1 indicates no target.
int32 target_index = 1;
// TODO: Delete this after 2 months (on or after 9/19/2023)
int32 target_index = 1 [deprecated = true];
}

// ID for actions that aren't spells or items.
Expand Down
4 changes: 2 additions & 2 deletions proto/deathknight.proto
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ message Deathknight {
bool precast_ghoul_frenzy = 3;
bool precast_horn_of_winter = 4;

RaidTarget unholy_frenzy_target = 5;
UnitReference unholy_frenzy_target = 5;

bool drw_pesti_apply = 6;

Expand Down Expand Up @@ -332,7 +332,7 @@ message TankDeathknight {

message Options {
double starting_runic_power = 1;
RaidTarget unholy_frenzy_target = 2;
UnitReference unholy_frenzy_target = 2;
double defensive_delay = 3;
}
Options options = 3;
Expand Down
8 changes: 4 additions & 4 deletions proto/druid.proto
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ message BalanceDruid {
Rotation rotation = 1;

message Options {
RaidTarget innervate_target = 1;
UnitReference innervate_target = 1;
}
Options options = 3;
}
Expand Down Expand Up @@ -254,7 +254,7 @@ message FeralDruid {
Rotation rotation = 1;

message Options {
RaidTarget innervate_target = 1;
UnitReference innervate_target = 1;
int32 latency_ms = 2;
bool assume_bleed_active = 4;
}
Expand All @@ -271,7 +271,7 @@ message FeralTankDruid {
Rotation rotation = 1;

message Options {
RaidTarget innervate_target = 1;
UnitReference innervate_target = 1;
double starting_rage = 2;
}
Options options = 3;
Expand All @@ -283,7 +283,7 @@ message RestorationDruid {
Rotation rotation = 1;

message Options {
RaidTarget innervate_target = 1;
UnitReference innervate_target = 1;
}
Options options = 3;
}
2 changes: 1 addition & 1 deletion proto/mage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ message Mage {
// Number of Evocation ticks to use. If 0, use all of them.
int32 evocation_ticks = 2;
int32 focus_magic_percent_uptime = 3;
RaidTarget focus_magic_target = 4;
UnitReference focus_magic_target = 4;
int32 reaction_time_ms = 5;
}
Options options = 3;
Expand Down
6 changes: 3 additions & 3 deletions proto/priest.proto
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ message ShadowPriest {
Armor armor = 2;
bool use_mind_blast = 4;
bool use_shadow_word_death = 5;
RaidTarget power_infusion_target = 6;
UnitReference power_infusion_target = 6;
}
Options options = 3;
}
Expand All @@ -184,7 +184,7 @@ message SmitePriest {
message Options {
bool use_inner_fire = 3;
bool use_shadowfiend = 1;
RaidTarget power_infusion_target = 2;
UnitReference power_infusion_target = 2;
}
Options options = 3;
}
Expand Down Expand Up @@ -217,7 +217,7 @@ message HealingPriest {
message Options {
bool use_inner_fire = 3;
bool use_shadowfiend = 1;
RaidTarget power_infusion_target = 2;
UnitReference power_infusion_target = 2;

// Number of times for rapture to proc each minute, ie when a PWS is fully absorbed.
double raptures_per_minute = 4;
Expand Down
2 changes: 1 addition & 1 deletion proto/rogue.proto
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ message Rogue {
Rotation rotation = 1;

message Options {
RaidTarget tricks_of_the_trade_target = 1;
UnitReference tricks_of_the_trade_target = 1;
enum PoisonImbue {
NoPoison = 0;
InstantPoison = 1;
Expand Down
2 changes: 1 addition & 1 deletion proto/ui.proto
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ message IndividualSimSettings {
SimSettings settings = 5;
RaidBuffs raid_buffs = 1;
Debuffs debuffs = 8;
repeated RaidTarget tanks = 7;
repeated UnitReference tanks = 7;
PartyBuffs party_buffs = 2;
Player player = 3;
Encounter encounter = 4;
Expand Down
2 changes: 1 addition & 1 deletion sim/core/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (env *Environment) construct(raidProto *proto.Raid, encounterProto *proto.E
if targetProto.TankIndex >= 0 && targetProto.TankIndex < int32(len(raidProto.Tanks)) {
raidTargetProto := raidProto.Tanks[targetProto.TankIndex]
if raidTargetProto != nil {
raidTarget := env.Raid.GetPlayerFromRaidTarget(raidTargetProto)
raidTarget := env.Raid.GetPlayerFromUnitReference(raidTargetProto)
if raidTarget != nil {
target.CurrentTarget = &raidTarget.GetCharacter().Unit
}
Expand Down
24 changes: 13 additions & 11 deletions sim/core/raid.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,21 +377,23 @@ func (raid Raid) GetPlayerFromUnit(unit *Unit) Agent {
return nil
}

func (raid Raid) GetPlayerFromRaidTarget(raidTarget *proto.RaidTarget) Agent {
if raidTarget == nil {
func (raid Raid) GetPlayerFromUnitReference(ref *proto.UnitReference) Agent {
if ref == nil {
return nil
}
raidIndex := raidTarget.TargetIndex

partyIndex := int(raidIndex / 5)
if partyIndex < 0 || partyIndex >= len(raid.Parties) {
return nil
}
if ref.Type == proto.UnitReference_Player {
raidIndex := ref.Index
partyIndex := int(raidIndex / 5)
if partyIndex < 0 || partyIndex >= len(raid.Parties) {
return nil
}

party := raid.Parties[partyIndex]
for _, player := range party.Players {
if player.GetCharacter().Index == raidIndex {
return player
party := raid.Parties[partyIndex]
for _, player := range party.Players {
if player.GetCharacter().Index == raidIndex {
return player
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion sim/core/test_generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ func FullCharacterTestSuiteGenerator(config CharacterSuiteConfig) TestGenerator

defaultRaid := SinglePlayerRaidProto(defaultPlayer, FullPartyBuffs, FullRaidBuffs, FullDebuffs)
if config.IsTank {
defaultRaid.Tanks = append(defaultRaid.Tanks, &proto.RaidTarget{TargetIndex: 0})
defaultRaid.Tanks = append(defaultRaid.Tanks, &proto.UnitReference{Type: proto.UnitReference_Player, Index: 0})
}
if config.IsHealer {
defaultRaid.TargetDummies = 1
Expand Down
2 changes: 1 addition & 1 deletion sim/deathknight/deathknight.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type DeathknightInputs struct {
IsDps bool
NewDrw bool

UnholyFrenzyTarget *proto.RaidTarget
UnholyFrenzyTarget *proto.UnitReference

StartingRunicPower float64
PrecastGhoulFrenzy bool
Expand Down
2 changes: 1 addition & 1 deletion sim/deathknight/dps/dps_deathknight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ var frostDesyncRotation = &proto.Deathknight_Rotation{
}

var deathKnightOptions = &proto.Deathknight_Options{
UnholyFrenzyTarget: &proto.RaidTarget{TargetIndex: 0},
UnholyFrenzyTarget: &proto.UnitReference{Type: proto.UnitReference_Player, Index: 0},
DrwPestiApply: true,
StartingRunicPower: 0,
PetUptime: 1,
Expand Down
2 changes: 1 addition & 1 deletion sim/deathknight/unholy_frenzy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (dk *Deathknight) registerUnholyFrenzyCD() {
unholyFrenzyTarget = &dk.Character
}

unholyFrenzyTargetAgent := dk.Party.Raid.GetPlayerFromRaidTarget(dk.Inputs.UnholyFrenzyTarget)
unholyFrenzyTargetAgent := dk.Party.Raid.GetPlayerFromUnitReference(dk.Inputs.UnholyFrenzyTarget)
if unholyFrenzyTargetAgent != nil {
unholyFrenzyTarget = unholyFrenzyTargetAgent.GetCharacter()
}
Expand Down
2 changes: 1 addition & 1 deletion sim/druid/balance/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewBalanceDruid(character core.Character, options *proto.Player) *BalanceDr
Rotation: balanceOptions.Rotation,
}

moonkin.SelfBuffs.InnervateTarget = &proto.RaidTarget{TargetIndex: -1}
moonkin.SelfBuffs.InnervateTarget = &proto.UnitReference{}
if balanceOptions.Options.InnervateTarget != nil {
moonkin.SelfBuffs.InnervateTarget = balanceOptions.Options.InnervateTarget
}
Expand Down
2 changes: 1 addition & 1 deletion sim/druid/druid.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type Druid struct {
}

type SelfBuffs struct {
InnervateTarget *proto.RaidTarget
InnervateTarget *proto.UnitReference
}

func (druid *Druid) GetCharacter() *core.Character {
Expand Down
2 changes: 1 addition & 1 deletion sim/druid/feral/feral.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewFeralDruid(character core.Character, options *proto.Player) *FeralDruid
latency: time.Duration(core.MaxInt32(feralOptions.Options.LatencyMs, 1)) * time.Millisecond,
}

cat.SelfBuffs.InnervateTarget = &proto.RaidTarget{TargetIndex: -1}
cat.SelfBuffs.InnervateTarget = &proto.UnitReference{}
if feralOptions.Options.InnervateTarget != nil {
cat.SelfBuffs.InnervateTarget = feralOptions.Options.InnervateTarget
}
Expand Down
6 changes: 3 additions & 3 deletions sim/druid/feral/feral_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ var StandardGlyphs = &proto.Glyphs{
var PlayerOptionsMonoCat = &proto.Player_FeralDruid{
FeralDruid: &proto.FeralDruid{
Options: &proto.FeralDruid_Options{
InnervateTarget: &proto.RaidTarget{TargetIndex: -1}, // no Innervate
InnervateTarget: &proto.UnitReference{}, // no Innervate
LatencyMs: 100,
AssumeBleedActive: true,
},
Expand Down Expand Up @@ -177,7 +177,7 @@ var PlayerOptionsMonoCat = &proto.Player_FeralDruid{
var PlayerOptionsMonoCatNoBleed = &proto.Player_FeralDruid{
FeralDruid: &proto.FeralDruid{
Options: &proto.FeralDruid_Options{
InnervateTarget: &proto.RaidTarget{TargetIndex: -1}, // no Innervate
InnervateTarget: &proto.UnitReference{}, // no Innervate
LatencyMs: 100,
AssumeBleedActive: false,
},
Expand Down Expand Up @@ -206,7 +206,7 @@ var PlayerOptionsMonoCatNoBleed = &proto.Player_FeralDruid{
var PlayerOptionsFlowerCatAoe = &proto.Player_FeralDruid{
FeralDruid: &proto.FeralDruid{
Options: &proto.FeralDruid_Options{
InnervateTarget: &proto.RaidTarget{TargetIndex: -1}, // no Innervate
InnervateTarget: &proto.UnitReference{}, // no Innervate
LatencyMs: 100,
AssumeBleedActive: false,
},
Expand Down
2 changes: 1 addition & 1 deletion sim/druid/innervate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
// Returns the time to wait before the next action, or 0 if innervate is on CD
// or disabled.
func (druid *Druid) registerInnervateCD() {
innervateTargetAgent := druid.Party.Raid.GetPlayerFromRaidTarget(druid.SelfBuffs.InnervateTarget)
innervateTargetAgent := druid.Party.Raid.GetPlayerFromUnitReference(druid.SelfBuffs.InnervateTarget)
if innervateTargetAgent == nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion sim/druid/restoration/restoration.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewRestorationDruid(character core.Character, options *proto.Player) *Resto
Rotation: restoOptions.Rotation,
}

resto.SelfBuffs.InnervateTarget = &proto.RaidTarget{TargetIndex: -1}
resto.SelfBuffs.InnervateTarget = &proto.UnitReference{}
if restoOptions.Options.InnervateTarget != nil {
resto.SelfBuffs.InnervateTarget = restoOptions.Options.InnervateTarget
}
Expand Down
2 changes: 1 addition & 1 deletion sim/druid/restoration/restoration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var FullConsumes = &proto.Consumes{
var PlayerOptionsStandard = &proto.Player_RestorationDruid{
RestorationDruid: &proto.RestorationDruid{
Options: &proto.RestorationDruid_Options{
InnervateTarget: &proto.RaidTarget{TargetIndex: 0}, // self innervate
InnervateTarget: &proto.UnitReference{Type: proto.UnitReference_Player, Index: 0}, // self innervate
},
Rotation: &proto.RestorationDruid_Rotation{},
},
Expand Down
2 changes: 1 addition & 1 deletion sim/druid/tank/tank.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewFeralTankDruid(character core.Character, options *proto.Player) *FeralTa
Options: tankOptions.Options,
}

bear.SelfBuffs.InnervateTarget = &proto.RaidTarget{TargetIndex: -1}
bear.SelfBuffs.InnervateTarget = &proto.UnitReference{}
if tankOptions.Options.InnervateTarget != nil {
bear.SelfBuffs.InnervateTarget = tankOptions.Options.InnervateTarget
}
Expand Down
2 changes: 1 addition & 1 deletion sim/druid/tank/tank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ var StandardGlyphs = &proto.Glyphs{
var PlayerOptionsDefault = &proto.Player_FeralTankDruid{
FeralTankDruid: &proto.FeralTankDruid{
Options: &proto.FeralTankDruid_Options{
InnervateTarget: &proto.RaidTarget{TargetIndex: -1}, // no Innervate
InnervateTarget: &proto.UnitReference{}, // no Innervate
StartingRage: 20,
},
Rotation: &proto.FeralTankDruid_Rotation{
Expand Down
2 changes: 1 addition & 1 deletion sim/mage/focus_magic.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (mage *Mage) applyFocusMagic() {
return
}

focusMagicTargetAgent := mage.Party.Raid.GetPlayerFromRaidTarget(mage.Options.FocusMagicTarget)
focusMagicTargetAgent := mage.Party.Raid.GetPlayerFromUnitReference(mage.Options.FocusMagicTarget)
if focusMagicTargetAgent == nil {
return
} else if focusMagicTargetAgent.GetCharacter() == mage.GetCharacter() {
Expand Down
2 changes: 1 addition & 1 deletion sim/priest/healing/healing_priest.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewHealingPriest(character core.Character, options *proto.Player) *HealingP
Options: healingOptions.Options,
}

hpriest.SelfBuffs.PowerInfusionTarget = &proto.RaidTarget{TargetIndex: -1}
hpriest.SelfBuffs.PowerInfusionTarget = &proto.UnitReference{}
if hpriest.Talents.PowerInfusion && hpriest.Options.PowerInfusionTarget != nil {
hpriest.SelfBuffs.PowerInfusionTarget = hpriest.Options.PowerInfusionTarget
}
Expand Down
2 changes: 1 addition & 1 deletion sim/priest/power_infusion.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (priest *Priest) registerPowerInfusionCD() {

actionID := core.ActionID{SpellID: 10060, Tag: priest.Index}

powerInfusionTargetAgent := priest.Party.Raid.GetPlayerFromRaidTarget(priest.SelfBuffs.PowerInfusionTarget)
powerInfusionTargetAgent := priest.Party.Raid.GetPlayerFromUnitReference(priest.SelfBuffs.PowerInfusionTarget)
if powerInfusionTargetAgent == nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion sim/priest/priest.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type SelfBuffs struct {
UseShadowfiend bool
UseInnerFire bool

PowerInfusionTarget *proto.RaidTarget
PowerInfusionTarget *proto.UnitReference
}

func (priest *Priest) GetCharacter() *core.Character {
Expand Down
2 changes: 1 addition & 1 deletion sim/priest/shadow/shadow_priest.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewShadowPriest(character core.Character, options *proto.Player) *ShadowPri
options: shadowOptions.Options,
}

spriest.SelfBuffs.PowerInfusionTarget = &proto.RaidTarget{TargetIndex: -1}
spriest.SelfBuffs.PowerInfusionTarget = &proto.UnitReference{}
if spriest.Talents.PowerInfusion && shadowOptions.Options.PowerInfusionTarget != nil {
spriest.SelfBuffs.PowerInfusionTarget = shadowOptions.Options.PowerInfusionTarget
}
Expand Down
2 changes: 1 addition & 1 deletion sim/priest/smite/smite_priest.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewSmitePriest(character core.Character, options *proto.Player) *SmitePries
allowedHFDelay: time.Millisecond * time.Duration(smiteOptions.Rotation.AllowedHolyFireDelayMs),
}

spriest.SelfBuffs.PowerInfusionTarget = &proto.RaidTarget{TargetIndex: -1}
spriest.SelfBuffs.PowerInfusionTarget = &proto.UnitReference{}
if spriest.Talents.PowerInfusion && smiteOptions.Options.PowerInfusionTarget != nil {
spriest.SelfBuffs.PowerInfusionTarget = smiteOptions.Options.PowerInfusionTarget
}
Expand Down
Loading