/
ant_role.go
262 lines (219 loc) · 5.31 KB
/
ant_role.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/*
Copyright (c) 2024 Sebastian Kroczek <me@xbug.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package simulation
import "github.com/gotameme/core/ant"
type Properties struct {
Speed AntSpeed
Rotation AntRotation
Load AntLoad
Vision AntVision
Range int
Energy AntEnergy
Attack AntAttack
}
func NewDefaultProperties(defaultRange float64) Properties {
return Properties{
Speed: DefaultSpeed,
Rotation: DefaultRotation,
Load: DefaultLoad,
Vision: DefaultVision,
Range: int(defaultRange * DefaultRange),
Energy: DefaultEnergy,
Attack: DefaultAttack,
}
}
func ApplyAntRole(defaultRange float64, role ant.Adjustments) Properties {
a := Properties{}
a.Speed = ToAntSpeed(role.Speed)
a.Rotation = ToAntRotation(role.Rotation)
a.Load = ToAntLoad(role.Load)
a.Vision = ToAntVision(role.Vision)
a.Range = int(defaultRange * ToAntRange(role.Range))
a.Energy = ToAntEnergy(role.Energy)
a.Attack = ToAntAttack(role.Attack)
return a
}
// region AntSpeed
// AntSpeed Adjustments for speed
type AntSpeed float64
const (
DecreasedSpeed AntSpeed = 3
DefaultSpeed = 4
IncreasedSpeed = 5
BoostedSpeed = 6
)
func ToAntSpeed(a ant.Level) AntSpeed {
switch a {
case ant.Decreased:
return DecreasedSpeed
case ant.Default:
return DefaultSpeed
case ant.Increased:
return IncreasedSpeed
case ant.Boosted:
return BoostedSpeed
default:
return DefaultSpeed
}
}
// endregion
// region AntRotation
// AntRotation Adjustments for rotation
type AntRotation int
const (
DecreasedRotation AntRotation = 6
DefaultRotation = 8
IncreasedRotation = 12
BoostedRotation = 16
)
func ToAntRotation(a ant.Level) AntRotation {
switch a {
case ant.Decreased:
return DecreasedRotation
case ant.Default:
return DefaultRotation
case ant.Increased:
return IncreasedRotation
case ant.Boosted:
return BoostedRotation
default:
return DefaultRotation
}
}
// endregion
// region AntLoad
// AntLoad Adjustments for load
type AntLoad int
const (
DecreasedLoad AntLoad = 4
DefaultLoad = 5
IncreasedLoad = 7
BoostedLoad = 10
)
func ToAntLoad(a ant.Level) AntLoad {
switch a {
case ant.Decreased:
return DecreasedLoad
case ant.Default:
return DefaultLoad
case ant.Increased:
return IncreasedLoad
case ant.Boosted:
return BoostedLoad
default:
return DefaultLoad
}
}
// endregion
// region AntVision
// AntVision Adjustments for vision
type AntVision int
const (
DecreasedVision AntVision = 45
DefaultVision = 60
IncreasedVision = 75
BoostedVision = 90
)
func ToAntVision(a ant.Level) AntVision {
switch a {
case ant.Decreased:
return DecreasedVision
case ant.Default:
return DefaultVision
case ant.Increased:
return IncreasedVision
case ant.Boosted:
return BoostedVision
default:
return DefaultVision
}
}
// endregion
// region AntRange
// AntRange Adjustments for range
type AntRange float64
const (
DecreasedRange AntRange = 0.75
DefaultRange = 1.0
IncreasedRange = 1.5
BoostedRange = 2
)
func ToAntRange(a ant.Level) float64 {
switch a {
case ant.Decreased:
return float64(DecreasedRange)
case ant.Default:
return DefaultRange
case ant.Increased:
return IncreasedRange
case ant.Boosted:
return BoostedRange
default:
return DefaultRange
}
}
// endregion
// region AntEnergy
// AntEnergy Adjustments for energy
type AntEnergy int
const (
DecreasedEnergy AntEnergy = 50
DefaultEnergy = 100
IncreasedEnergy = 175
BoostedEnergy = 250
)
func ToAntEnergy(a ant.Level) AntEnergy {
switch a {
case ant.Decreased:
return DecreasedEnergy
case ant.Default:
return DefaultEnergy
case ant.Increased:
return IncreasedEnergy
case ant.Boosted:
return BoostedEnergy
default:
return DefaultEnergy
}
}
// endregion
// region AntAttack
// AntAttack Adjustments for attack
type AntAttack int
const (
DecreasedAttack AntAttack = 0
DefaultAttack = 10
IncreasedAttack = 20
BoostedAttack = 30
)
func ToAntAttack(a ant.Level) AntAttack {
switch a {
case ant.Decreased:
return DecreasedAttack
case ant.Default:
return DefaultAttack
case ant.Increased:
return IncreasedAttack
case ant.Boosted:
return BoostedAttack
default:
return DefaultAttack
}
}
// endregion