Skip to content

Commit

Permalink
Add apl values for min, max, and sequences, and prot paladin APL preset
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyt857 committed Aug 19, 2023
1 parent cc06aa3 commit ac239ac
Show file tree
Hide file tree
Showing 14 changed files with 770 additions and 350 deletions.
25 changes: 24 additions & 1 deletion proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ message APLAction {
}
}

// NextIndex: 44
// NextIndex: 49
message APLValue {
oneof value {
// Operators
Expand All @@ -61,6 +61,8 @@ message APLValue {
APLValueNot not = 4;
APLValueCompare cmp = 5;
APLValueMath math = 38;
APLValueMax max = 47;
APLValueMin min = 48;

// Encounter values
APLValueCurrentTime current_time = 7;
Expand Down Expand Up @@ -114,6 +116,11 @@ message APLValue {
// Dot values
APLValueDotIsActive dot_is_active = 6;
APLValueDotRemainingTime dot_remaining_time = 13;

// Sequence values
APLValueSequenceIsComplete sequence_is_complete = 44;
APLValueSequenceIsReady sequence_is_ready = 45;
APLValueSequenceTimeToReady sequence_time_to_ready = 46;
}
}

Expand Down Expand Up @@ -229,6 +236,12 @@ message APLValueMath {
APLValue lhs = 2;
APLValue rhs = 3;
}
message APLValueMax {
repeated APLValue vals = 1;
}
message APLValueMin {
repeated APLValue vals = 1;
}

message APLValueCurrentTime {}
message APLValueCurrentTimePercent {}
Expand Down Expand Up @@ -353,3 +366,13 @@ message APLValueDotIsActive {
message APLValueDotRemainingTime {
ActionID spell_id = 1;
}

message APLValueSequenceIsComplete {
string sequence_name = 1;
}
message APLValueSequenceIsReady {
string sequence_name = 1;
}
message APLValueSequenceTimeToReady {
string sequence_name = 1;
}
4 changes: 2 additions & 2 deletions sim/core/apl.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ func (unit *Unit) newAPLRotation(config *proto.APLRotation) *APLRotation {

// Finalize
for _, action := range rotation.prepullActions {
action.impl.Finalize(rotation)
action.Finalize(rotation)
rotation.curWarnings = nil
}
for i, action := range rotation.priorityList {
action.impl.Finalize(rotation)
action.Finalize(rotation)

rotation.priorityListWarnings[configIdxs[i]] = append(rotation.priorityListWarnings[configIdxs[i]], rotation.curWarnings...)
rotation.curWarnings = nil
Expand Down
27 changes: 26 additions & 1 deletion sim/core/apl_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package core

import (
"fmt"

"github.com/wowsims/wotlk/sim/core/proto"
)

Expand All @@ -10,6 +11,13 @@ type APLAction struct {
impl APLActionImpl
}

func (action *APLAction) Finalize(rot *APLRotation) {
action.impl.Finalize(rot)
for _, value := range action.GetAllAPLValues() {
value.Finalize(rot)
}
}

func (action *APLAction) IsReady(sim *Simulation) bool {
return (action.condition == nil || action.condition.GetBool(sim)) && action.impl.IsReady(sim)
}
Expand All @@ -25,6 +33,19 @@ func (action *APLAction) GetAllActions() []*APLAction {
return actions
}

// Returns all APLValues used by this action and all of its inner Actions.
func (action *APLAction) GetAllAPLValues() []APLValue {
var values []APLValue
for _, a := range action.GetAllActions() {
values = append(values, a.impl.GetAPLValues()...)
if action.condition != nil {
values = append(values, a.condition)
values = append(values, a.condition.GetInnerValues()...)
}
}
return FilterSlice(values, func(val APLValue) bool { return val != nil })
}

func (action *APLAction) String() string {
if action.condition == nil {
return fmt.Sprintf("ACTION = %s", action.impl)
Expand All @@ -34,9 +55,12 @@ func (action *APLAction) String() string {
}

type APLActionImpl interface {
// Returns all inner Actions.
// Returns all inner APL Actions.
GetInnerActions() []*APLAction

// Returns all APLValues used by this Action (but not by inner Actions).
GetAPLValues() []APLValue

// Performs optional post-processing.
Finalize(*APLRotation)

Expand All @@ -58,6 +82,7 @@ type defaultAPLActionImpl struct {
}

func (impl defaultAPLActionImpl) GetInnerActions() []*APLAction { return nil }
func (impl defaultAPLActionImpl) GetAPLValues() []APLValue { return nil }
func (impl defaultAPLActionImpl) Finalize(*APLRotation) {}
func (impl defaultAPLActionImpl) Reset(*Simulation) {}

Expand Down
9 changes: 9 additions & 0 deletions sim/core/apl_actions_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func (rot *APLRotation) newActionMultidot(config *proto.APLActionMultidot) APLAc
maxOverlap: maxOverlap,
}
}
func (action *APLActionMultidot) GetAPLValues() []APLValue {
return []APLValue{action.maxOverlap}
}
func (action *APLActionMultidot) Reset(*Simulation) {
action.nextTarget = nil
}
Expand Down Expand Up @@ -143,6 +146,9 @@ func (rot *APLRotation) newActionMultishield(config *proto.APLActionMultishield)
maxOverlap: maxOverlap,
}
}
func (action *APLActionMultishield) GetAPLValues() []APLValue {
return []APLValue{action.maxOverlap}
}
func (action *APLActionMultishield) Reset(*Simulation) {
action.nextTarget = nil
}
Expand Down Expand Up @@ -211,6 +217,9 @@ func (rot *APLRotation) newActionWait(config *proto.APLActionWait) APLActionImpl
duration: rot.coerceTo(rot.newAPLValue(config.Duration), proto.APLValueType_ValueTypeDuration),
}
}
func (action *APLActionWait) GetAPLValues() []APLValue {
return []APLValue{action.duration}
}
func (action *APLActionWait) IsReady(sim *Simulation) bool {
return action.duration != nil
}
Expand Down
2 changes: 0 additions & 2 deletions sim/core/apl_actions_sequences.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (action *APLActionSequence) String() string {

type APLActionResetSequence struct {
defaultAPLActionImpl
unit *Unit
name string
sequence *APLActionSequence
}
Expand All @@ -65,7 +64,6 @@ func (rot *APLRotation) newActionResetSequence(config *proto.APLActionResetSeque
return nil
}
return &APLActionResetSequence{
unit: rot.unit,
name: config.SequenceName,
}
}
Expand Down
21 changes: 21 additions & 0 deletions sim/core/apl_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
)

type APLValue interface {
// Returns all inner APLValues.
GetInnerValues() []APLValue

// The type of value that will be returned.
Type() proto.APLValueType

Expand All @@ -18,6 +21,9 @@ type APLValue interface {
GetDuration(*Simulation) time.Duration
GetString(*Simulation) string

// Performs optional post-processing.
Finalize(*APLRotation)

// Pretty-print string for debugging.
String() string
}
Expand All @@ -26,6 +32,9 @@ type APLValue interface {
type defaultAPLValueImpl struct {
}

func (impl defaultAPLValueImpl) GetInnerValues() []APLValue { return nil }
func (impl defaultAPLValueImpl) Finalize(*APLRotation) {}

func (impl defaultAPLValueImpl) GetBool(sim *Simulation) bool {
panic("Unimplemented GetBool")
}
Expand Down Expand Up @@ -61,6 +70,10 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue {
return rot.newValueCompare(config.GetCmp())
case *proto.APLValue_Math:
return rot.newValueMath(config.GetMath())
case *proto.APLValue_Max:
return rot.newValueMax(config.GetMax())
case *proto.APLValue_Min:
return rot.newValueMin(config.GetMin())

// Encounter
case *proto.APLValue_CurrentTime:
Expand Down Expand Up @@ -152,6 +165,14 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue {
case *proto.APLValue_DotRemainingTime:
return rot.newValueDotRemainingTime(config.GetDotRemainingTime())

// Sequences
case *proto.APLValue_SequenceIsComplete:
return rot.newValueSequenceIsComplete(config.GetSequenceIsComplete())
case *proto.APLValue_SequenceIsReady:
return rot.newValueSequenceIsReady(config.GetSequenceIsReady())
case *proto.APLValue_SequenceTimeToReady:
return rot.newValueSequenceTimeToReady(config.GetSequenceTimeToReady())

default:
return nil
}
Expand Down
3 changes: 3 additions & 0 deletions sim/core/apl_values_aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func (rot *APLRotation) newValueAuraShouldRefresh(config *proto.APLValueAuraShou
maxOverlap: maxOverlap,
}
}
func (value *APLValueAuraShouldRefresh) GetInnerValues() []APLValue {
return []APLValue{value.maxOverlap}
}
func (value *APLValueAuraShouldRefresh) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeBool
}
Expand Down
Loading

0 comments on commit ac239ac

Please sign in to comment.