Skip to content

Commit

Permalink
Merge pull request #536 from wowsims/kg/spell-known-aura-known
Browse files Browse the repository at this point in the history
Core: Add APL "Spell Known" and "Aura Known" values
  • Loading branch information
rosenrusinov authored Apr 1, 2024
2 parents ab474e6 + c793cd0 commit 903b5e7
Show file tree
Hide file tree
Showing 12 changed files with 638 additions and 95 deletions.
11 changes: 10 additions & 1 deletion proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ message APLAction {
}
}

// NextIndex: 67
// NextIndex: 69
message APLValue {
oneof value {
// Operators
Expand Down Expand Up @@ -121,6 +121,7 @@ message APLValue {
APLValueAutoSwingTime auto_swing_time = 64;

// Spell values
APLValueSpellIsKnown spell_is_known = 68;
APLValueSpellCanCast spell_can_cast = 19;
APLValueSpellIsReady spell_is_ready = 20;
APLValueSpellTimeToReady spell_time_to_ready = 21;
Expand All @@ -132,6 +133,7 @@ message APLValue {
APLValueSpellCurrentCost spell_current_cost = 62;

// Aura values
APLValueAuraIsKnown aura_is_known = 67;
APLValueAuraIsActive aura_is_active = 22;
APLValueAuraIsActiveWithReactionTime aura_is_active_with_reaction_time = 50;
APLValueAuraRemainingTime aura_remaining_time = 23;
Expand Down Expand Up @@ -394,6 +396,9 @@ message APLValueAutoSwingTime {
SwingType auto_type = 1;
}

message APLValueSpellIsKnown {
ActionID spell_id = 1;
}
message APLValueSpellCanCast {
ActionID spell_id = 1;
}
Expand Down Expand Up @@ -427,6 +432,10 @@ message APLValueSpellCurrentCost {
ActionID spell_id = 1;
}

message APLValueAuraIsKnown {
UnitReference source_unit = 2;
ActionID aura_id = 1;
}
message APLValueAuraIsActive {
UnitReference source_unit = 2;
ActionID aura_id = 1;
Expand Down
6 changes: 6 additions & 0 deletions sim/core/apl_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue {
return rot.newValueAutoSwingTime(config.GetAutoSwingTime())

// Spells
case *proto.APLValue_SpellIsKnown:
return rot.newValueSpellIsKnown(config.GetSpellIsKnown())
case *proto.APLValue_SpellCanCast:
return rot.newValueSpellCanCast(config.GetSpellCanCast())
case *proto.APLValue_SpellIsReady:
Expand All @@ -141,8 +143,12 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue {
return rot.newValueSpellIsChanneling(config.GetSpellIsChanneling())
case *proto.APLValue_SpellChanneledTicks:
return rot.newValueSpellChanneledTicks(config.GetSpellChanneledTicks())
case *proto.APLValue_SpellCurrentCost:
return rot.newValueSpellCurrentCost(config.GetSpellCurrentCost())

// Auras
case *proto.APLValue_AuraIsKnown:
return rot.newValueAuraIsKnown(config.GetAuraIsKnown())
case *proto.APLValue_AuraIsActive:
return rot.newValueAuraIsActive(config.GetAuraIsActive())
case *proto.APLValue_AuraIsActiveWithReactionTime:
Expand Down
28 changes: 27 additions & 1 deletion sim/core/apl_values_aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,39 @@ import (
"github.com/wowsims/sod/sim/core/proto"
)

type APLValueAuraIsKnown struct {
DefaultAPLValueImpl
aura AuraReference
}

func (rot *APLRotation) newValueAuraIsKnown(config *proto.APLValueAuraIsKnown) APLValue {
aura := rot.GetAPLAura(rot.GetSourceUnit(config.SourceUnit), config.AuraId)
return &APLValueAuraIsKnown{
aura: aura,
}
}
func (value *APLValueAuraIsKnown) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeBool
}
func (value *APLValueAuraIsKnown) GetBool(sim *Simulation) bool {
return value.aura.Get() != nil
}
func (value *APLValueAuraIsKnown) String() string {
return fmt.Sprintf("Aura Active(%s)", value.aura.String())
}

type APLValueAuraIsActive struct {
DefaultAPLValueImpl
aura AuraReference
}

func (rot *APLRotation) newValueAuraIsActive(config *proto.APLValueAuraIsActive) APLValue {
aura := rot.GetAPLAura(rot.GetSourceUnit(config.SourceUnit), config.AuraId)

if aura.Get() == nil {
return nil
}

return &APLValueAuraIsActive{
aura: aura,
}
Expand All @@ -22,7 +48,7 @@ func (value *APLValueAuraIsActive) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeBool
}
func (value *APLValueAuraIsActive) GetBool(sim *Simulation) bool {
return value.aura.Get() != nil && value.aura.Get().IsActive()
return value.aura.Get().IsActive()
}
func (value *APLValueAuraIsActive) String() string {
return fmt.Sprintf("Aura Active(%s)", value.aura.String())
Expand Down
1 change: 1 addition & 0 deletions sim/core/apl_values_operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ type APLValueCompare struct {

func (rot *APLRotation) newValueCompare(config *proto.APLValueCompare) APLValue {
lhs, rhs := rot.coerceToSameType(rot.newAPLValue(config.Lhs), rot.newAPLValue(config.Rhs))

if lhs == nil || rhs == nil {
return nil
}
Expand Down
21 changes: 21 additions & 0 deletions sim/core/apl_values_spell.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ import (
"github.com/wowsims/sod/sim/core/proto"
)

type APLValueSpellIsKnown struct {
DefaultAPLValueImpl
spell *Spell
}

func (rot *APLRotation) newValueSpellIsKnown(config *proto.APLValueSpellIsKnown) APLValue {
spell := rot.GetAPLSpell(config.SpellId)
return &APLValueSpellIsKnown{
spell: spell,
}
}
func (value *APLValueSpellIsKnown) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeBool
}
func (value *APLValueSpellIsKnown) GetBool(sim *Simulation) bool {
return value.spell != nil
}
func (value *APLValueSpellIsKnown) String() string {
return fmt.Sprintf("Is Known(%s)", value.spell.ActionID)
}

type APLValueSpellCanCast struct {
DefaultAPLValueImpl
spell *Spell
Expand Down
Loading

0 comments on commit 903b5e7

Please sign in to comment.