-
Notifications
You must be signed in to change notification settings - Fork 28
/
apl_values_encounter.go
124 lines (110 loc) · 3.53 KB
/
apl_values_encounter.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package core
import (
"fmt"
"time"
"github.com/wowsims/sod/sim/core/proto"
)
type APLValueCurrentTime struct {
DefaultAPLValueImpl
}
func (rot *APLRotation) newValueCurrentTime(config *proto.APLValueCurrentTime) APLValue {
return &APLValueCurrentTime{}
}
func (value *APLValueCurrentTime) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeDuration
}
func (value *APLValueCurrentTime) GetDuration(sim *Simulation) time.Duration {
return sim.CurrentTime
}
func (value *APLValueCurrentTime) String() string {
return "Current Time"
}
type APLValueCurrentTimePercent struct {
DefaultAPLValueImpl
}
func (rot *APLRotation) newValueCurrentTimePercent(config *proto.APLValueCurrentTimePercent) APLValue {
return &APLValueCurrentTimePercent{}
}
func (value *APLValueCurrentTimePercent) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeFloat
}
func (value *APLValueCurrentTimePercent) GetFloat(sim *Simulation) float64 {
return sim.CurrentTime.Seconds() / sim.Duration.Seconds()
}
func (value *APLValueCurrentTimePercent) String() string {
return fmt.Sprintf("Current Time %%")
}
type APLValueRemainingTime struct {
DefaultAPLValueImpl
}
func (rot *APLRotation) newValueRemainingTime(config *proto.APLValueRemainingTime) APLValue {
return &APLValueRemainingTime{}
}
func (value *APLValueRemainingTime) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeDuration
}
func (value *APLValueRemainingTime) GetDuration(sim *Simulation) time.Duration {
return sim.GetRemainingDuration()
}
func (value *APLValueRemainingTime) String() string {
return "Remaining Time"
}
type APLValueRemainingTimePercent struct {
DefaultAPLValueImpl
}
func (rot *APLRotation) newValueRemainingTimePercent(config *proto.APLValueRemainingTimePercent) APLValue {
return &APLValueRemainingTimePercent{}
}
func (value *APLValueRemainingTimePercent) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeFloat
}
func (value *APLValueRemainingTimePercent) GetFloat(sim *Simulation) float64 {
return sim.GetRemainingDurationPercent()
}
func (value *APLValueRemainingTimePercent) String() string {
return fmt.Sprintf("Remaining Time %%")
}
type APLValueNumberTargets struct {
DefaultAPLValueImpl
}
func (rot *APLRotation) newValueNumberTargets(config *proto.APLValueNumberTargets) APLValue {
return &APLValueNumberTargets{}
}
func (value *APLValueNumberTargets) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeInt
}
func (value *APLValueNumberTargets) GetInt(sim *Simulation) int32 {
return sim.GetNumTargets()
}
func (value *APLValueNumberTargets) String() string {
return "Num Targets"
}
type APLValueIsExecutePhase struct {
DefaultAPLValueImpl
threshold proto.APLValueIsExecutePhase_ExecutePhaseThreshold
}
func (rot *APLRotation) newValueIsExecutePhase(config *proto.APLValueIsExecutePhase) APLValue {
if config.Threshold == proto.APLValueIsExecutePhase_Unknown {
return nil
}
return &APLValueIsExecutePhase{
threshold: config.Threshold,
}
}
func (value *APLValueIsExecutePhase) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeBool
}
func (value *APLValueIsExecutePhase) GetBool(sim *Simulation) bool {
if value.threshold == proto.APLValueIsExecutePhase_E20 {
return sim.IsExecutePhase20()
} else if value.threshold == proto.APLValueIsExecutePhase_E25 {
return sim.IsExecutePhase25()
} else if value.threshold == proto.APLValueIsExecutePhase_E35 {
return sim.IsExecutePhase35()
} else {
panic("Should never reach here")
}
}
func (value *APLValueIsExecutePhase) String() string {
return "Is Execute Phase"
}