liujx54704 1 год назад
Родитель
Сommit
eb01da91e8

+ 4 - 2
tasks/BondlingFairyland/assets.py

@@ -39,7 +39,7 @@ class BondlingFairylandAssets:
 
 
 	# Image Rule Assets
-	# description 
+	# 挑战 
 	I_BALL_FIRE = RuleImage(roi_front=(1140,575,100,100), roi_back=(1140,575,100,100), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/ball_ball_fire.png")
 	# description 
 	I_BALL_UNLOCK = RuleImage(roi_front=(714,637,31,33), roi_back=(714,637,31,33), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/ball_ball_unlock.png")
@@ -49,6 +49,8 @@ class BondlingFairylandAssets:
 	I_BALL_RECORDS = RuleImage(roi_front=(856,566,38,39), roi_back=(856,566,38,39), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/ball_ball_records.png")
 	# 求援 
 	I_BALL_HELP = RuleImage(roi_front=(963,571,100,100), roi_back=(963,571,100,100), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/ball_ball_help.png")
+	# 契灵创建队伍 
+	I_CREATE_TEAM = RuleImage(roi_front=(569,491,141,50), roi_back=(569,491,141,50), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/ball/create_team.png")
 
 
 	# Image Rule Assets
@@ -112,7 +114,7 @@ class BondlingFairylandAssets:
 	I_C_FIRST_DISABLE = RuleImage(roi_front=(713,469,38,34), roi_back=(713,469,38,34), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/capture_c_first_disable.png")
 	# description 
 	I_CAPTION_ENSURE = RuleImage(roi_front=(690,532,129,56), roi_back=(690,532,129,56), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/capture_caption_ensure.png")
-	# description 
+	# 结契设置 
 	I_CLICK_CAPTION = RuleImage(roi_front=(177,625,59,51), roi_back=(177,625,59,51), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/capture_click_caption.png")
 
 

BIN
tasks/BondlingFairyland/ball/create_team.png


+ 11 - 2
tasks/BondlingFairyland/ball/image.json

@@ -6,7 +6,7 @@
     "roiBack": "1140,575,100,100",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "description"
+    "description": "挑战"
   },
   {
     "itemName": "ball_unlock",
@@ -43,5 +43,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "求援"
-  }
+  },
+    {
+    "itemName": "create_team",
+    "imageName": "create_team.png",
+    "roiFront": "569,491,141,50",
+    "roiBack": "569,491,141,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "契灵创建队伍"
+    }
 ]

BIN
tasks/BondlingFairyland/ball/room_team.png


+ 2 - 2
tasks/BondlingFairyland/battle.py

@@ -14,13 +14,13 @@ from module.logger import logger
 
 class BondlingBattle(GeneralBattle, BondlingFairylandAssets):
 
-    def run_battle(self, battle_config: BattleConfig) -> bool:
+    def run_battle(self, battle_config: BattleConfig, limit_count: int = None) -> bool:
         """
         :return: 如果结契成功返回True,否则返回False
         """
         logger.hr("General battle start", 2)
         self.current_count += 1
-        logger.info(f"Current count: {self.current_count}")
+        logger.info(f"Current count: {self.current_count} / " + str(limit_count))
 
         if self.check_load():
             # 首先要判断进入战斗的界面

+ 1 - 1
tasks/BondlingFairyland/capture/image.json

@@ -105,6 +105,6 @@
     "roiBack": "177,625,59,51",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "description"
+    "description": "结契设置"
   }
 ]

+ 12 - 1
tasks/BondlingFairyland/config.py

@@ -9,6 +9,8 @@ from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_base import ConfigBase, DateTime, TimeDelta, Time
 from tasks.BondlingFairyland.config_battle import BattleConfig
+from tasks.Component.GeneralInvite.config_invite import InviteConfig
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
 
 class BondlingMode(str, Enum):
     MODE1 = 'mode_1'
@@ -28,8 +30,14 @@ class BondlingClass(str, Enum):
 # 低级契灵盘 Low Bondling Discs
 # 中级契灵盘 Medium Bondling Discs
 # 高级契灵盘 High Bondling Discs
-
+class UserStatus(str, Enum):
+    LEADER = 'leader'
+    MEMBER = 'member'
+    ALONE = 'alone'
+    # WILD = 'wild'  # 还不打算实现
 class BondlingConfig(ConfigBase):
+    # 身份
+    user_status: UserStatus = Field(default=UserStatus.ALONE, description='user_status_help')
     bondling_mode: BondlingMode = Field(default=BondlingMode.MODE1, description='bondling_mode_help')
     limit_time: Time = Field(default=Time(minute=30), description='limit_time_help')
     limit_count: int = Field(default=30, description='limit_count_help')
@@ -51,7 +59,10 @@ class BondlingFairyland(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     bondling_config: BondlingConfig = Field(default_factory=BondlingConfig)
     bondling_switch_soul: BondlingSwitchSoul = Field(default_factory=BondlingSwitchSoul)
+    invite_config: InviteConfig = Field(default_factory=InviteConfig)
     battle_config: BattleConfig = Field(default_factory=BattleConfig)
+    # battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
+
     switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
 
 

+ 648 - 0
tasks/BondlingFairyland/general_invite.py

@@ -0,0 +1,648 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from time import sleep
+import numpy as np
+
+from enum import Enum
+from cached_property import cached_property
+from datetime import timedelta, time
+
+from module.base.timer import Timer
+from tasks.base_task import BaseTask
+from tasks.Component.GeneralInvite.assets import GeneralInviteAssets
+from tasks.Component.GeneralInvite.config_invite import InviteConfig, InviteNumber, FindMode
+from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
+from module.logger import logger
+
+
+class FriendList(str, Enum):
+    RECENT_FRIEND = 'recent_friend'
+    GUILD_FRIEND = 'guild_friend'
+    FRIEND = 'friend'
+    OTHER_FRIEND = 'other_friend'
+
+
+class RoomType(str, Enum):
+    # 房间只可以两个人的: 探索
+    NORMAL_2 = 'normal_2'
+    # 房间可以两三个人的: 觉醒、御魂、日轮、石距(石距是单次没有锁定阵容)
+    NORMAL_3 = 'normal_3'
+    # 永生之海不一样
+    ETERNITY_SEA = 'eternity_sea'
+    # 经验妖怪和金币妖怪
+    NORMAL_5 = 'normal_5'
+
+
+class GeneralInvite(BaseTask, GeneralInviteAssets):
+    timer_invite = None
+    timer_wait = None
+    timer_emoji = None  # 等待期间如果没有操作的话,可能会导致长时间无响应报错
+
+    """
+
+    """
+
+    def run_invite(self, config: InviteConfig, is_first: bool = False) -> bool:
+        """
+        队长!!身份。。。在组队界面邀请好友( 如果开启is_first) 等待队员进入开启挑战
+        请注意,返回的时候成功时是进入战斗了!!!
+        如果是失败,那就是没有队友进入,然后会退出房间的界面
+        :param config:
+        :param is_first: 如果是第一次开房间的那就要邀请队员,其他情况等待队员进入
+        :return:
+        """
+        logger.hr('Invite friend', 2)
+        if not self.ensure_enter():
+            logger.warning('Not enter invite page')
+            return False
+        if is_first:
+            _ = self.room_type
+            self.timer_invite = Timer(20)
+            self.timer_invite.start()
+            self.ensure_room_type(config.invite_number)
+            self.invite_friends(config)
+        else:
+            self.timer_invite = Timer(30)
+            self.timer_invite.start()
+            self.timer_emoji = Timer(20)
+            self.timer_emoji.start()
+        wait_second = config.wait_time.second + config.wait_time.minute * 60
+        self.timer_wait = Timer(wait_second)
+        self.timer_wait.start()
+        while 1:
+            self.screenshot()
+            if self.timer_wait.reached():
+                logger.warning('Wait timeout')
+                return False
+            if self.appear(self.I_MATCHING):
+                logger.warning('Timeout, now is no room')
+                return False
+
+            if not self.is_in_room():
+                continue
+
+            if self.timer_emoji and self.timer_emoji.reached():
+                self.timer_emoji.reset()
+                self.appear_then_click(self.I_GI_EMOJI_1)
+                self.appear_then_click(self.I_GI_EMOJI_2)
+
+            fire = False  # 是否开启挑战
+            # 如果这个房间最多只容纳两个人(意思是只可以邀请一个人),且已经邀请一个人了,那就开启挑战
+            if self.room_type == RoomType.NORMAL_2 and not self.appear(self.I_ADD_1):
+                logger.info('Start challenge and this room can only invite one friend')
+                fire = True
+            # 如果这个房间最多容纳三个人(意思是可以邀请两个人),且设定邀请一个就开启挑战,那就开启挑战
+            elif self.room_type == RoomType.NORMAL_3 and config.invite_number == InviteNumber.ONE and not self.appear(self.I_ADD_1):
+                logger.info('Start challenge and user only invite one friend')
+                fire = True
+            # 如果这个房间最多容纳三个人(意思是可以邀请两个人),且设定邀请两个就开启挑战,那就开启挑战
+            elif self.room_type == RoomType.NORMAL_3 \
+                    and config.invite_number == InviteNumber.TWO and not self.appear(self.I_ADD_2):
+                logger.info('Start challenge and user invite two friends')
+                fire = True
+            # 如果这个房间是五人的,且设定邀请一个就开启挑战,那就开启挑战
+            elif self.room_type == RoomType.NORMAL_5 \
+                    and config.invite_number == InviteNumber.ONE and not self.appear(self.I_ADD_5_1):
+                logger.info('Start challenge and user only invite one friend')
+                fire = True
+            # 如果这个房间是五人的,且设定邀请两个就开启挑战,那就开启挑战
+            elif self.room_type == RoomType.NORMAL_5 \
+                    and config.invite_number == InviteNumber.TWO and not self.appear(self.I_ADD_5_2):
+                logger.info('Start challenge and user invite two friends')
+                fire = True
+            # 如果是永生之海
+            elif self.room_type == RoomType.ETERNITY_SEA and not self.appear(self.I_ADD_SEA):
+                logger.info('Start challenge and this is lock sea')
+                fire = True
+
+            # 点击挑战
+            if fire:
+                self.click_fire()
+                return True
+
+            if self.timer_invite and self.timer_invite.reached():
+                if is_first:
+                    logger.info('Invitation is triggered every 20s')
+                    self.timer_invite.reset()
+                else:
+                    logger.info('Wait for 30s and invite again')
+                    self.timer_invite = None
+                self.invite_friends(config)
+
+    def ensure_enter(self) -> bool:
+        """
+        确认是否进入了组队界面
+        :return:
+        """
+        logger.info('Ensure enter invite page')
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_ADD_2):
+                return True
+            if self.appear(self.I_ADD_5_4):
+                return True
+            if self.appear(self.I_LOCK_SEA):
+                return True
+            if self.appear(self.I_UNLOCK_SEA):
+                return True
+            # 修复三人组队卡住bug,#78
+            # 增加左上角协战房间判断,存在就说明在组队界面
+            if self.appear(self.I_GI_IN_ROOM):
+                return True
+            if self.appear(self.I_MATCHING):
+                return False
+
+    # 判断是否在房间里面
+    def is_in_room(self, is_screenshot: bool = True) -> bool:
+        """
+        判断是否在房间里面
+        :return:
+        """
+        if is_screenshot:
+            self.screenshot()
+        if self.appear(self.I_GI_EMOJI_1):
+            return True
+        if self.appear(self.I_GI_EMOJI_2):
+            return True
+        # if self.appear(self.I_MATCHING):
+        #     return False
+        return False
+
+    def exit_room(self) -> bool:
+        """
+        退出房间
+        :return:
+        """
+        if not self.is_in_room():
+            return False
+        logger.info('Exit room')
+        while 1:
+            self.screenshot()
+            if not self.is_in_room() and \
+                    not self.appear_then_click(self.I_GI_SURE, interval=0.8) and \
+                    not self.appear(self.I_BACK_YELLOW):
+                break
+            if self.appear_then_click(self.I_GI_SURE, interval=0.5):
+                continue
+            if not self.appear(self.I_GI_SURE) and self.appear_then_click(self.I_BACK_YELLOW, interval=0.8):
+                self.wait_until_appear(self.I_GI_SURE, wait_time=0.8)
+                continue
+        return True
+
+    def click_fire(self):
+        while 1:
+            self.screenshot()
+            if not self.is_in_room(False):
+                break
+            if self.appear_then_click(self.I_FIRE, interval=1, threshold=0.7):
+                continue
+
+    @cached_property
+    def room_type(self) -> RoomType:
+        """
+        只需要在队长进入的时候判断一次就可以了,任务后面之间使用
+
+        :return:
+        """
+        self.screenshot()
+        room_type = self.check_room_type(image=self.device.image)
+        logger.info(f'Room type: {room_type}')
+        return room_type
+
+    def check_room_type(self, image: np.array = None, pre_type: RoomType = None) -> RoomType:
+        """
+        检查房间类型
+        :param image:
+        :param pre_type: 可以先指定这个类型,如果不指定,就自动检查
+        :return:
+        """
+
+        def check_3(img) -> bool:
+            appear = False
+            if self.I_ADD_1.match(img) and self.I_ADD_2.match(img):
+                appear = True
+            return appear
+
+        def check_2(img) -> bool:
+            appear = False
+            if self.I_ADD_1.match(img) and not self.I_ADD_2.match(img):
+                appear = True
+            return appear
+
+        def check_5(img) -> bool:
+            appear = False
+            if self.I_ADD_5_1.match(img) and self.I_ADD_5_2.match(img) \
+                    and self.I_ADD_5_3.match(img) and self.I_ADD_5_4.match(img):
+                appear = True
+            return appear
+
+        def check_eternity_sea(img) -> bool:
+            appear = False
+            if self.I_LOCK_SEA.match(img) or self.I_UNLOCK_SEA.match(img):
+                appear = True
+            return appear
+
+        room_type = None
+        if pre_type is not None:
+            match pre_type:
+                case RoomType.NORMAL_2:
+                    room_type = RoomType.NORMAL_2 if check_2(image) else None
+                case RoomType.NORMAL_3:
+                    room_type = RoomType.NORMAL_3 if check_3(image) else None
+                case RoomType.NORMAL_5:
+                    room_type = RoomType.NORMAL_5 if check_5(image) else None
+                case RoomType.ETERNITY_SEA:
+                    room_type = RoomType.ETERNITY_SEA if check_eternity_sea(image) else None
+        if room_type:
+            return room_type
+        if room_type is None and check_2(image):
+            room_type = RoomType.NORMAL_2
+            return room_type
+        if room_type is None and check_3(image):
+            room_type = RoomType.NORMAL_3
+            return room_type
+        if room_type is None and check_5(image):
+            room_type = RoomType.NORMAL_5
+            return room_type
+        if room_type is None and check_eternity_sea(image):
+            room_type = RoomType.ETERNITY_SEA
+            return room_type
+        return room_type
+
+    def ensure_room_type(self, friend_number: int = None) -> bool:
+        """
+        确认设定的邀请人数是否会超出房间的最大
+        :param friend_number: 这个输入的是用户选项中的invite_number
+        :return:  如果超出了,就返回False
+        """
+        if isinstance(friend_number, InviteNumber):
+            if friend_number == InviteNumber.ONE:
+                friend_number = 1
+            elif friend_number == InviteNumber.TWO:
+                friend_number = 2
+
+        if friend_number == 2:
+            if self.room_type == RoomType.NORMAL_2:
+                # 整个房间就可以两个人,还邀请两个 这个是报错的
+                logger.error('Room can only be one people, but invite two people')
+                return False
+            elif self.room_type == RoomType.ETERNITY_SEA:
+                # 永生之海,只能邀请一个人
+                logger.error('Room can only be one people, but invite two people')
+                return False
+            return True
+        return True
+
+    @cached_property
+    def friend_class(self) -> list[str]:
+        return ['好友', '最近', '跨区', '寮友', '蔡友', '路区', '察友', '区']
+
+    def detect_select(self, name: str = None) -> bool:
+        """
+        在当前的页面检测是否有好友, 如果有就选中这个好友
+        :return:
+        """
+        if not name:
+            return False
+
+        self.screenshot()
+        self.O_FRIEND_NAME_1.keyword = name
+        self.O_FRIEND_NAME_2.keyword = name
+        appear_1 = self.ocr_appear_click(self.O_FRIEND_NAME_1, interval=2)
+        appear_2 = self.ocr_appear_click(self.O_FRIEND_NAME_2, interval=2)
+        if not appear_1 and not appear_2:
+            logger.info('Current page no friend')
+            return False
+
+        while appear_1 or appear_2:
+            self.screenshot()
+            if self.appear(self.I_SELECTED):
+                break
+            appear_1 = self.ocr_appear_click(self.O_FRIEND_NAME_1, interval=2)
+            appear_2 = self.ocr_appear_click(self.O_FRIEND_NAME_2, interval=2)
+
+        return True
+
+    def invite_friend(self, name: str = None, find_mode: FindMode = FindMode.AUTO_FIND) -> bool:
+        """
+        邀请好友
+        :param find_mode: 寻找的方式
+        :param name:
+        :return:
+        """
+        logger.info('Click add to invite friend')
+        # 点击+号
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_LOAD_FRIEND):
+                break
+            if self.appear(self.I_INVITE_ENSURE):
+                break
+            if self.appear_then_click(self.I_ADD_2, interval=1):
+                continue
+            if self.appear_then_click(self.I_ADD_1, interval=1):
+                continue
+            if self.appear_then_click(self.I_ADD_5_4, interval=1):
+                continue
+
+        friend_class = []
+        class_ocr = [self.O_F_LIST_1, self.O_F_LIST_2, self.O_F_LIST_3, self.O_F_LIST_4]
+        class_index = 0
+        list_1 = self.O_F_LIST_1.ocr(self.device.image)
+        list_2 = self.O_F_LIST_2.ocr(self.device.image)
+        list_3 = self.O_F_LIST_3.ocr(self.device.image)
+        list_4 = self.O_F_LIST_4.ocr(self.device.image)
+        list_1 = list_1.replace(' ', '').replace('、', '')
+        list_2 = list_2.replace(' ', '').replace('、', '')
+        list_3 = list_3.replace(' ', '').replace('、', '')
+        if list_1 is not None and list_1 != '' and list_1 in self.friend_class:
+            friend_class.append(list_1)
+        if list_2 is not None and list_2 != '' and list_2 in self.friend_class:
+            friend_class.append(list_2)
+        if list_3 is not None and list_3 != '' and list_3 in self.friend_class:
+            friend_class.append(list_3)
+        if list_4 is not None and list_4 != '' and list_4 in self.friend_class:
+            friend_class.append(list_4)
+        for i in range(len(friend_class)):
+            if friend_class[i] == '蔡友':
+                friend_class[i] = '寮友'
+            elif friend_class[i] == '路区':
+                friend_class[i] = '跨区'
+            elif friend_class[i] == '察友':
+                friend_class[i] = '寮友'
+            elif friend_class[i] == '区':
+                friend_class[i] = '跨区'
+        logger.info(f'Friend class: {friend_class}')
+
+        is_select: bool = False  # 是否选中了好友
+        if find_mode == FindMode.RECENT_FRIEND:
+            logger.info('Find recent friend')
+            # 获取’最近‘在friend_class中的index
+            if '最近' not in friend_class:
+                logger.warning('No recent friend')
+                return False
+            recent_index = friend_class.index('最近')
+            while recent_index == 1:
+                self.screenshot()
+                if self.appear(self.I_FLAG_2_ON):
+                    break
+                if self.appear_then_click(self.I_FLAG_2_OFF, interval=1):
+                    continue
+
+            logger.info(f'Now find friend in ”最近“')
+            sleep(1)
+            if not is_select:
+                if self.detect_select(name):
+                    is_select = True
+            sleep(1)
+            if not is_select:
+                if self.detect_select(name):
+                    is_select = True
+
+        for index in range(len(friend_class)):
+            # 如果不是自动寻找,就跳过
+            if find_mode != FindMode.AUTO_FIND:
+                continue
+            # 如果已经选中了好友,就不需要再选中了
+            if is_select:
+                continue
+            # 首先切换到不同的好友列表
+            while index == 0:
+                self.screenshot()
+                if self.appear(self.I_FLAG_1_ON):
+                    break
+                if self.appear_then_click(self.I_FLAG_1_OFF, interval=1):
+                    continue
+            while index == 1:
+                self.screenshot()
+                if self.appear(self.I_FLAG_2_ON):
+                    break
+                if self.appear_then_click(self.I_FLAG_2_OFF, interval=1):
+                    continue
+            while index == 2:
+                self.screenshot()
+                if self.appear(self.I_FLAG_3_ON):
+                    break
+                if self.appear_then_click(self.I_FLAG_3_OFF, interval=1):
+                    continue
+            while index == 3:
+                self.screenshot()
+                if self.appear(self.I_FLAG_4_ON):
+                    break
+                if self.appear_then_click(self.I_FLAG_4_OFF, interval=1):
+                    continue
+
+            # 选中好友, 在这里游戏获取在线的好友并不是很快,根据不同的设备会有不同的时间,而且没有什么元素提供我们来判断
+            # 所以这里就直接等待一段时间
+            logger.info(f'Now find friend in {friend_class[index]}')
+            sleep(1)
+            if not is_select:
+                if self.detect_select(name):
+                    is_select = True
+            sleep(1)
+            if not is_select:
+                if self.detect_select(name):
+                    is_select = True
+
+        # 点击确定
+        logger.info('Click invite ensure')
+        if not self.appear(self.I_INVITE_ENSURE):
+            logger.warning('No appear invite ensure while invite friend')
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_INVITE_ENSURE):
+                break
+            if self.appear_then_click(self.I_INVITE_ENSURE):
+                continue
+        # 哪怕没有找到好友也有点击 确认 以退出好友列表
+        if not is_select:
+            logger.warning('No find friend')
+            # 这个时候任务运行失败
+            logger.info('Task failed')
+            return False
+
+        return True
+
+    def invite_friends(self, config: InviteConfig) -> bool:
+        """
+        看情况邀请两个好友
+        :return:
+        """
+        success = self.invite_friend(config.friend_1, config.find_mode)
+        if not success:
+            logger.warning('Invite friend 1 failed')
+        # 如果是邀请第二个人
+        if config.invite_number == InviteNumber.TWO:
+            success = self.invite_friend(config.friend_2, config.find_mode)
+            if not success:
+                logger.warning('Invite friend 2 failed')
+        sleep(0.5)
+
+    def invite_again(self, default_invite: bool=True) -> bool:
+        """
+        作为队长战斗胜利后再次邀请队友,
+        :param default_invite:  是否勾选默认
+        :return:
+        """
+        logger.info('Invite again')
+        # 判断是否进入界面
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_GI_SURE):
+                break
+        # 如果勾选了默认邀请
+        if default_invite:
+            logger.info('Click default invite')
+            while 1:
+                self.screenshot()
+                if self.appear(self.I_I_DEFAULT):
+                    break
+                if self.appear_then_click(self.I_I_NO_DEFAULT, interval=1):
+                    continue
+        else:
+            logger.info('Click no default invite')
+            while 1:
+                self.screenshot()
+                if self.appear(self.I_I_NO_DEFAULT):
+                    break
+                if self.appear_then_click(self.I_I_DEFAULT, interval=1):
+                    continue
+
+        # 点击确认
+        logger.info('Click invite ensure')
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_GI_SURE):
+                break
+            if self.appear_then_click(self.I_GI_SURE):
+                continue
+
+    def check_and_invite(self, default_invite: bool=True) -> bool:
+        """
+        队长战斗后 邀请队友
+        :param default_invite:
+        :return:
+        """
+        if not self.appear(self.I_GI_SURE):
+            return False
+
+        if default_invite:
+            # 有可能是挑战失败的
+            if self.appear(self.I_I_DEFAULT) or self.appear(self.I_I_NO_DEFAULT):
+                logger.info('Click default invite')
+                while 1:
+                    self.screenshot()
+                    if self.appear(self.I_I_DEFAULT):
+                        break
+                    if self.appear_then_click(self.I_I_NO_DEFAULT, interval=1):
+                        continue
+        # 点击确认
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_GI_SURE):
+                break
+            if self.appear_then_click(self.I_GI_SURE, interval=1):
+                continue
+
+        return True
+
+    def check_then_accept(self) -> bool:
+        """
+        队员接受邀请
+        :return:
+        """
+        if not self.appear(self.I_I_ACCEPT):
+            return False
+        logger.info('Click accept')
+        while 1:
+            self.screenshot()
+            if self.is_in_room():
+                return True
+            # 被秒开
+            # https://github.com/runhey/OnmyojiAutoScript/issues/230
+            if self.appear(GeneralBattleAssets.I_EXIT):
+                return False
+            if self.appear_then_click(self.I_I_NO_DEFAULT, interval=1):
+                continue
+            if self.appear_then_click(self.I_GI_SURE, interval=1):
+                continue
+            if self.appear_then_click(self.I_I_ACCEPT_DEFAULT, interval=1):
+                continue
+            if self.appear_then_click(self.I_I_ACCEPT, interval=1):
+                continue
+        return True
+
+    def wait_battle(self, wait_time: time) -> bool:
+        """
+        在房间等待,(要求保证在房间里面) 队长开启战斗
+        如果队长跑路了,或者的等待了很久还没开始
+        :return: 如果成功进入战斗(反正就是不在房间 )返回 True
+                 如果失败了,(退出房间)返回 False
+        """
+        self.timer_emoji = Timer(15)
+        self.timer_emoji.start()
+        wait_second = wait_time.second + wait_time.minute * 60
+        self.timer_wait = Timer(wait_second)
+        self.timer_wait.start()
+        logger.info(f'Wait battle {wait_second} seconds')
+        success = True
+        while 1:
+            self.screenshot()
+
+            # 如果自己在探索界面或者是庭院,那就是房间已经被销毁了
+            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE):
+                logger.warning('Room destroyed')
+                success = False
+                break
+
+
+            if self.timer_wait.reached():
+                logger.warning('Wait battle time out')
+                success = False
+                break
+
+            # 如果队长跑路了,自己变成了队长: 自己也要跑路
+            if self.appear(self.I_FIRE) or self.appear(self.I_FIRE_SEA):
+                logger.warning('Leader run away while wait battle and become leader now')
+                success = False
+                break
+
+            # 判断是否进入战斗
+            if self.is_in_room(is_screenshot=False):
+                if self.timer_emoji.reached():
+                    self.timer_emoji.reset()
+                    self.appear_then_click(self.I_GI_EMOJI_1)
+                    self.appear_then_click(self.I_GI_EMOJI_2)
+            else:
+                break
+
+
+        # 调出循环只有这些可能性:
+        # 1. 进入战斗(ui是战斗)
+        # 2. 队长跑路(自己还是在房间里面)
+        # 3. 等待时间到没有开始(还是在房间里面)
+        # 4. 房间的时间到了被迫提出房间(这个时候来到了探索界面)
+        if not success:
+            logger.info('Leave room')
+            self.exit_room()
+
+        return success
+
+
+
+
+if __name__ == '__main__':
+    from module.config.config import Config
+    from module.device.device import Device
+    import cv2
+
+    c = Config('oas1')
+    d = Device(c)
+    t = GeneralInvite(c, d)
+
+    # t.run_invite(c.orochi.invite_config, is_first=True)
+    t.screenshot()
+    print(t.appear(t.I_FIRE, threshold=0.8))
+
+

