forked from KeithMaxwellZ/FCO_Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.py
345 lines (254 loc) · 9.02 KB
/
actions.py
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
import status
from utils import *
ACTION_ID = {}
ACTIONS_ALL = []
class ActionBase:
def __init__(
self,
name: str = "",
durability_cost: int = 0,
cp_cost: int = 0,
success_rate: float = 1.0,
progress_multiplier: float = 0.0,
quality_multiplier: float = 0.0,
buff=-1
):
self.name = name
self.durability_cost = durability_cost
self.cp_cost = cp_cost
self.success_rate = success_rate
self.progress_multiplier = progress_multiplier
self.quality_multiplier = quality_multiplier
self.buff = buff
ACTION_ID[self.name] = len(ACTIONS_ALL)
ACTIONS_ALL.append(self)
def check_success(self, engine):
"""
Check if the condition is met
:param engine: current engine instance
:return: success rate
"""
return self.success_rate
def get_cp(self, engine):
return self.cp_cost
def __str__(self):
return self.name
def __repr__(self):
return self.name
class MuscleMemory(ActionBase):
def __init__(self):
super().__init__("Muscle Memory", 10, 6, 1.0, 3.0, 0.0, 5)
def check_success(self, engine):
if engine.turn > 0:
raise EngineException(1)
return self.success_rate
class Reflect(ActionBase):
def __init__(self):
super().__init__("Reflect", 10, 6, 1.0, 0.0, 1.0, -1)
def check_success(self, engine):
if engine.turn > 0:
raise EngineException(1)
return self.success_rate
# Synthesis actions
class BasicSynth(ActionBase):
def __init__(self):
super().__init__("Basic Synth", 10, 0, 1.0, 1.2, 0.0, -1)
class CarefulSynth(ActionBase):
def __init__(self):
super().__init__("Careful Synth", 10, 7, 1.0, 1.8, 0.0, -1)
class RapidSynth(ActionBase):
def __init__(self):
super().__init__("Rapid Synth", 10, 0, 0.5, 5.0, 0.0, -1)
class FocusedSynthesis(ActionBase):
def __init__(self):
super().__init__("Focused Synth", 10, 5, 0.5, 2.0, 0.0, -1)
def check_success(self, engine):
return self.success_rate + (0.5 if engine.buffs[1] > 0 else 0)
class Groundwork(ActionBase):
def __init__(self):
super().__init__("Groundwork", 20, 18, 1.0, 3.6, 0.0, -1)
class IntensiveSynthesis(ActionBase):
def __init__(self):
super().__init__("Intensive Synthesis", 10, 6, 1.0, 4.0, 0.0, -1)
def check_success(self, engine):
if engine.status != status.RED:
if engine.buffs[8] > 0:
if engine.cp_current >= self.cp_cost:
engine.buffs[8] = 0
else:
raise EngineException(2)
return self.success_rate
class PrudentSynthesis(ActionBase):
def __init__(self):
super().__init__("Prudent Synthesis", 5, 18, 1.0, 1.8, 0.0, -1)
def check_success(self, engine):
if engine.buffs[2] > 0:
raise EngineException(6)
return self.success_rate
class DelicateSynthesis(ActionBase):
def __init__(self):
super().__init__("Delicate Synthesis", 10, 32, 1.0, 1.0, 1.0, -1)
# Touch actions
class BasicTouch(ActionBase):
def __init__(self):
super().__init__("Basic Touch", 10, 18, 1.0, 0.0, 1.0, -1)
class HastyTouch(ActionBase):
def __init__(self):
super().__init__("Hasty Touch", 10, 0, 0.6, 0.0, 1.0, -1)
class StandardTouch(ActionBase):
def __init__(self):
super().__init__("Standard Touch", 10, 32, 1.0, 0.0, 1.25, -1)
def get_cp(self, engine):
if engine.touchCombo == 1:
return 18
else:
return self.cp_cost
class ByregotsBlessing(ActionBase):
def __init__(self):
super().__init__("Byregots Blessing", 10, 24, 1.0, 0.0, 1.0, -1)
class PreciseTouch(ActionBase):
def __init__(self):
super().__init__("Precise Touch", 10, 18, 1.0, 0.0, 1.5, -1)
def check_success(self, engine):
if engine.status != status.RED:
if engine.buffs[8] > 0:
if engine.cp_current >= self.cp_cost:
engine.buffs[8] = 0
else:
raise EngineException(2)
return self.success_rate
class PrudentTouch(ActionBase):
def __init__(self):
super().__init__("Prudent Touch", 5, 25, 1.0, 0.0, 1.0, -1)
def check_success(self, engine):
if engine.buffs[2] > 0:
raise EngineException(6)
return self.success_rate
class FocusedTouch(ActionBase):
def __init__(self):
super().__init__("Focused Touch", 10, 18, 0.5, 0.0, 1.5, -1)
def check_success(self, engine):
return self.success_rate + (0.5 if engine.buffs[1] > 0 else 0)
class PreparatoryTouch(ActionBase):
def __init__(self):
super().__init__("Preparatory Touch", 20, 40, 1.0, 0.0, 2.0, -1)
class AdvancedTouch(ActionBase):
def __init__(self):
super().__init__("Advanced Touch", 10, 46, 1.0, 0.0, 1.5, -1)
def get_cp(self, engine):
if engine.touchCombo == 2:
return 18
else:
return self.cp_cost
class TrainedFinesse(ActionBase):
def __init__(self):
super().__init__("Trained Finesse", 0, 32, 1.0, 0.0, 1.00, -1)
def check_success(self, engine):
if engine.inner_quiet < 10:
raise EngineException(3)
return self.success_rate
class MastersMend(ActionBase):
def __init__(self):
super().__init__("Master's Mend", 0, 88, 1.0, 0.0, 0.0, -1)
def check_success(self, engine):
# engine.dura_current = min((engine.dura_current + 30), engine.dura_total)
return self.success_rate
class WasteNot(ActionBase):
def __init__(self):
super().__init__("Waste Not", 0, 56, 1.0, 0.0, 0.0, 24)
class WasteNotII(ActionBase):
def __init__(self):
super().__init__("Waste Not II", 0, 98, 1.0, 0.0, 0.0, 28)
class Manipulation(ActionBase):
def __init__(self):
super().__init__("Manipulation", 0, 96, 1.0, 0.0, 0.0, 38)
def check_success(self, engine):
engine.buffs[3] = 0
return self.success_rate
class Veneration(ActionBase):
def __init__(self):
super().__init__("Veneration", 0, 18, 1.0, 0.0, 0.0, 44)
class GreatStrides(ActionBase):
def __init__(self):
super().__init__("Great Strides", 0, 32, 1.0, 0.0, 0.0, 53)
class Innovation(ActionBase):
def __init__(self):
super().__init__("Innovation", 0, 18, 1.0, 0.0, 0.0, 64)
class Observe(ActionBase):
def __init__(self):
super().__init__("Observe", 0, 7, 1.0, 0.0, 0.0, 11)
class TricksOfTheTrade(ActionBase):
def __init__(self):
super().__init__("Tricks of the Trade", 0, 0, 1.0, 0.0, 0.0, -1)
def check_success(self, engine):
if engine.status != status.RED:
if engine.buffs[8] > 0:
engine.buffs[8] = 0
else:
raise EngineException(2)
engine.cp_current = min(engine.cp_current + 20, engine.cp_total)
return self.success_rate
class FinalAppraisal(ActionBase):
def __init__(self):
super().__init__("Final Appraisal", 0, 1, 1.0, 0.0, 0.0, -1)
def check_success(self, engine):
# if engine.faReady <= 0:
# raise EngineException(5)
# engine.faReady -= 1
engine.cp_current -= 1
engine.buffs[7] = 5
return 0
class HeartAndSoul(ActionBase):
def __init__(self):
super().__init__("Heart And Soul", 0, 0, 1.0, 0.0, 0.0, -1)
def check_success(self, engine):
if engine.hsReady <= 0:
raise EngineException(5)
engine.hsReady -= 1
engine.buffs[8] = 999
return 0
class CarefulObservation(ActionBase):
def __init__(self):
super().__init__("Careful Observation", 0, 0, 1.0, 0.0, 0.0, -1)
def check_success(self, engine):
if engine.caReady <= 0:
raise EngineException(5)
engine.caReady -= 1
engine.status = engine.status_manager.next_status()
return 0
MuscleMemory = MuscleMemory()
Reflect = Reflect()
BasicSynth = BasicSynth()
CarefulSynth = CarefulSynth()
RapidSynth = RapidSynth()
FocusedSynthesis = FocusedSynthesis()
Groundwork = Groundwork()
IntensiveSynthesis = IntensiveSynthesis()
PrudentSynthesis = PrudentSynthesis()
DelicateSynthesis = DelicateSynthesis()
BasicTouch = BasicTouch()
HastyTouch = HastyTouch()
StandardTouch = StandardTouch()
ByregotsBlessing = ByregotsBlessing()
PreciseTouch = PreciseTouch()
PrudentTouch = PrudentTouch()
FocusedTouch = FocusedTouch()
PreparatoryTouch = PreparatoryTouch()
AdvancedTouch = AdvancedTouch()
TrainedFinesse = TrainedFinesse()
MastersMend = MastersMend()
WasteNot = WasteNot()
WasteNotII = WasteNotII()
Manipulation = Manipulation()
Veneration = Veneration()
GreatStrides = GreatStrides()
Innovation = Innovation()
Observe = Observe()
TricksOfTheTrade = TricksOfTheTrade()
FinalAppraisal = FinalAppraisal()
HeartAndSoul = HeartAndSoul()
CarefulObservation = CarefulObservation()
if __name__ == '__main__':
print(ACTIONS_ALL)
for i in ACTIONS_ALL:
print(i)