Skip to content

Commit 5318ff6

Browse files
committed
Add: class EquipmentCodeHandler
1 parent 819ac40 commit 5318ff6

2 files changed

Lines changed: 322 additions & 120 deletions

File tree

module/equipment/equipment.py

Lines changed: 126 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from module.base.decorator import cached_property
33
from module.base.timer import Timer
44
from module.equipment.assets import *
5+
from module.equipment.equipment_code import EquipmentCodeHandler
56
from module.logger import logger
67
from module.retire.assets import DOCK_CHECK, EQUIP_CONFIRM as RETIRE_EQUIP_CONFIRM
7-
from module.storage.storage import StorageHandler
88
from module.ui.assets import BACK_ARROW
99
from module.ui.navbar import Navbar
1010

@@ -14,7 +14,7 @@
1414
EQUIPMENT_OPEN.match = EQUIPMENT_OPEN.match_luma
1515

1616

17-
class Equipment(StorageHandler):
17+
class Equipment(EquipmentCodeHandler):
1818
equipment_has_take_on = False
1919

2020
def _ship_view_swipe(self, distance, check_button=EQUIPMENT_OPEN):
@@ -159,121 +159,127 @@ def ship_side_navbar_ensure(self, upper=None, bottom=None):
159159
return True
160160
return False
161161