+ 346 - 22
tasks/BondlingFairyland/script_task.py

@@ -2,16 +2,20 @@
 # @author runhey
 # github https://github.com/runhey
 
+from tasks.Component.GeneralRoom.general_room import GeneralRoom
+
 import numpy as np
 from time import sleep
 from cached_property import cached_property
 from datetime import datetime, timedelta
+from tasks.BondlingFairyland.general_invite import GeneralInvite
+from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
 
 from tasks.base_task import BaseTask
 from tasks.GameUi.game_ui import GameUi
 from tasks.BondlingFairyland.config import (BondlingFairyland, BondlingMode,
                                             BondlingClass,
-                                            BondlingSwitchSoul, BondlingConfig)
+                                            BondlingSwitchSoul, BondlingConfig, UserStatus)
 from tasks.BondlingFairyland.assets import BondlingFairylandAssets
 from tasks.BondlingFairyland.battle import BondlingBattle
 from tasks.BondlingFairyland.config_battle import BattleConfig
@@ -22,16 +26,16 @@ from tasks.GameUi.page import page_main, page_bondling_fairyland, page_shikigami
 from module.atom.image import RuleImage
 from module.logger import logger
 from module.exception import TaskEnd
-
+from tasks.Component.GeneralRoom.assets import GeneralRoomAssets
+from module.base.timer import Timer
+from datetime import timedelta, time
 
 
 class BondlingNumberMax(Exception):
     pass
 
 
