-
Notifications
You must be signed in to change notification settings - Fork 45
/
apl_values.go
88 lines (71 loc) · 2.77 KB
/
apl_values.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package paladin
import (
"time"
"github.com/wowsims/sod/sim/core"
"github.com/wowsims/sod/sim/core/proto"
)
// The APLValue for the remaining duration of the primary seal aura.
func (paladin *Paladin) NewAPLValue(rot *core.APLRotation, config *proto.APLValue) core.APLValue {
switch config.Value.(type) {
case *proto.APLValue_CurrentSealRemainingTime:
return paladin.newValueCurrentSealRemainingTime(rot, config.GetCurrentSealRemainingTime())
default:
return nil
}
}
type APLValueCurrentSealRemainingTime struct {
core.DefaultAPLValueImpl
paladin *Paladin
}
func (paladin *Paladin) newValueCurrentSealRemainingTime(_ *core.APLRotation, _ *proto.APLValueCurrentSealRemainingTime) core.APLValue {
return &APLValueCurrentSealRemainingTime{
paladin: paladin,
}
}
func (x *APLValueCurrentSealRemainingTime) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeDuration
}
func (x *APLValueCurrentSealRemainingTime) GetDuration(sim *core.Simulation) time.Duration {
if x.paladin.currentSeal.IsActive() {
return x.paladin.currentSeal.RemainingDuration(sim)
}
return 0
}
func (x *APLValueCurrentSealRemainingTime) String() string {
return "Current Seal Remaining Time()"
}
// The APLAction for casting the current Seal
func (paladin *Paladin) NewAPLAction(rot *core.APLRotation, config *proto.APLAction) core.APLActionImpl {
switch config.Action.(type) {
case *proto.APLAction_CastPaladinPrimarySeal:
return paladin.newActionPaladinPrimarySealAction(rot, config.GetCastPaladinPrimarySeal())
default:
return nil
}
}
type APLActionCastPaladinPrimarySeal struct {
paladin *Paladin
lastAction time.Duration
}
func (x *APLActionCastPaladinPrimarySeal) GetInnerActions() []*core.APLAction { return nil }
func (x *APLActionCastPaladinPrimarySeal) GetAPLValues() []core.APLValue { return nil }
func (x *APLActionCastPaladinPrimarySeal) Finalize(*core.APLRotation) {}
func (x *APLActionCastPaladinPrimarySeal) GetNextAction(*core.Simulation) *core.APLAction { return nil }
func (paladin *Paladin) newActionPaladinPrimarySealAction(_ *core.APLRotation, _ *proto.APLActionCastPaladinPrimarySeal) core.APLActionImpl {
return &APLActionCastPaladinPrimarySeal{
paladin: paladin,
}
}
func (x *APLActionCastPaladinPrimarySeal) Execute(sim *core.Simulation) {
x.lastAction = sim.CurrentTime
x.paladin.primarySeal.Cast(sim, x.paladin.CurrentTarget)
}
func (x *APLActionCastPaladinPrimarySeal) IsReady(sim *core.Simulation) bool {
return sim.CurrentTime > x.lastAction && x.paladin.primarySeal.CanCast(sim, x.paladin.CurrentTarget)
}
func (x *APLActionCastPaladinPrimarySeal) Reset(*core.Simulation) {
x.lastAction = core.DurationFromSeconds(-100)
}
func (x *APLActionCastPaladinPrimarySeal) String() string {
return "Cast Primary Seal()"
}