Skip to content

Commit

Permalink
Merge pull request #3289 from wowsims/apl_health
Browse files Browse the repository at this point in the history
add health as apl value
  • Loading branch information
rosenrusinov authored Jul 11, 2023
2 parents cd5b973 + d66c23b commit d1057aa
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
6 changes: 6 additions & 0 deletions proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ message APLValue {
APLValueRemainingTimePercent remaining_time_percent = 10;

// Resource values
APLValueCurrentHealth current_health = 26;
APLValueCurrentHealthPercent current_health_percent = 27;
APLValueCurrentMana current_mana = 11;
APLValueCurrentManaPercent current_mana_percent = 12;
APLValueCurrentRage current_rage = 14;
Expand All @@ -80,6 +82,8 @@ message APLValue {
// Dot values
APLValueDotIsActive dot_is_active = 6;
APLValueDotRemainingTime dot_remaining_time = 13;

// Current Last Index - 27
}
}

Expand Down Expand Up @@ -165,6 +169,8 @@ message APLValueCurrentTimePercent {}
message APLValueRemainingTime {}
message APLValueRemainingTimePercent {}

message APLValueCurrentHealth {}
message APLValueCurrentHealthPercent {}
message APLValueCurrentMana {}
message APLValueCurrentManaPercent {}
message APLValueCurrentRage {}
Expand Down
4 changes: 4 additions & 0 deletions sim/core/apl_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue {
return rot.newValueRemainingTimePercent(config.GetRemainingTimePercent())

// Resources
case *proto.APLValue_CurrentHealth:
return rot.newValueCurrentHealth(config.GetCurrentHealth())
case *proto.APLValue_CurrentHealthPercent:
return rot.newValueCurrentHealthPercent(config.GetCurrentHealthPercent())
case *proto.APLValue_CurrentMana:
return rot.newValueCurrentMana(config.GetCurrentMana())
case *proto.APLValue_CurrentManaPercent:
Expand Down
42 changes: 42 additions & 0 deletions sim/core/apl_values_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,48 @@ import (
"github.com/wowsims/wotlk/sim/core/proto"
)

type APLValueCurrentHealth struct {
defaultAPLValueImpl
unit *Unit
}

func (rot *APLRotation) newValueCurrentHealth(config *proto.APLValueCurrentHealth) APLValue {
unit := rot.unit
if !unit.HasHealthBar() {
return nil
}
return &APLValueCurrentHealth{
unit: unit,
}
}
func (value *APLValueCurrentHealth) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeFloat
}
func (value *APLValueCurrentHealth) GetFloat(sim *Simulation) float64 {
return value.unit.CurrentHealth()
}

type APLValueCurrentHealthPercent struct {
defaultAPLValueImpl
unit *Unit
}

func (rot *APLRotation) newValueCurrentHealthPercent(config *proto.APLValueCurrentHealthPercent) APLValue {
unit := rot.unit
if !unit.HasHealthBar() {
return nil
}
return &APLValueCurrentHealthPercent{
unit: unit,
}
}
func (value *APLValueCurrentHealthPercent) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeFloat
}
func (value *APLValueCurrentHealthPercent) GetFloat(sim *Simulation) float64 {
return value.unit.CurrentHealthPercent()
}

type APLValueCurrentMana struct {
defaultAPLValueImpl
unit *Unit
Expand Down
16 changes: 16 additions & 0 deletions ui/core/components/individual_sim_ui/apl_values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
APLValueCurrentTimePercent,
APLValueRemainingTime,
APLValueRemainingTimePercent,
APLValueCurrentHealth,
APLValueCurrentHealthPercent,
APLValueCurrentMana,
APLValueCurrentManaPercent,
APLValueCurrentRage,
Expand Down Expand Up @@ -370,6 +372,20 @@ const valueTypeFactories: Record<NonNullable<APLValueType>, ValueTypeConfig<any>
}),

// Resources
['currentHealth']: inputBuilder({
label: 'Health',
submenu: ['Resources'],
shortDescription: 'Amount of currently available Health.',
newValue: APLValueCurrentHealth.create,
fields: [],
}),
['currentHealthPercent']: inputBuilder({
label: 'Health (%)',
submenu: ['Resources'],
shortDescription: 'Amount of currently available Health, as a percentage.',
newValue: APLValueCurrentHealthPercent.create,
fields: [],
}),
['currentMana']: inputBuilder({
label: 'Mana',
submenu: ['Resources'],
Expand Down

0 comments on commit d1057aa

Please sign in to comment.