-
-class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
-
+class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
     ball_pos_list = [None, None, None, None, None]  # 用于记录每一个位置的球是否出现
     first_catch = True  # 用于记录是否是第一次捕捉
 
@@ -44,7 +48,7 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             self.ui_get_current_page()
             self.ui_goto(page_shikigami_records)
             self.run_switch_soul(cong.switch_soul_config.switch_group_team)
-          # 御魂切换方式二
+        # 御魂切换方式二
         if cong.switch_soul_config.enable_switch_by_name:
             self.ui_get_current_page()
             self.ui_goto(page_shikigami_records)
@@ -53,6 +57,100 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
         self.ui_get_current_page()
         self.ui_goto(page_bondling_fairyland)
 
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_CHECK_BONDLING_FAIRYLAND, interval=1):
+                break
+            if self.appear(self.I_BALL_HELP, interval=1):
+                self.ui_get_current_page()
+                self.ui_goto(page_bondling_fairyland)
+                continue
+
+        limit_count = cong.bondling_config.limit_count
+        self.current_count = 0
+        self.limit_count: int = limit_count
+
+        match cong.bondling_config.user_status:
+            case UserStatus.LEADER:
+                self.switch_ball()
+            case UserStatus.MEMBER:
+                self.run_member()
+            case UserStatus.ALONE:
+                self.switch_ball()
+            case _:
+                logger.error('Unknown user status')
+
+    def run_member(self):
+        logger.info('Start run member')
+        self.ui_get_current_page()
+        # 开始等待队长拉人
+        wait_time = self.config.bondling_fairyland.invite_config.wait_time
+        wait_timer = Timer(wait_time.minute * 60)
+        wait_timer.start()
+        success = True
+
+        # 进入战斗流程
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+
+        while 1:
+
+            self.screenshot()
+
+            # 等待超时
+            logger.info("开始等待队长拉人:" + str(wait_timer.current()))
+            if wait_timer.reached():
+                logger.warning('wait_timer timeout')
+                break
+
+            # if self.current_count >= self.limit_count:
+            #     logger.info('Orochi count limit out')
+            #     break
+            if datetime.now() - self.start_time >= self.limit_time:
+                logger.info('Orochi time limit out')
+                break
+
+            if self.check_then_accept():
+                continue
+
+            if self.is_in_room():
+                logger.info("契灵:进入组队房间!")
+                if self.wait_battle(wait_time=self.config.bondling_fairyland.invite_config.wait_time):
+                    self.run_battle(self.config.bondling_fairyland.battle_config, limit_count=self.limit_count)
+                    wait_timer.reset()
+                    # 进入战斗流程
+                    self.device.stuck_record_add('BATTLE_STATUS_S')
+                else:
+                    break
+            # 队长秒开的时候,检测是否进入到战斗中
+            elif self.check_take_over_battle(False, config=self.config.bondling_fairyland.battle_config):
+                wait_timer.reset()
+                # 进入战斗流程
+                self.device.stuck_record_add('BATTLE_STATUS_S')
+                continue
+
+        while 1:
+            # 有一种情况是本来要退出的,但是队长邀请了进入的战斗的加载界面
+            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_CHECK_BONDLING_FAIRYLAND):
+                break
+            # 如果可能在房间就退出
+            if self.exit_room():
+                pass
+            # 如果还在战斗中,就退出战斗
+            if self.exit_battle():
+                pass
+
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+
+        if success:
+            self.set_next_run(task='BondlingFairyland', finish=True, success=True)
+        else:
+            self.set_next_run(task='BondlingFairyland', finish=True, success=False)
+        raise TaskEnd
+
+    def switch_ball(self):
+        cong = self.config.bondling_fairyland
+
         bondling_config = cong.bondling_config
         bondling_switch_soul = cong.bondling_switch_soul
         battle_config = cong.battle_config
