Skip to content

Commit

Permalink
Replace Time to Max with Time to Target for more flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
hillerstorm committed Dec 16, 2024
1 parent 28072a6 commit accf399
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 46 deletions.
12 changes: 8 additions & 4 deletions proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ message APLValue {
APLValueMaxRunicPower max_runic_power = 86;
APLValueEnergyRegenPerSecond energy_regen_per_second = 90;
APLValueFocusRegenPerSecond focus_regen_per_second = 91;
APLValueEnergyTimeToMax energy_time_to_max = 92;
APLValueFocusTimeToMax focus_time_to_max = 93;
APLValueEnergyTimeToTarget energy_time_to_target = 92;
APLValueFocusTimeToTarget focus_time_to_target = 93;

// Unit values
APLValueUnitIsMoving unit_is_moving = 72;
Expand Down Expand Up @@ -450,8 +450,12 @@ message APLValueMaxFocus {}
message APLValueMaxRunicPower {}
message APLValueEnergyRegenPerSecond {}
message APLValueFocusRegenPerSecond {}
message APLValueEnergyTimeToMax {}
message APLValueFocusTimeToMax {}
message APLValueEnergyTimeToTarget {
APLValue target_energy = 1;
}
message APLValueFocusTimeToTarget {
APLValue target_focus = 1;
}

enum APLValueRuneType {
RuneUnknown = 0;
Expand Down
8 changes: 4 additions & 4 deletions sim/core/apl_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue {
value = rot.newValueEnergyRegenPerSecond(config.GetEnergyRegenPerSecond(), config.Uuid)
case *proto.APLValue_FocusRegenPerSecond:
value = rot.newValueFocusRegenPerSecond(config.GetFocusRegenPerSecond(), config.Uuid)
case *proto.APLValue_EnergyTimeToMax:
value = rot.newValueEnergyTimeToMax(config.GetEnergyTimeToMax(), config.Uuid)
case *proto.APLValue_FocusTimeToMax:
value = rot.newValueFocusTimeToMax(config.GetFocusTimeToMax(), config.Uuid)
case *proto.APLValue_EnergyTimeToTarget:
value = rot.newValueEnergyTimeToTarget(config.GetEnergyTimeToTarget(), config.Uuid)
case *proto.APLValue_FocusTimeToTarget:
value = rot.newValueFocusTimeToTarget(config.GetFocusTimeToTarget(), config.Uuid)

// Resources Runes
case *proto.APLValue_CurrentRuneCount:
Expand Down
56 changes: 36 additions & 20 deletions sim/core/apl_values_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,29 +222,37 @@ func (value *APLValueFocusRegenPerSecond) String() string {
return "Focus Regen Per Second"
}

type APLValueFocusTimeToMax struct {
type APLValueFocusTimeToTarget struct {
DefaultAPLValueImpl
unit *Unit
unit *Unit
targetFocus APLValue
}

func (rot *APLRotation) newValueFocusTimeToMax(_ *proto.APLValueFocusTimeToMax, uuid *proto.UUID) APLValue {
func (rot *APLRotation) newValueFocusTimeToTarget(config *proto.APLValueFocusTimeToTarget, uuid *proto.UUID) APLValue {
unit := rot.unit
if !unit.HasFocusBar() {
rot.ValidationMessageByUUID(uuid, proto.LogLevel_Warning, "%s does not use Focus", unit.Label)
return nil
}
return &APLValueFocusTimeToMax{
unit: unit,

targetFocus := rot.coerceTo(rot.newAPLValue(config.TargetFocus), proto.APLValueType_ValueTypeFloat)
if targetFocus == nil {
return nil
}

return &APLValueFocusTimeToTarget{
unit: unit,
targetFocus: targetFocus,
}
}
func (value *APLValueFocusTimeToMax) Type() proto.APLValueType {
func (value *APLValueFocusTimeToTarget) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeDuration
}
func (value *APLValueFocusTimeToMax) GetDuration(sim *Simulation) time.Duration {
return value.unit.TimeToMaxFocus()
func (value *APLValueFocusTimeToTarget) GetDuration(sim *Simulation) time.Duration {
return value.unit.TimeToTargetFocus(value.targetFocus.GetFloat(sim))
}
func (value *APLValueFocusTimeToMax) String() string {
return "Estimated Time To Max Focus"
func (value *APLValueFocusTimeToTarget) String() string {
return "Estimated Time To Target Focus"
}

type APLValueCurrentEnergy struct {
Expand Down Expand Up @@ -322,29 +330,37 @@ func (value *APLValueEnergyRegenPerSecond) String() string {
return "Energy Regen Per Second"
}

type APLValueEnergyTimeToMax struct {
type APLValueEnergyTimeToTarget struct {
DefaultAPLValueImpl
unit *Unit
unit *Unit
targetEnergy APLValue
}

func (rot *APLRotation) newValueEnergyTimeToMax(_ *proto.APLValueEnergyTimeToMax, uuid *proto.UUID) APLValue {
func (rot *APLRotation) newValueEnergyTimeToTarget(config *proto.APLValueEnergyTimeToTarget, uuid *proto.UUID) APLValue {
unit := rot.unit
if !unit.HasEnergyBar() {
rot.ValidationMessageByUUID(uuid, proto.LogLevel_Warning, "%s does not use Energy", unit.Label)
return nil
}
return &APLValueEnergyTimeToMax{
unit: unit,

targetEnergy := rot.coerceTo(rot.newAPLValue(config.TargetEnergy), proto.APLValueType_ValueTypeFloat)
if targetEnergy == nil {
return nil
}

return &APLValueEnergyTimeToTarget{
unit: unit,
targetEnergy: targetEnergy,
}
}
func (value *APLValueEnergyTimeToMax) Type() proto.APLValueType {
func (value *APLValueEnergyTimeToTarget) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeDuration
}
func (value *APLValueEnergyTimeToMax) GetDuration(sim *Simulation) time.Duration {
return value.unit.TimeToMaxEnergy()
func (value *APLValueEnergyTimeToTarget) GetDuration(sim *Simulation) time.Duration {
return value.unit.TimeToTargetEnergy(value.targetEnergy.GetFloat(sim))
}
func (value *APLValueEnergyTimeToMax) String() string {
return "Estimated Time To Max Energy"
func (value *APLValueEnergyTimeToTarget) String() string {
return "Estimated Time To Target Energy"
}

type APLValueCurrentComboPoints struct {
Expand Down
6 changes: 3 additions & 3 deletions sim/core/energy.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ func (eb *energyBar) EnergyRegenPerSecond() float64 {
return 10.0 * eb.hasteRatingMultiplier * eb.energyRegenMultiplier
}

func (eb *energyBar) TimeToMaxEnergy() time.Duration {
if eb.currentEnergy == eb.maxEnergy {
func (eb *energyBar) TimeToTargetEnergy(targetEnergy float64) time.Duration {
if eb.currentEnergy >= targetEnergy {
return time.Duration(0)
}

return DurationFromSeconds((eb.maxEnergy - eb.currentEnergy) / eb.EnergyRegenPerSecond())
return DurationFromSeconds((targetEnergy - eb.currentEnergy) / eb.EnergyRegenPerSecond())
}

func (eb *energyBar) AddEnergy(sim *Simulation, amount float64, metrics *ResourceMetrics) {
Expand Down
6 changes: 3 additions & 3 deletions sim/core/focus.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ func (fb *focusBar) FocusRegenPerSecond() float64 {
}
}

func (fb *focusBar) TimeToMaxFocus() time.Duration {
if fb.currentFocus == fb.maxFocus {
func (fb *focusBar) TimeToTargetFocus(targetFocus float64) time.Duration {
if fb.currentFocus >= targetFocus {
return time.Duration(0)
}

return DurationFromSeconds((fb.maxFocus - fb.currentFocus) / fb.FocusRegenPerSecond())
return DurationFromSeconds((targetFocus - fb.currentFocus) / fb.FocusRegenPerSecond())
}

func (fb *focusBar) getTotalRegenMultiplier() float64 {
Expand Down
24 changes: 12 additions & 12 deletions ui/core/components/individual_sim_ui/apl_values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ import {
APLValueDotRemainingTime,
APLValueDotTickFrequency,
APLValueEnergyRegenPerSecond,
APLValueEnergyTimeToMax,
APLValueEnergyTimeToTarget,
APLValueFocusRegenPerSecond,
APLValueFocusTimeToMax,
APLValueFocusTimeToTarget,
APLValueFrontOfTarget,
APLValueGCDIsReady,
APLValueGCDTimeToReady,
Expand Down Expand Up @@ -725,13 +725,13 @@ const valueKindFactories: { [f in NonNullable<APLValueKind>]: ValueKindConfig<AP
includeIf: (player: Player<any>, _isPrepull: boolean) => player.getClass() == Class.ClassHunter,
fields: [],
}),
focusTimeToMax: inputBuilder({
label: 'Estimated Time To Max Focus',
focusTimeToTarget: inputBuilder({
label: 'Estimated Time To Target Focus',
submenu: ['Resources', 'Focus'],
shortDescription: 'Estimated time until max Focus is reached.',
newValue: APLValueFocusTimeToMax.create,
shortDescription: 'Estimated time until target Focus is reached, will return 0 if at or above target.',
newValue: APLValueFocusTimeToTarget.create,
includeIf: (player: Player<any>, _isPrepull: boolean) => player.getClass() == Class.ClassHunter,
fields: [],
fields: [valueFieldConfig('targetFocus')],
}),
currentEnergy: inputBuilder({
label: 'Current Energy',
Expand Down Expand Up @@ -769,17 +769,17 @@ const valueKindFactories: { [f in NonNullable<APLValueKind>]: ValueKindConfig<AP
},
fields: [],
}),
energyTimeToMax: inputBuilder({
label: 'Estimated Time To Max Energy',
energyTimeToTarget: inputBuilder({
label: 'Estimated Time To Target Energy',
submenu: ['Resources', 'Energy'],
shortDescription: 'Estimated time until max Energy is reached.',
newValue: APLValueEnergyTimeToMax.create,
shortDescription: 'Estimated time until target Energy is reached, will return 0 if at or above target.',
newValue: APLValueEnergyTimeToTarget.create,
includeIf(player: Player<any>, _isPrepull: boolean) {
const clss = player.getClass();
const spec = player.getSpec();
return spec === Spec.SpecFeralDruid || spec === Spec.SpecGuardianDruid || clss === Class.ClassRogue;
},
fields: [],
fields: [valueFieldConfig('targetEnergy')],
}),
currentComboPoints: inputBuilder({
label: 'Combo Points',
Expand Down

0 comments on commit accf399

Please sign in to comment.