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

Merge remote-tracking branch 'origin/dev' into dev

huangrunheng 2 лет назад
Родитель
Сommit
c80fc060ca

+ 6 - 0
tasks/GameUi/assets.py

@@ -117,6 +117,12 @@ class GameUiAssets:
 	I_BACK_YOLLOW = RuleImage(roi_front=(24,16,48,55), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_back_yollow.png")
 	# description 
 	I_DEMON_ENCOUNTER_GOTO_TOWN = RuleImage(roi_front=(28,20,56,52), roi_back=(3,4,100,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_demon_encounter_goto_town.png")
+	# description 
+	I_TOWN_GOTO_HYAKKIYAKOU = RuleImage(roi_front=(880,165,53,69), roi_back=(827,149,148,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_town_goto_hyakkiyakou.png")
+	# description 
+	I_CHECK_KYAKKIYAKOU = RuleImage(roi_front=(305,567,56,64), roi_back=(280,545,100,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_kyakkiyakou.png")
+	# description 
+	I_HYAKKIYAKOU_CLOSE = RuleImage(roi_front=(1063,181,47,43), roi_back=(1063,181,47,43), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_hyakkiyakou_close.png")
 
 
 	# Image Rule Assets

+ 4 - 0
tasks/GameUi/page.py

@@ -116,6 +116,10 @@ page_town.link(button=G.I_TOWN_GOTO_DRAFT_DUEL, destination=page_draft_duel)
 page_hyakkisen = Page(G.I_CHECK_HYAKKISEN)
 page_hyakkisen.link(button=G.I_BACK_YOLLOW, destination=page_town)
 page_town.link(button=G.I_TOWN_GOTO_HYAKKISEN, destination=page_hyakkisen)
+# 百鬼夜行
+page_hyakkiyakou = Page(G.I_CHECK_KYAKKIYAKOU)
+page_hyakkiyakou.link(button=G.I_HYAKKIYAKOU_CLOSE, destination=page_town)
+page_town.link(button=G.I_TOWN_GOTO_HYAKKIYAKOU, destination=page_hyakkiyakou)
 
 
 # ************************************* 庭院部分 *****************************************#

BIN
tasks/GameUi/page/page_check_kyakkiyakou.png


BIN
tasks/GameUi/page/page_hyakkiyakou_close.png


+ 27 - 0
tasks/GameUi/page/page_img_2.json

@@ -133,5 +133,32 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
+  },
+  {
+    "itemName": "town_goto_hyakkiyakou",
+    "imageName": "page_town_goto_hyakkiyakou.png",
+    "roiFront": "880,165,53,69",
+    "roiBack": "827,149,148,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "check_kyakkiyakou",
+    "imageName": "page_check_kyakkiyakou.png",
+    "roiFront": "305,567,56,64",
+    "roiBack": "280,545,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "hyakkiyakou_close",
+    "imageName": "page_hyakkiyakou_close.png",
+    "roiFront": "1063,181,47,43",
+    "roiBack": "1063,181,47,43",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
   }
 ]

BIN
tasks/GameUi/page/page_town_goto_hyakkiyakou.png


+ 22 - 0
tasks/Hyakkiyakou/assets.py

@@ -10,6 +10,28 @@ from module.atom.list import RuleList
 class HyakkiyakouAssets: 
 
 
+	# Click Rule Assets
+	# description 
+	C_HSELECT_1 = RuleClick(roi_front=(158,209,225,405), roi_back=(158,209,225,405), name="hselect_1")
+	# description 
+	C_HSELECT_2 = RuleClick(roi_front=(531,225,202,363), roi_back=(531,225,202,363), name="hselect_2")
+	# description 
+	C_HSELECT_3 = RuleClick(roi_front=(875,210,219,394), roi_back=(875,210,219,394), name="hselect_3")
+
+
+	# Image Rule Assets
+	# 邀请按钮 
+	I_HINVITE = RuleImage(roi_front=(139,569,63,60), roi_back=(139,569,63,60), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_hinvite.png")
+	# 进入 
+	I_HACCESS = RuleImage(roi_front=(1059,554,100,100), roi_back=(1059,554,100,100), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_haccess.png")
+	# 开始 
+	I_HSTART = RuleImage(roi_front=(1119,555,100,100), roi_back=(1119,555,100,100), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_hstart.png")
+	# 押注 
+	I_HSELECTED = RuleImage(roi_front=(980,265,41,44), roi_back=(226,53,836,348), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_hselected.png")
+	# 结束 
+	I_HEND = RuleImage(roi_front=(81,164,86,299), roi_back=(81,164,86,299), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_hend.png")
+
+
 	# Click Rule Assets
 	# description 
 	C_CLICK = RuleClick(roi_front=(26,250,33,100), roi_back=(26,250,33,100), name="click")

+ 20 - 0
tasks/Hyakkiyakou/hya/click.json

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "hselect_1",
+    "roiFront": "158,209,225,405",
+    "roiBack": "158,209,225,405",
+    "description": "description"
+  },
+  {
+    "itemName": "hselect_2",
+    "roiFront": "531,225,202,363",
+    "roiBack": "531,225,202,363",
+    "description": "description"
+  },
+  {
+    "itemName": "hselect_3",
+    "roiFront": "875,210,219,394",
+    "roiBack": "875,210,219,394",
+    "description": "description"
+  }
+]

BIN
tasks/Hyakkiyakou/hya/hya_haccess.png


BIN
tasks/Hyakkiyakou/hya/hya_hend.png


BIN
tasks/Hyakkiyakou/hya/hya_hinvite.png


BIN
tasks/Hyakkiyakou/hya/hya_hselected.png


BIN
tasks/Hyakkiyakou/hya/hya_hstart.png


+ 47 - 0
tasks/Hyakkiyakou/hya/image1.json

@@ -0,0 +1,47 @@
+[
+  {
+    "itemName": "hinvite",
+    "imageName": "hya_hinvite.png",
+    "roiFront": "139,569,63,60",
+    "roiBack": "139,569,63,60",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "邀请按钮"
+  },
+  {
+    "itemName": "haccess",
+    "imageName": "hya_haccess.png",
+    "roiFront": "1059,554,100,100",
+    "roiBack": "1059,554,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "进入"
+  },
+  {
+    "itemName": "hstart",
+    "imageName": "hya_hstart.png",
+    "roiFront": "1119,555,100,100",
+    "roiBack": "1119,555,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "开始"
+  },
+  {
+    "itemName": "hselected",
+    "imageName": "hya_hselected.png",
+    "roiFront": "980,265,41,44",
+    "roiBack": "226,53,836,348",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "押注"
+  },
+  {
+    "itemName": "hend",
+    "imageName": "hya_hend.png",
+    "roiFront": "81,164,86,299",
+    "roiBack": "81,164,86,299",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "结束"
+  }
+]

+ 86 - 0
tasks/Hyakkiyakou/prepare/get_images.py

@@ -0,0 +1,86 @@
+import cv2
+import time
+from datetime import timedelta, datetime
+from cached_property import cached_property
+from random import choice
+from pathlib import Path
+
+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_hyakkiyakou
+from tasks.Hyakkiyakou.assets import HyakkiyakouAssets
+
+
+class GenerateImages(GameUi, HyakkiyakouAssets):
+    @cached_property
+    def save_folder(self) -> Path:
+        save_time = datetime.now().strftime('%Y%m%dT%H%M%S')
+        save_folder = Path(f'./tasks/Hyakkiyakou/temp/{save_time}')
+        save_folder.mkdir(parents=True, exist_ok=True)
+        return save_folder
+
+    def run(self):
+        self.ui_get_current_page()
+        self.ui_goto(page_hyakkiyakou)
+        for i in range(1):
+            self.save_one()
+
+    def save_one(self):
+        """
+        生成一次票的截图
+        @return:
+        """
+        if not self.appear(self.I_HACCESS):
+            logger.warning('Page Error')
+        self.ui_click(self.I_HACCESS, self.I_HSTART, interval=2)
+        # 随机选一个
+        click_button = choice([self.C_HSELECT_1, self.C_HSELECT_2, self.C_HSELECT_3])
+        while 1:
+            self.screenshot()
+
+            if self.appear(self.I_CHECK_RUN):
+                break
+            if self.appear_then_click(self.I_HSTART, interval=2):
+                continue
+            if not self.appear(self.I_HSELECTED):
+                self.click(click_button, interval=1)
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        # 保存图片
+        save_img_timer = Timer(0.1)
+        save_img_timer.start()
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_HEND):
+                logger.info('Generate a time Images Success')
+                break
+            if save_img_timer.reached():
+                save_img_timer.reset()
+                self.save_image()
+        self.ui_click(self.I_HEND, self.I_HACCESS)
+
+    def save_image(self, image=None):
+        if image is None:
+            image = self.device.image
+        img1 = image[80:, :640]
+        img2 = image[80:, 640:]
+        # 时间戳毫秒级别
+        time_now1 = int(time.time() * 1000)
+        time_now2 = time_now1 + 1
+        cv2.imwrite(str(self.save_folder / f'{time_now1}.png'), img1)
+        cv2.imwrite(str(self.save_folder / f'{time_now2}.png'), img2)
+
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+    c = Config('oas1')
+    d = Device(c)
+    t = GenerateImages(c, d)
+    t.screenshot()
+
+    t.run()
+
+