@@ -88,6 +186,7 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
                     continue
 
                 try:
+                    # 执行捕捉
                     if self.run_catch(bondling_config, bondling_switch_soul, battle_config):
                         current_ball -= 1
                         logger.info(f'Catch successful and current ball number: {current_ball} ')
@@ -120,7 +219,6 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             self.set_next_run(task='BondlingFairyland', finish=True, success=False)
         raise TaskEnd
 
-
     def run_stone(self, bondling_stone_enable: bool, bondling_stone_class: BondlingClass):
         """
         使用结契石 进行召唤 契灵
@@ -171,8 +269,6 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
                             continue
                     break
 
-
-
                 if self.appear_then_click(self.I_STONE_ENTER, interval=1):
                     click_count += 1
                     continue
@@ -217,7 +313,6 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
         (4) 捕获成功,返回True (退出页面是捕获的页面)
         """
 
-
         self.lock_team()
         if self.first_catch:
             self.first_catch = False
@@ -234,6 +329,7 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
                 logger.warning(f'No plate number, exit')
                 return False
             return True
+
         if not check_plate_number(target_plate):
             return False
 
@@ -247,7 +343,7 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
                 case BondlingClass.TOMB_GUARD: group_team = bondling_switch_soul.tomb_guard_switch
             group_team = switch_parser(group_team)
             if group_team == [-1, -1]:
