Переглянути джерело

Merge pull request #281 from roarhill/dev

fix(Emergency): Add accept both jade and food option
huangrunheng 2 роки тому
батько
коміт
c14b2aa8da

+ 4 - 1
tasks/GlobalGame/assets.py

@@ -9,7 +9,6 @@ from module.atom.list import RuleList
 # Don't modify it manually.
 # Don't modify it manually.
 class GlobalGameAssets: 
 class GlobalGameAssets: 
 
 
-
 	# Image Rule Assets
 	# Image Rule Assets
 	# 接受 
 	# 接受 
 	I_G_ACCEPT = RuleImage(roi_front=(830,407,56,46), roi_back=(798,369,117,110), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/gg/gg_g_accept.png")
 	I_G_ACCEPT = RuleImage(roi_front=(830,407,56,46), roi_back=(798,369,117,110), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/gg/gg_g_accept.png")
@@ -17,6 +16,10 @@ class GlobalGameAssets:
 	I_G_REJECT = RuleImage(roi_front=(832,508,53,51), roi_back=(808,480,108,101), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/gg/gg_g_reject.png")
 	I_G_REJECT = RuleImage(roi_front=(832,508,53,51), roi_back=(808,480,108,101), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/gg/gg_g_reject.png")
 	# 勾玉 
 	# 勾玉 
 	I_G_JADE = RuleImage(roi_front=(661,466,43,46), roi_back=(661,466,43,46), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/gg/gg_g_jade.png")
 	I_G_JADE = RuleImage(roi_front=(661,466,43,46), roi_back=(661,466,43,46), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/gg/gg_g_jade.png")
+	# 猫粮
+	I_G_CAT_FOOD = RuleImage(roi_front=(565,463,59,65), roi_back=(565,463,59,65), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/gg/gg_g_cat_food.png")
+	# 狗粮
+	I_G_DOG_FOOD = RuleImage(roi_front=(565,464,60,63), roi_back=(565,464,60,63), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/gg/gg_g_dog_food.png")
 	# 忽略 
 	# 忽略 
 	I_G_IGNORE = RuleImage(roi_front=(773,116,21,21), roi_back=(759,102,48,48), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/gg/gg_g_ignore.png")
 	I_G_IGNORE = RuleImage(roi_front=(773,116,21,21), roi_back=(759,102,48,48), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/gg/gg_g_ignore.png")
 	# 网络异常 
 	# 网络异常 

+ 4 - 3
tasks/GlobalGame/config_emergency.py

@@ -5,11 +5,14 @@ from datetime import datetime, time
 from enum import Enum
 from enum import Enum
 from pydantic import BaseModel, ValidationError, validator, Field
 from pydantic import BaseModel, ValidationError, validator, Field
 
 
-
 class FriendInvitation(str, Enum):
 class FriendInvitation(str, Enum):
+    '''
+    协作
+    '''
     ACCEPT = 'accept'
     ACCEPT = 'accept'
     REJECT = 'reject'
     REJECT = 'reject'
     ONLY_JADE = 'only_jade'  # 仅接受勾玉邀请
     ONLY_JADE = 'only_jade'  # 仅接受勾玉邀请
+    JADE_AND_FOOD = 'jade_and_food' # 勾协+粮协
     IGNORE = 'ignore'
     IGNORE = 'ignore'
 
 
 class WhenNetworkAbnormal(str, Enum):
 class WhenNetworkAbnormal(str, Enum):
@@ -19,8 +22,6 @@ class WhenNetworkAbnormal(str, Enum):
 class WhenNetworkError(str, Enum):
 class WhenNetworkError(str, Enum):
     RESTART = 'restart'
     RESTART = 'restart'
 
 
-
-
 # 也可以是左边的邀请什么的
 # 也可以是左边的邀请什么的
 class Emergency(BaseModel):
 class Emergency(BaseModel):
     friend_invitation: FriendInvitation = Field(default=FriendInvitation.ACCEPT,description='friend_invitation_help')
     friend_invitation: FriendInvitation = Field(default=FriendInvitation.ACCEPT,description='friend_invitation_help')

BIN
tasks/GlobalGame/gg/gg_g_cat_food.png


BIN
tasks/GlobalGame/gg/gg_g_dog_food.png


+ 18 - 0
tasks/GlobalGame/gg/image.json

@@ -26,6 +26,24 @@
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "勾玉"
     "description": "勾玉"
   },
   },
+  {
+    "itemName": "g_cat_food",
+    "imageName": "gg_g_cat_food.png",
+    "roiFront": "565,463,59,65",
+    "roiBack": "565,463,59,65",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "猫粮"
+  },
+  {
+    "itemName": "g_dog_food",
+    "imageName": "gg_g_dog_food.png",
+    "roiFront": "565,464,60,63",
+    "roiBack": "565,464,60,63",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "狗粮"
+  },
   {
   {
     "itemName": "g_ignore",
     "itemName": "g_ignore",
     "imageName": "gg_g_ignore.png",
     "imageName": "gg_g_ignore.png",

+ 12 - 0
tasks/base_task.py

@@ -101,6 +101,18 @@ class BaseTask(GlobalGameAssets, CostumeBase):
                         continue
                         continue
                     if not self.appear(self.I_G_ACCEPT):
                     if not self.appear(self.I_G_ACCEPT):
                         break
                         break
+            # 如果是接受勾协和粮协
+            elif invite and self.config.global_game.emergency.friend_invitation == FriendInvitation.JADE_AND_FOOD:
+                logger.info(f"Accept jade and food invitation")
+                while 1:
+                    self.device.screenshot()
+                    if self.appear(self.I_G_JADE) or self.appear(self.I_G_CAT_FOOD) or self.appear(self.I_G_DOG_FOOD):
+                        if self.appear_then_click(self.I_G_ACCEPT, interval=1):
+                            continue
+                    elif self.appear_then_click(self.I_G_IGNORE, interval=1):
+                        continue
+                    if not self.appear(self.I_G_ACCEPT):
+                        break
             # 如果是全部忽略
             # 如果是全部忽略
             elif invite and self.config.global_game.emergency.friend_invitation == FriendInvitation.IGNORE:
             elif invite and self.config.global_game.emergency.friend_invitation == FriendInvitation.IGNORE:
                 logger.info(f"Ignore friend invitation")
                 logger.info(f"Ignore friend invitation")