Просмотр исходного кода

feat(task): Goldyoukai has finished

runhey 3 лет назад
Родитель
Сommit
75a93524d9

+ 1 - 0
module/config/i18n/zh_CN.ts

@@ -638,5 +638,6 @@ Refresh:直接刷新,如果刷新操作进入CD,将标记为失败并退
 	<message><source>PetsConfig</source><translation>宠物</translation></message>
 	<message><source>Pets Happy</source><translation>其乐融融</translation></message>
 	<message><source>Pets Feast</source><translation>饕餮大餐</translation></message>
+	<message><source>GoldYoukaiConfig</source><translation>金币妖怪</translation></message>
 </context>	
 </TS>

+ 8 - 0
tasks/Component/GeneralRoom/assets.py

@@ -44,5 +44,13 @@ class GeneralRoomAssets:
 	I_GR_AUTO_MATCH = RuleImage(roi_front=(697,598,181,63), roi_back=(697,598,181,63), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralRoom/gr/gr_gr_auto_match.png")
 	# 刷新 
 	I_GR_REFRESH = RuleImage(roi_front=(417,595,176,65), roi_back=(417,595,176,65), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralRoom/gr/gr_gr_refresh.png")
+	# description 
+	I_ENSURE_PUBLIC = RuleImage(roi_front=(400,282,35,37), roi_back=(400,282,35,37), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralRoom/gr/gr_ensure_public.png")
+	# description 
+	I_ENSURE_PUBLIC_FALSE = RuleImage(roi_front=(399,285,37,35), roi_back=(399,285,37,35), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralRoom/gr/gr_ensure_public_false.png")
+	# description 
+	I_ENSURE_PUBLIC_2 = RuleImage(roi_front=(307,490,37,40), roi_back=(307,490,37,40), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralRoom/gr/gr_ensure_public_2.png")
+	# description 
+	I_ENSURE_PUBLIC_FALSE_2 = RuleImage(roi_front=(307,491,38,37), roi_back=(307,491,38,37), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralRoom/gr/gr_ensure_public_false_2.png")
 
 

+ 25 - 2
tasks/Component/GeneralRoom/general_room.py

@@ -27,9 +27,15 @@ class GeneralRoom(BaseTask, GeneralRoomAssets):
         if not self.appear(self.I_CREATE_ROOM):
             logger.warning('No create room button')
             return False
+        click_number = 0
         while 1:
             self.screenshot()
+            if click_number > 3:
+                logger.warning('Create room button do not take effect')
+                logger.warning('The most possible reason is that there are not challenge tickets')
+                return False
             if self.appear_then_click(self.I_CREATE_ROOM, interval=2):
+                click_number += 1
                 continue
             if self.appear(self.I_CREATE_ENSURE):
                 return True
@@ -48,9 +54,26 @@ class GeneralRoom(BaseTask, GeneralRoomAssets):
                 return True
             if self.appear(self.I_ENSURE_PRIVATE_2):
                 return True
-            if self.appear_then_click(self.I_ENSURE_PRIVATE_FALSE):
+            if self.appear_then_click(self.I_ENSURE_PRIVATE_FALSE, interval=1):
                 continue
-            if self.appear_then_click(self.I_ENSURE_PRIVATE_FALSE_2):
+            if self.appear_then_click(self.I_ENSURE_PRIVATE_FALSE_2, interval=1):
+                continue
+
+    def ensure_public(self) -> bool:
+        """
+        确认公开房间, 允许任何人加入
+        :return:
+        """
+        logger.info('Ensure public')
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_ENSURE_PUBLIC):
+                return True
+            if self.appear(self.I_ENSURE_PUBLIC_2):
+                return True
+            if self.appear_then_click(self.I_ENSURE_PUBLIC_FALSE, interval=1):
+                continue
+            if self.appear_then_click(self.I_ENSURE_PUBLIC_FALSE_2, interval=1):
                 continue
 
     def create_ensure(self) -> bool:

BIN
tasks/Component/GeneralRoom/gr/gr_ensure_public.png


BIN
tasks/Component/GeneralRoom/gr/gr_ensure_public_2.png


BIN
tasks/Component/GeneralRoom/gr/gr_ensure_public_false.png


BIN
tasks/Component/GeneralRoom/gr/gr_ensure_public_false_2.png


+ 36 - 0
tasks/Component/GeneralRoom/gr/image.json

@@ -97,5 +97,41 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "刷新"
+  },
+  {
+    "itemName": "ensure_public",
+    "imageName": "gr_ensure_public.png",
+    "roiFront": "400,282,35,37",
+    "roiBack": "400,282,35,37",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "ensure_public_false",
+    "imageName": "gr_ensure_public_false.png",
+    "roiFront": "399,285,37,35",
+    "roiBack": "399,285,37,35",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "ensure_public_2",
+    "imageName": "gr_ensure_public_2.png",
+    "roiFront": "307,490,37,40",
+    "roiBack": "307,490,37,40",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "ensure_public_false_2",
+    "imageName": "gr_ensure_public_false_2.png",
+    "roiFront": "307,491,38,37",
+    "roiBack": "307,491,38,37",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
   }
 ]

+ 8 - 1
tasks/GoldYoukai/config.py

@@ -5,7 +5,14 @@ from pydantic import BaseModel, Field
 
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_base import ConfigBase
+from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
 
+class GoldYoukaiConfig(ConfigBase):
+    buff_gold_50_click: bool = Field(default=False)
+    buff_gold_100_click: bool = Field(default=False)
 
 class GoldYoukai(ConfigBase):
-    scheduler: Scheduler = Field(default_factory=Scheduler)
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    gold_youkai: GoldYoukaiConfig = Field(default_factory=GoldYoukaiConfig)
+    switch_soul: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
+

+ 110 - 0
tasks/GoldYoukai/script_task.py

@@ -0,0 +1,110 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from cached_property import cached_property
+
+from module.exception import TaskEnd
+from module.logger import logger
+from module.base.timer import Timer
+
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_main, page_team, page_shikigami_records
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.GeneralRoom.general_room import GeneralRoom
+from tasks.Component.GeneralInvite.general_invite import GeneralInvite
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
+from tasks.GoldYoukai.assets import GoldYoukaiAssets
+from tasks.GoldYoukai.config import GoldYoukaiConfig
+
+
+class ScriptTask(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, SwitchSoul, GoldYoukaiAssets):
+
+    def run(self):
+        # 切换御魂
+        if self.config.gold_youkai.switch_soul.enable:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul(self.config.gold_youkai.switch_soul.switch_group_team)
+        # 开启加成
+        con = self.config.gold_youkai.gold_youkai
+        if con.buff_gold_50_click or con.buff_gold_100_click:
+            self.ui_get_current_page()
+            self.ui_goto(page_main)
+            self.open_buff()
+            if con.buff_gold_50_click:
+                self.gold_50()
+            if con.buff_gold_100_click:
+                self.gold_100()
+            self.close_buff()
+        self.ui_get_current_page()
+        self.ui_goto(page_team)
+        self.check_zones('金币妖怪')
+        # 开始
+        if not self.create_room():
+            self.gold_exit(con)
+        self.ensure_public()
+        self.create_ensure()
+        # 进入到了房间里面
+        wait_timer = Timer(60)
+        wait_timer.start()
+        while 1:
+            self.screenshot()
+
+            if not self.is_in_room():
+                continue
+            if wait_timer.reached():
+                logger.warning('Wait for too long, exit')
+                self.exit_room()
+                break
+            if not self.appear(self.I_ADD_5_1):
+                # 有人进来了,可以进行挑战
+                logger.info('There is someone in the room and start the challenge')
+                self.click_fire()
+                self.run_general_battle()
+                break
+        # 退出 (要么是在组队界面要么是在庭院)
+        self.gold_exit(con)
+
+
+    def battle_wait(self, random_click_swipt_enable: bool) -> bool:
+        # 重写
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        self.device.click_record_clear()
+        # 战斗过程 随机点击和滑动 防封
+        logger.info("Start battle process")
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_DE_WIN):
+                logger.info('Win battle')
+                self.ui_click_until_disappear(self.I_DE_WIN)
+                return True
+
+            if self.appear(self.I_FALSE):
+                logger.warning('False battle')
+                self.ui_click_until_disappear(self.I_FALSE)
+                return False
+
+    def gold_exit(self, con):
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+        if con.buff_gold_50_click or con.buff_gold_100_click:
+            self.open_buff()
+            if con.buff_gold_50_click:
+                self.gold_50(False)
+            if con.buff_gold_100_click:
+                self.gold_100(False)
+            self.close_buff()
+
+        self.set_next_run(task='GoldYoukai', success=True, finish=False)
+        raise TaskEnd('GoldYoukai')
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+    c = Config('oas1')
+    d = Device(c)
+    t = ScriptTask(c, d)
+    t.screenshot()
+
+    t.run()