-                logger.info(f'{bondling_class.name } switch soul is not set, skip')
+                logger.info(f'{bondling_class.name} switch soul is not set, skip')
                 return False
             self.enter_shikigami_records()
             self.run_switch_soul(tuple(group_team))
@@ -260,8 +356,8 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             first_switch_soul = False
             switch_soul(bondling_class)
 
-
         # 开始执行循环
+        success =True
         while 1:
             self.screenshot()
 
@@ -281,13 +377,29 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             if datetime.now() - self.start_time >= self.limit_time:
                 logger.warning(f'No time, exit')
                 return False
-            # ok 就进行挑战
-            self.click_fire()
-            if self.run_battle(battle_config):
-                return True
-
-
 
+            # 引用配置
+            cong = self.config.bondling_fairyland
+            match cong.bondling_config.user_status:
+                case UserStatus.LEADER:
+                    if self.run_leader():
+                        return success
+                case UserStatus.ALONE:
+                    self.run_alone()
+                    if self.run_battle(battle_config, limit_count=self.limit_count):
+                        return success
+                case _:
+                    logger.error('Unknown user status')
+
+
+    def is_room_dead(self) -> bool:
+        # 如果在探索界面或者是出现在组队界面,那就是可能房间死了
+        sleep(0.5)
+        if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+            sleep(0.5)
+            if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+                return True
+        return False
 
     @cached_property
     def balls_target(self) -> list[RuleImage]:
