|
@@ -22,9 +22,36 @@ class Honor(Special):
|
|
|
logger.info('Honor is not enable')
|
|
logger.info('Honor is not enable')
|
|
|
return
|
|
return
|
|
|
self._enter_honor()
|
|
self._enter_honor()
|
|
|
- self._honor_mystery_amulet(con.mystery_amulet)
|
|
|
|
|
- self._honor_black_daruma_scrap(con.black_daruma_scrap)
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ # 向下滑找到购买的物品
|
|
|
|
|
+ mystery_bought, black_bought = False, False
|
|
|
|
|
+ max_swipes = 3
|
|
|
|
|
+ swipe_count = 0
|
|
|
|
|
+
|
|
|
|
|
+ while 1:
|
|
|
|
|
+ self.screenshot()
|
|
|
|
|
+ if not mystery_bought and con.mystery_amulet and self.appear(self.I_HONOR_BLUE):
|
|
|
|
|
+ self._honor_mystery_amulet(con.mystery_amulet)
|
|
|
|
|
+ mystery_bought = True
|
|
|
|
|
+ if not black_bought and con.black_daruma_scrap and self.appear(self.I_HONOR_BLACK):
|
|
|
|
|
+ self._honor_black_daruma_scrap(con.black_daruma_scrap)
|
|
|
|
|
+ black_bought = True
|
|
|
|
|
+
|
|
|
|
|
+ # 如果所有需要购买的物品都已购买完成
|
|
|
|
|
+ if (not con.mystery_amulet or mystery_bought) and (not con.black_daruma_scrap or black_bought):
|
|
|
|
|
+ logger.info('All honor items processed')
|
|
|
|
|
+ break
|
|
|
|
|
+ # 如果滑动次数过多,避免无限循环
|
|
|
|
|
+ if swipe_count >= max_swipes:
|
|
|
|
|
+ break
|
|
|
|
|
+ # 如果滑动到底了
|
|
|
|
|
+ if self.appear(self.I_SP_SWIPE_CHECK):
|
|
|
|
|
+ break
|
|
|
|
|
+
|
|
|
|
|
+ # 向下滑动寻找商品
|
|
|
|
|
+ if self.swipe(self.S_SP_DOWN, interval=2):
|
|
|
|
|
+ swipe_count += 1
|
|
|
|
|
+ time.sleep(2)
|
|
|
|
|
|
|
|
def _honor_mystery_amulet(self, enable: bool=False):
|
|
def _honor_mystery_amulet(self, enable: bool=False):
|
|
|
logger.hr('Buy mystery amulet', 3)
|
|
logger.hr('Buy mystery amulet', 3)
|
|
@@ -32,12 +59,7 @@ class Honor(Special):
|
|
|
logger.info('Buy mystery amulet is disabled')
|
|
logger.info('Buy mystery amulet is disabled')
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
- self.screenshot()
|
|
|
|
|
- if not self.appear(self.I_HONOR_BLUE):
|
|
|
|
|
- logger.warning('No appear mystery amulet')
|
|
|
|
|
- return
|
|
|
|
|
# 检查剩余数量
|
|
# 检查剩余数量
|
|
|
- # remain_number = self.O_HONOR_BLUE.ocr(self.device.image)
|
|
|
|
|
remain_number = self._special_check_remain(self.I_HONOR_BLUE)
|
|
remain_number = self._special_check_remain(self.I_HONOR_BLUE)
|
|
|
if not isinstance(remain_number, int):
|
|
if not isinstance(remain_number, int):
|
|
|
logger.warning('Can not get remain number')
|
|
logger.warning('Can not get remain number')
|
|
@@ -48,8 +70,8 @@ class Honor(Special):
|
|
|
if not self.mall_check_money(4, 1500):
|
|
if not self.mall_check_money(4, 1500):
|
|
|
logger.warning('No enough money')
|
|
logger.warning('No enough money')
|
|
|
return
|
|
return
|
|
|
- # 点击购买
|
|
|
|
|
- self.buy_more(self.I_HONOR_BLUE)
|
|
|
|
|
|
|
+ # 使用动态位置点击购买
|
|
|
|
|
+ self.appear_then_click(self.I_HONOR_BLUE)
|
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
def _honor_black_daruma_scrap(self, enable: bool=False):
|
|
def _honor_black_daruma_scrap(self, enable: bool=False):
|
|
@@ -58,12 +80,7 @@ class Honor(Special):
|
|
|
logger.info('Buy black daruma scrap is disabled')
|
|
logger.info('Buy black daruma scrap is disabled')
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
- self.screenshot()
|
|
|
|
|
- if not self.appear(self.I_HONOR_BLACK):
|
|
|
|
|
- logger.warning('No appear black daruma scrap')
|
|
|
|
|
- return
|
|
|
|
|
# 检查剩余数量
|
|
# 检查剩余数量
|
|
|
- # remain_number = self.O_HONOR_BLACK.ocr(self.device.image)
|
|
|
|
|
remain_number = self._special_check_remain(self.I_HONOR_BLACK)
|
|
remain_number = self._special_check_remain(self.I_HONOR_BLACK)
|
|
|
if not isinstance(remain_number, int):
|
|
if not isinstance(remain_number, int):
|
|
|
logger.warning('Can not get remain number')
|
|
logger.warning('Can not get remain number')
|
|
@@ -74,14 +91,11 @@ class Honor(Special):
|
|
|
if not self.mall_check_money(4, 540):
|
|
if not self.mall_check_money(4, 540):
|
|
|
logger.warning('No enough money')
|
|
logger.warning('No enough money')
|
|
|
return
|
|
return
|
|
|
- # 点击购买
|
|
|
|
|
|
|
+ # 使用动态位置点击购买
|
|
|
self.buy_more(self.I_HONOR_BLACK)
|
|
self.buy_more(self.I_HONOR_BLACK)
|
|
|
time.sleep(0.5)
|
|
time.sleep(0.5)
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
from module.config.config import Config
|
|
from module.config.config import Config
|
|
|
from module.device.device import Device
|
|
from module.device.device import Device
|
|
@@ -92,6 +106,3 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
t.execute_honor()
|
|
t.execute_honor()
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|