| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- # This Python file uses the following encoding: utf-8
- # @author runhey
- # github https://github.com/runhey
- import re
- import time
- from module.logger import logger
- from tasks.GameUi.page import page_main, page_guild, page_mall
- from tasks.GameUi.game_ui import GameUi
- from tasks.Component.Buy.buy import Buy
- from tasks.RichMan.assets import RichManAssets
- class MallNavbar(GameUi, RichManAssets):
- def _enter_consignment(self):
- """
- 进入寄售屋
- :return:
- """
- self.ui_click(self.I_MALL_CONSIGNMENT, self.I_MALL_CONSIGNMENT_CHECK)
- def _enter_scales(self):
- """
- 进入密卷屋 蛇皮
- :return:
- """
- self.ui_click(self.I_MALL_SCCALES, self.I_MALL_SCCALES_CHECK)
- def _enter_bondlings(self):
- """
- 进入契灵
- :return:
- """
- self._enter_scales()
- self.ui_click(self.I_MALL_BONDLINGS_SURE, self.I_MALL_BONDLINGS_ON)
- def _enter_sundry(self):
- """
- 进入杂货铺
- :return:
- """
- self.ui_click(self.I_MALL_SUNDRY, self.I_MALL_SUNDRY_CHECK)
- def _enter_special(self):
- """
- 进入特殊
- :return:
- """
- self._enter_sundry()
- self.ui_click(self.I_SIDE_SURE_SPECIAL, self.I_SIDE_CHECK_SPECIAL)
- def _enter_honor(self):
- """
- 进入荣誉 屋
- :return:
- """
- self._enter_sundry()
- self.ui_click(self.I_SIDE_SUER_HONOR, self.I_SIDE_CHECK_HONOR)
- def _enter_friendship(self):
- """
- 友情点
- :return:
- """
- self._enter_sundry()
- self.ui_click(self.I_SIDE_SURE_FRIENDS, self.I_SIDE_CHECK_FRIENDS)
- def _enter_medal(self):
- """
- 勋章
- :return:
- """
- self._enter_sundry()
- self.ui_click(self.I_SIDE_SURE_MEDAL, self.I_SIDE_CHECK_MEDAL, interval=3, timeout=15)
- def _enter_charisma(self):
- """
- 魅力
- :return:
- """
- self._enter_sundry()
- self.ui_click(self.I_SIDE_SURE_CHARISMA, self.I_SIDE_CHECK_CHARISMA)
- def back_mall(self):
- """
- 返回商城
- :return:
- """
- self.goto_page(page_mall, skip_first_screenshot=False, timeout=6)
- def mall_resource(self, index: int) -> int:
- """
- 获取商城资源,
- :param index: 从左开始数
- :return:
- """
- match = {
- 1: self.O_MALL_RESOURCE_1,
- 2: self.O_MALL_RESOURCE_2,
- 3: self.O_MALL_RESOURCE_3,
- 4: self.O_MALL_RESOURCE_4,
- 5: self.O_MALL_RESOURCE_5,
- 6: self.O_MALL_RESOURCE_6,
- 7: self.O_MALL_RESOURCE_7,
- }
- self.screenshot()
- result = match[index].ocr(self.device.image)
- # match = re.search(r'\d+', result)
- # result = int(match.group())
- if not isinstance(result, int):
- logger.warning(f'Get mall resource {index} error, result: {result}')
- if result == 0:
- logger.warning(f'Get mall resource {index} error, result: {result}')
- return result
- def mall_check_money(self, index: int, least: int) -> bool:
- return self.mall_resource(index) >= least
-
- #add legacy check money method for compatibility, for consignment task
- def mall_check_money_legacy(self, index: int, least: int) -> bool:
- """
- Legacy implementation.
- 旧版商城资源判断逻辑(包含资源获取 + 校验)用于插画屋和寄售屋任务
- :param index: 从左开始数 1-4 对应第1-4个资源 least 最少多少
- :return: bool
- """
- match = {
- 1: self.O_LEGACY_MALL_RESOURCE_1,
- 2: self.O_LEGACY_MALL_RESOURCE_2,
- 3: self.O_LEGACY_MALL_RESOURCE_3,
- 4: self.O_LEGACY_MALL_RESOURCE_4,
- }
- self.screenshot()
- result = match[index].ocr(self.device.image)
- if not isinstance(result, int):
- logger.warning(f'Get mall resource {index} error, result: {result}')
- return False
- if result == 0:
- logger.warning(f'Get mall resource {index} error, result: {result}')
- return False
- return result >= least
- if __name__ == '__main__':
- from module.config.config import Config
- from module.device.device import Device
- c = Config('oas1')
- d = Device(c)
- t = MallNavbar(c, d)
|