@@ -389,7 +501,6 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             if self.click(click_target, interval=1):
                 click_count += 1
 
-
     def capture_setting(self, mode: BondlingMode) -> None:
         """
         第一次进入任务的时候触发这一项方法:为了确保用户的选择默认是正确的
@@ -499,9 +610,9 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
         limit_time = self.config.bondling_fairyland.bondling_config.limit_time
         return timedelta(hours=limit_time.hour, minutes=limit_time.minute, seconds=limit_time.second)
 
-    def click_fire(self):
+    def run_alone(self):
         """
-        点击 挑战, 主要是结契时的挑战
+        单人 挑战, 主要是结契时的挑战
         """
         click_count = 0
         while 1:
@@ -519,6 +630,180 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
             if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
                 continue
 
+    def run_leader(self):
+
+        """
+        点击 求援, 组队模式
+        """
+        click_count = 0
+        # target = None
+        # appear1 = self.I_CREATE_ENSURE.match(self.device.image)
+        while 1:
+            self.screenshot()
+            if click_count >= 6:
+                logger.error('Click fire failed')
+                logger.error('You might need to check your bondling number. It most possibly arrived to the max 500')
+                raise BondlingNumberMax
+            if self.appear(self.I_CREATE_TEAM):
+                break
+            # 某些活动的时候出现 “选择共鸣的阴阳师”
+            if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                continue
+            # 盘子满了继续
+            if self.check_and_invite(True):
+                continue
+            # 求援
+            if self.appear_then_click(self.I_BALL_HELP, interval=1):
+                click_count += 1
+                continue
+
+        while 1:
+            self.screenshot()
+            if self.ensure_private():
+                break
+        while 1:
+            self.screenshot()
+
+            if self.appear(self.I_GI_IN_ROOM):
+                break
+            if self.appear_then_click(self.I_CREATE_TEAM, interval=1):
+                continue
+
+        # 邀请队友
+        success = True
+        is_first = True
+        # 这个时候我已经进入房间了哦
+        while 1:
+            self.screenshot()
+
+            # 无论胜利与否, 都会出现是否邀请一次队友
+            # 区别在于,失败的话不会出现那个勾选默认邀请的框
+            self.check_and_invite(True)
+
+            if self.current_count >= self.limit_count:
+                if self.appear(self.I_GI_IN_ROOM):
+                    logger.info('bondling_fairyland count limit out')
+                    break
+
+            if datetime.now() - self.start_time >= self.limit_time:
+                if self.appear(self.I_GI_IN_ROOM):
+                    logger.info('bondling_fairyland time limit out')
+                    break
+
+            if self.appear(self.I_GI_IN_ROOM):
+                # 点击挑战
+                if not is_first:
+                    if self.run_invite(config=self.config.bondling_fairyland.invite_config):
+                        self.run_battle(self.config.bondling_fairyland.battle_config, limit_count=self.limit_count)
+                    else:
+                        # 邀请失败,退出任务
+                        logger.warning('Invite failed and exit this bondling_fairyland task')
+                        success = False
+                        break
+
+                # 第一次会邀请队友
+                if is_first:
+                    if not self.run_invite(config=self.config.bondling_fairyland.invite_config, is_first=True):
+                        logger.warning('Invite failed and exit this bondling_fairyland task')
+                        success = False
+                        break
+                    else:
+                        is_first = False
+                        self.run_battle(self.config.bondling_fairyland.battle_config, limit_count=self.limit_count)
+                        continue
+            if self.appear(self.I_CHECK_BONDLING_FAIRYLAND):
+                return True
+        # 当结束或者是失败退出循环的时候只有两个UI的可能,在房间或者是在组队界面
+        # 如果在房间就退出
+        if self.exit_room():
+            pass
+        # 如果在组队界面就退出
+        if self.exit_team():
+            pass
+
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+
+        if success:
+            self.set_next_run(task='BondlingFairyland', finish=True, success=True)
+        else:
+            self.set_next_run(task='BondlingFairyland', finish=True, success=False)
+        raise TaskEnd
+
+    def wait_battle(self, wait_time: time) -> bool:
+        """
+        在房间等待,(要求保证在房间里面) 队长开启战斗
+        如果队长跑路了,或者的等待了很久还没开始
+        :return: 如果成功进入战斗(反正就是不在房间 )返回 True
+                 如果失败了,(退出房间)返回 False
+        """
+        self.timer_emoji = Timer(15)
+        self.timer_emoji.start()
+        wait_second = wait_time.second + wait_time.minute * 60
+        self.timer_wait = Timer(wait_second)
+        self.timer_wait.start()
+        logger.info(f'Wait battle {wait_second} seconds')
+        success = True
+        while 1:
+            self.screenshot()
+
+            # 如果自己在探索界面或者是庭院,那就是房间已经被销毁了
+            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_CHECK_BONDLING_FAIRYLAND):
+                logger.warning('Room destroyed')
+                success = False
+                break
+
+            if self.timer_wait.reached():
+                logger.warning('Wait battle time out')
+                success = False
+                break
+
+            if self.appear(self.I_EXIT):
+                success = True
+                logger.info("契灵:进入战斗页面!")
+                break
+
+            # # 判断是否进入战斗
+            # if self.is_in_room(is_screenshot=False):
+            #     logger.info("契灵:进入组队房间!")
+            #     if self.timer_emoji.reached():
+            #         self.timer_emoji.reset()
+            #         self.appear_then_click(self.I_GI_EMOJI_1)
+            #         self.appear_then_click(self.I_GI_EMOJI_2)
+            # else:
+            #     if self.appear(self.I_EXIT):
+            #         logger.info("契灵:进入战斗页面!")
+            #         break
+            #     if self.appear(self.I_CHECK_BONDLING_FAIRYLAND):
+            #         logger.info("契灵:探查页面!")
+            #         success = False
+            #         break
+
+        # 调出循环只有这些可能性:
+        # 1. 进入战斗(ui是战斗)
+        # 2. 队长跑路(自己还是在房间里面)
+        # 3. 等待时间到没有开始(还是在房间里面)
+        # 4. 房间的时间到了被迫提出房间(这个时候来到了探索界面)
+        if not success:
+            logger.info('Leave room')
+            self.exit_room()
+
+        return success
+
+    def exit_team(self) -> bool:
+        """
+        在组队界面 退出组队的界面, 返回到庭院或者是你一开始进入的入口
+        :return:
+        """
+        if self.appear(self.I_CHECK_TEAM):
+            logger.info('Exit team ui')
+            while 1:
+                self.screenshot()
+                if not self.appear(self.I_CHECK_TEAM):
+                    return True
+                if self.appear_then_click(self.I_GR_BACK_YELLOW, interval=0.5):
+                    continue
+
     def in_catch_ui(self, screenshot=False) -> bool:
         """
         判断是否在结契的总界面