162-
def ship_equipment_take_off(self, skip_first_screenshot=True):
163-
logger.info('Equipment take off')
164-
bar_timer = Timer(5)
165-
off_timer = Timer(5)
166-
confirm_timer = Timer(5)
167-
168-
while 1:
169-
if skip_first_screenshot:
170-
skip_first_screenshot = False
171-
else:
172-
self.device.screenshot()
173-
174-
# End
175-
# if self.handle_info_bar():
176-
# break
177-
if off_timer.started() and self.info_bar_count():
178-
break
179-
180-
if self.handle_storage_full():
181-
continue
182-
183-
if confirm_timer.reached() and self.handle_popup_confirm('EQUIPMENT_TAKE_OFF'):
184-
confirm_timer.reset()
185-
off_timer.reset()
186-
bar_timer.reset()
187-
continue
188-
189-
if off_timer.reached():
190-
if not self.info_bar_count() and self.appear_then_click(EQUIP_OFF, offset=(20, 20)):
191-
off_timer.reset()
192-
bar_timer.reset()
193-
continue
194-
195-
if bar_timer.reached():
196-
if self.appear(EQUIPMENT_OPEN, offset=(20, 20)) and not self.appear(EQUIP_OFF, offset=(20, 20)):
197-
self.device.click(EQUIPMENT_OPEN)
198-
bar_timer.reset()
199-
continue
200-
201-
logger.info('Equipment take off ended')
202-
203-
def fleet_equipment_take_off(self, enter, long_click, out):
204-
"""
205-
Args:
206-
enter (Button): Button to edit equipment.
207-
long_click (bool): How to click enter
208-
out (Button): Button to confirm exit success.
209-
"""
210-
logger.hr('Equipment take off')
211-
self.ship_info_enter(enter, long_click=long_click)
212-
213-
while True:
214-
self.ship_equipment_take_off()
215-
self.ui_click(EQUIPMENT_CLOSE, check_button=EQUIPMENT_OPEN, skip_first_screenshot=True)
216-
if not self.ship_view_next():
217-
break
218-
219-
self.ui_back(out)
220-
self.equipment_has_take_on = False
221-
222-
def ship_equipment_take_on_preset(self, index, skip_first_screenshot=True):
223-
logger.info('Equipment take on preset')
224-
bar_timer = Timer(5)
225-
on_timer = Timer(5)
226-
227-
while 1:
228-
if skip_first_screenshot:
229-
skip_first_screenshot = False
230-
else:
231-
self.device.screenshot()
232-
233-
# End
234-
# if self.handle_info_bar():
235-
# break
236-
if on_timer.started() and self.info_bar_count():
237-
break
238-
239-
if bar_timer.reached() and not self.appear(EQUIP_1, offset=10):
240-
self.device.click(EQUIPMENT_OPEN)
241-
# self.device.sleep(0.3)
242-
bar_timer.reset()
243-
continue
244-
245-
if on_timer.reached() and self.appear(EQUIP_1, offset=10) and not self.info_bar_count():
246-
if index == 1:
247-
self.device.click(EQUIP_1)
248-
elif index == 2:
249-
self.device.click(EQUIP_2)
250-
elif index == 3:
251-
self.device.click(EQUIP_3)
252-
253-
on_timer.reset()
254-
bar_timer.reset()
255-
continue
256-
257-
logger.info('Equipment take on ended')
258-
259-
def fleet_equipment_take_on_preset(self, preset_record, enter, long_click, out):
260-
"""
261-
Args:
262-
preset_record (list[int]): list of equipment record. [3, 1, 1, 1, 1, 1]
263-
enter (Button): Button to edit equipment.
264-
long_click (bool): How to click enter
265-
out (Button): Button to confirm exit success.
266-
"""
267-
logger.hr('Equipment take on')
268-
self.ship_info_enter(enter, long_click=long_click)
269-
270-
for index in '9'.join([str(x) for x in preset_record if x > 0]):
271-
index = int(index)
272-
if index == 9:
273-
self.ship_view_next()
274-
else:
275-
self.ship_equipment_take_on_preset(index=index)
276-
self.ui_click(EQUIPMENT_CLOSE, check_button=EQUIPMENT_OPEN, skip_first_screenshot=True)
277-
278-
self.ui_back(out)
279-
self.equipment_has_take_on = True
162+
def ship_equipment_take_off(self, name=None):
163+
self.code_clear(name=name)
164+
165+
def ship_equipment_take_on(self, name=None):
166+
self.code_apply(name=name)
167+
168+
# def ship_equipment_take_off(self, skip_first_screenshot=True):
169+
# logger.info('Equipment take off')
170+
# bar_timer = Timer(5)
171+
# off_timer = Timer(5)
172+
# confirm_timer = Timer(5)
173+
174+
# while 1:
175+
# if skip_first_screenshot:
176+
# skip_first_screenshot = False
177+
# else:
178+
# self.device.screenshot()
179+
180+
# # End
181+
# # if self.handle_info_bar():
182+
# # break
183+
# if off_timer.started() and self.info_bar_count():
184+
# break
185+
186+
# if self.handle_storage_full():
187+
# continue
188+
189+
# if confirm_timer.reached() and self.handle_popup_confirm('EQUIPMENT_TAKE_OFF'):
190+
# confirm_timer.reset()
191+
# off_timer.reset()
192+
# bar_timer.reset()
193+
# continue
194+
195+
# if off_timer.reached():
196+
# if not self.info_bar_count() and self.appear_then_click(EQUIP_OFF, offset=(20, 20)):
197+
# off_timer.reset()
198+
# bar_timer.reset()
199+
# continue
200+
201+
# if bar_timer.reached():
202+
# if self.appear(EQUIPMENT_OPEN, offset=(20, 20)) and not self.appear(EQUIP_OFF, offset=(20, 20)):
203+
# self.device.click(EQUIPMENT_OPEN)
204+
# bar_timer.reset()
205+
# continue
206+
207+
# logger.info('Equipment take off ended')
208+
209+
# def fleet_equipment_take_off(self, enter, long_click, out):
210+
# """
211+
# Args:
212+
# enter (Button): Button to edit equipment.
213+
# long_click (bool): How to click enter
214+
# out (Button): Button to confirm exit success.
215+
# """
216+
# logger.hr('Equipment take off')
217+
# self.ship_info_enter(enter, long_click=long_click)
218+
219+
# while True:
220+
# self.ship_equipment_take_off()
221+
# self.ui_click(EQUIPMENT_CLOSE, check_button=EQUIPMENT_OPEN, skip_first_screenshot=True)
222+
# if not self.ship_view_next():
223+
# break
224+
225+
# self.ui_back(out)
226+
# self.equipment_has_take_on = False
227+
228+
# def ship_equipment_take_on_preset(self, index, skip_first_screenshot=True):
229+
# logger.info('Equipment take on preset')
230+
# bar_timer = Timer(5)
231+
# on_timer = Timer(5)
232+
233+
# while 1:
234+
# if skip_first_screenshot:
235+
# skip_first_screenshot = False
236+
# else:
237+
# self.device.screenshot()
238+
239+
# # End
240+
# # if self.handle_info_bar():
241+
# # break
242+
# if on_timer.started() and self.info_bar_count():
243+
# break
244+
245+
# if bar_timer.reached() and not self.appear(EQUIP_1, offset=10):
246+
# self.device.click(EQUIPMENT_OPEN)
247+
# # self.device.sleep(0.3)
248+
# bar_timer.reset()
249+
# continue
250+
251+
# if on_timer.reached() and self.appear(EQUIP_1, offset=10) and not self.info_bar_count():
252+
# if index == 1:
253+
# self.device.click(EQUIP_1)
254+
# elif index == 2:
255+
# self.device.click(EQUIP_2)
256+
# elif index == 3:
257+
# self.device.click(EQUIP_3)
258+
259+
# on_timer.reset()
260+
# bar_timer.reset()
261+
# continue
262+
263+
# logger.info('Equipment take on ended')
264+
265+
# def fleet_equipment_take_on_preset(self, preset_record, enter, long_click, out):
266+
# """
267+
# Args:
268+
# preset_record (list[int]): list of equipment record. [3, 1, 1, 1, 1, 1]
269+
# enter (Button): Button to edit equipment.
270+
# long_click (bool): How to click enter
271+
# out (Button): Button to confirm exit success.
272+
# """
273+
# logger.hr('Equipment take on')
274+
# self.ship_info_enter(enter, long_click=long_click)
275+
276+
# for index in '9'.join([str(x) for x in preset_record if x > 0]):
277+
# index = int(index)
278+
# if index == 9:
279+
# self.ship_view_next()
280+
# else:
281+
# self.ship_equipment_take_on_preset(index=index)
282+
# self.ui_click(EQUIPMENT_CLOSE, check_button=EQUIPMENT_OPEN, skip_first_screenshot=True)
283+
284+
# self.ui_back(out)
285+
# self.equipment_has_take_on = True

0 commit comments

Comments
 (0)