@@ -558,6 +843,44 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
                 continue
         return False
 
+    def check_then_accept(self) -> bool:
+        """
+        队员接受邀请
+        :return:
+        """
+        if not self.appear(self.I_I_ACCEPT):
+            return False
+        logger.info('Click accept')
+
+        accept_timer = Timer(5)
+        accept_timer.start()
+        logger.info("识别到队长邀请,准备点击接受")
+        while 1:
+            self.screenshot()
+
+            # 等待超时
+            logger.info(str(accept_timer.current()))
+            if accept_timer.reached():
+                logger.warning('accept_timer timeout')
+                break
+
+            if self.is_in_room():
+                return True
+            # 被秒开
+            # https://github.com/runhey/OnmyojiAutoScript/issues/230
+            if self.appear(GeneralBattleAssets.I_EXIT):
+                logger.info("进入到组队房间!")
+                return False
+            if self.appear_then_click(self.I_I_NO_DEFAULT, interval=1):
+                continue
+            if self.appear_then_click(self.I_GI_SURE, interval=1):
+                continue
+            if self.appear_then_click(self.I_I_ACCEPT_DEFAULT, interval=1):
+                continue
+            if self.appear_then_click(self.I_I_ACCEPT, interval=1):
+                continue
+        return True
+
     @cached_property
     def general_battle_config(self):
         gbc = GeneralBattleConfig()
@@ -567,12 +890,13 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
         gbc.random_click_swipt_enable = False
         return gbc
 
+
 if __name__ == '__main__':
     from module.config.config import Config
     from module.device.device import Device
     import cv2
 
-    config = Config('oas1')
+    config = Config('du')
     device = Device(config)
     task = ScriptTask(config, device)
     image = task.screenshot()

+ 4 - 4
tasks/Component/GeneralInvite/assets.py

@@ -46,11 +46,11 @@ class GeneralInviteAssets:
 	# 左上角退出 
 	I_BACK_YELLOW = RuleImage(roi_front=(19,13,58,55), roi_back=(19,13,58,55), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_back_yellow.png")
 	# 点击邀请 
-	I_INVITE_ENSURE = RuleImage(roi_front=(710,544,132,60), roi_back=(710,544,132,60), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_invite_ensure.png")
+	I_INVITE_ENSURE = RuleImage(roi_front=(500,541,132,60), roi_back=(478,523,378,92), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_invite_ensure.png")
 	# 判断是否点中好友了 
-	I_SELECTED = RuleImage(roi_front=(895,373,33,32), roi_back=(895,373,33,32), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_selected.png")
+	I_SELECTED = RuleImage(roi_front=(895,373,33,32), roi_back=(380,157,568,350), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_selected.png")
 	# 用来判断当前的列表是哪儿的 
-	I_FLAG_1_ON = RuleImage(roi_front=(354,126,62,21), roi_back=(354,126,62,21), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_flag_1_on.png")
+	I_FLAG_1_ON = RuleImage(roi_front=(373,127,22,21), roi_back=(373,127,22,21), threshold=0.7, method="Template matching", file="./tasks/Component/GeneralInvite/gi/flag_1_on_new.png")
 	# description 
 	I_FLAG_1_OFF = RuleImage(roi_front=(353,126,58,22), roi_back=(353,126,58,22), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_flag_1_off.png")
 	# description 
@@ -90,7 +90,7 @@ class GeneralInviteAssets:
 	# 所有的组队界面都有加成 
 	I_GI_BUFF = RuleImage(roi_front=(794,38,46,42), roi_back=(794,38,46,42), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_gi_buff.png")
 	# 三人御魂组队左上角的协站队伍 
-	I_GI_IN_ROOM = RuleImage(roi_front=(92,17,213,64), roi_back=(92,17,213,64), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_gi_in_room.png")
+	I_GI_IN_ROOM = RuleImage(roi_front=(92,17,213,64), roi_back=(92,17,213,64), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_in_room.png")
 	# description 
 	I_BACK_YELLOW_SEA = RuleImage(roi_front=(31,16,42,42), roi_back=(31,16,42,42), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_back_yellow_sea.png")
 

BIN
tasks/Component/GeneralInvite/gi/flag_1_on_new.png


+ 0 - 0
tasks/Component/GeneralInvite/gi/gi_gi_in_room.png → tasks/Component/GeneralInvite/gi/gi_in_room.png


+ 4 - 4
tasks/Component/GeneralInvite/gi/image.json

@@ -155,8 +155,8 @@
   {
     "itemName": "invite_ensure",
     "imageName": "gi_invite_ensure.png",
-    "roiFront": "710,544,132,60",
-    "roiBack": "710,544,132,60",
+    "roiFront": "500,541,132,60",
+    "roiBack": "478,523,378,92",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "点击邀请"
@@ -165,7 +165,7 @@
     "itemName": "selected",
     "imageName": "gi_selected.png",
     "roiFront": "895,373,33,32",
-    "roiBack": "895,373,33,32",
+    "roiBack": "380,157,568,350",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "判断是否点中好友了"
@@ -352,7 +352,7 @@
   },
   {
     "itemName": "gi_in_room",
-    "imageName": "gi_gi_in_room.png",
+    "imageName": "gi_in_room.png",
     "roiFront": "92,17,213,64",
     "roiBack": "92,17,213,64",
     "method": "Template matching",