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

Revert "ADD FALLENSUN"

This reverts commit ce395bbc60a82631ed32af741c8ebac8378ae62c.
TripleEarth 3 лет назад
Родитель
Сommit
63a1b8e76b

+ 2 - 32
tasks/FallenSun/assets.py

@@ -7,36 +7,6 @@ from module.atom.list import RuleList
 
 # This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
-class FallenSunAssets:
-
-
-	# Image Rule Assets
-	# 八级大蛇进入 
-	I_OROCHI = RuleImage(roi_front=(55,104,295,406), roi_back=(55,104,295,406), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi.png")
-	# 组队 
-	I_FORM_TEAM = RuleImage(roi_front=(937,591,100,100), roi_back=(937,591,100,100), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_form_team.png")
-	# description 
-	I_OROCHI_LOCK = RuleImage(roi_front=(573,559,31,32), roi_back=(548,554,65,54), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_lock.png")
-	# description 
-	I_OROCHI_UNLOCK = RuleImage(roi_front=(575,558,26,29), roi_back=(560,553,56,40), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_unlock.png")
-	# 点击挑战 
-	I_OROCHI_FIRE = RuleImage(roi_front=(1095,577,131,124), roi_back=(1095,577,131,124), threshold=0.6, method="Template matching", file="./tasks/Orochi/o/o_orochi_fire.png")
-	# 式神录 
-	I_SHI_RECORDS = RuleImage(roi_front=(821,638,48,45), roi_back=(821,638,48,45), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_shi_records.png")
-	# description 
-	I_OROCHI_MATCHING = RuleImage(roi_front=(62,568,44,114), roi_back=(62,568,44,114), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_matching.png")
-	# 小小宠物,发现宝藏 
-	I_PET_PRESENT = RuleImage(roi_front=(873,184,62,147), roi_back=(873,184,62,147), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_pet_present.png")
-
-
-	# List Rule Assets
-	# 这个是御魂界面选择不同层数的 
-	L_LAYER_LIST = RuleList(folder="./tasks/FallenSun/res", direction="vertical", mode="ocr", roi_back=(138,130,359,500), size=(45, 88),
-					 array=["壹", "贰", "叁"])
-
-
-	# Ocr Rule Assets
-	# Ocr-description 
-	O_O_TEST_OCR = RuleOcr(roi=(126,136,360,491), area=(126,136,360,491), mode="Full", method="Default", keyword="", name="o_test_ocr")
-
+class FallenSunAssets: 
+	pass
 

+ 4 - 37
tasks/FallenSun/config.py

@@ -1,44 +1,11 @@
 # This Python file uses the following encoding: utf-8
-# @author TripleEarth
-# github https://github.com/TripleEarth
+# @author runhey
+# github https://github.com/runhey
 from pydantic import BaseModel, Field
-from enum import Enum
-from datetime import datetime, time
 
-from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
 from tasks.Component.config_scheduler import Scheduler
-from tasks.Component.config_base import ConfigBase, TimeDelta
-from tasks.Component.GeneralInvite.config_invite import InviteConfig
-from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
-
-
-class UserStatus(str, Enum):
-    LEADER = 'leader'
-    MEMBER = 'member'
-    ALONE = 'alone'
-    WILD = 'wild'  # 还不打算实现
-
-class Layer(str, Enum):
-    ONE = '壹层'
-    TWO = '贰层'
-    THREE = '叁层'
-
-
-class FallenSunConfig(ConfigBase):
-    # 身份
-    user_status: UserStatus = Field(default=UserStatus.LEADER, description='user_status_help')
-    # 层数
-    layer: Layer = Field(default=Layer.ELEVEN, description='layer_help')
-    # 限制时间
-    limit_time: time = Field(default=time(minute=30), description='limit_time_help')
-    # 限制次数
-    limit_count: int = Field(default=30, description='limit_count_help')
-    # 是否开启御魂加成
-    # soul_buff_enable: bool = Field(default=False, description='soul_buff_enable_help')
+from tasks.Component.config_base import ConfigBase
 
 class FallenSun(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
-    fallensun_config: FallenSunConfig = Field(default_factory=FallenSunConfig)
-    invite_config: InviteConfig = Field(default_factory=InviteConfig)
-    general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
-    switch_soul: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
+

+ 0 - 74
tasks/FallenSun/f/image.json

@@ -1,74 +0,0 @@
-[
-  {
-    "itemName": "orochi",
-    "imageName": "o_orochi.png",
-    "roiFront": "55,104,295,406",
-    "roiBack": "55,104,295,406",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "八级大蛇进入"
-  },
-  {
-    "itemName": "form_team",
-    "imageName": "o_form_team.png",
-    "roiFront": "937,591,100,100",
-    "roiBack": "937,591,100,100",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "组队"
-  },
-  {
-    "itemName": "orochi_lock",
-    "imageName": "o_orochi_lock.png",
-    "roiFront": "573,559,31,32",
-    "roiBack": "548,554,65,54",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "description"
-  },
-  {
-    "itemName": "orochi_unlock",
-    "imageName": "o_orochi_unlock.png",
-    "roiFront": "575,558,26,29",
-    "roiBack": "560,553,56,40",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "description"
-  },
-  {
-    "itemName": "orochi_fire",
-    "imageName": "o_orochi_fire.png",
-    "roiFront": "1095,577,131,124",
-    "roiBack": "1095,577,131,124",
-    "method": "Template matching",
-    "threshold": 0.6,
-    "description": "点击挑战"
-  },
-  {
-    "itemName": "shi_records",
-    "imageName": "o_shi_records.png",
-    "roiFront": "821,638,48,45",
-    "roiBack": "821,638,48,45",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "式神录"
-  },
-  {
-    "itemName": "orochi_matching",
-    "imageName": "o_orochi_matching.png",
-    "roiFront": "62,568,44,114",
-    "roiBack": "62,568,44,114",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "description"
-  },
-  {
-    "itemName": "pet_present",
-    "imageName": "o_pet_present.png",
-    "roiFront": "873,184,62,147",
-    "roiBack": "873,184,62,147",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "小小宠物,发现宝藏"
-  }
-]

BIN
tasks/FallenSun/f/o_form_team.png


BIN
tasks/FallenSun/f/o_orochi.png


BIN
tasks/FallenSun/f/o_orochi_fire.png


BIN
tasks/FallenSun/f/o_orochi_lock.png


BIN
tasks/FallenSun/f/o_orochi_matching.png


BIN
tasks/FallenSun/f/o_orochi_unlock.png


BIN
tasks/FallenSun/f/o_pet_present.png


BIN
tasks/FallenSun/f/o_shi_records.png


+ 0 - 57
tasks/FallenSun/res/list.json

@@ -1,57 +0,0 @@
-{
-  "name": "layer_list",
-  "direction": "vertical",
-  "type": "ocr",
-  "roiBack": "138,130,359,500",
-  "description": "这个是御魂界面选择不同层数的",
-  "list": [
-    {
-      "itemName": "壹",
-      "roiFront": "281,135,39,102"
-    },
-    {
-      "itemName": "贰",
-      "roiFront": "280,253,39,85"
-    },
-    {
-      "itemName": "叁",
-      "roiFront": "283,422,43,93"
-    },
-    {
-      "itemName": "肆",
-      "roiFront": "280,312,44,90"
-    },
-    {
-      "itemName": "伍",
-      "roiFront": "282,425,43,82"
-    },
-    {
-      "itemName": "陆",
-      "roiFront": "275,316,47,89"
-    },
-    {
-      "itemName": "柒",
-      "roiFront": "279,312,48,93"
-    },
-    {
-      "itemName": "捌",
-      "roiFront": "275,203,51,89"
-    },
-    {
-      "itemName": "玖",
-      "roiFront": "278,206,48,81"
-    },
-    {
-      "itemName": "拾",
-      "roiFront": "282,315,45,84"
-    },
-    {
-      "itemName": "悲",
-      "roiFront": "277,427,47,85"
-    },
-    {
-      "itemName": "神",
-      "roiFront": "277,534,46,86"
-    }
-  ]
-}

+ 0 - 11
tasks/FallenSun/res/ocr.json

@@ -1,11 +0,0 @@
-[
-  {
-    "itemName": "o_test_ocr",
-    "roiFront": "126,136,360,491",
-    "roiBack": "126,136,360,491",
-    "mode": "Full",
-    "method": "Default",
-    "keyword": "",
-    "description": "Ocr-description"
-  }
-]

+ 0 - 359
tasks/FallenSun/script_task.py

@@ -1,359 +0,0 @@
-# This Python file uses the following encoding: utf-8
-# @author runhey
-# github https://github.com/runhey
-from time import sleep
-from datetime import time, datetime, timedelta
-
-from tasks.Component.GeneralBattle.general_battle import GeneralBattle
-from tasks.Component.GeneralInvite.general_invite import GeneralInvite
-from tasks.Component.GeneralBuff.general_buff import GeneralBuff
-from tasks.Component.GeneralRoom.general_room import GeneralRoom
-from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
-from tasks.GameUi.game_ui import GameUi
-from tasks.GameUi.page import page_main, page_soul_zones, page_shikigami_records
-from tasks.FallenSun.assets import FallenSunAssets
-from tasks.FallenSun.config import FallenSun, UserStatus
-from module.logger import logger
-from module.exception import TaskEnd
-
-class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi, SwitchSoul, FallenSunAssets):
-
-    def run(self) -> bool:
-        # 御魂切换方式一
-        if self.config.fallensun.switch_soul.enable:
-            self.ui_get_current_page()
-            self.ui_goto(page_shikigami_records)
-            self.run_switch_soul(self.config.fallensun.switch_soul.switch_group_team)
-
-        # 御魂切换方式二
-        if self.config.fallensun.switch_soul.enable_switch_by_name:
-            self.ui_get_current_page()
-            self.ui_goto(page_shikigami_records)
-            self.run_switch_soul_by_name(self.config.fallensun.switch_soul.group_name,
-                                         self.config.fallensun.switch_soul.team_name)
-
-        limit_count = self.config.fallensun.fallensun_config.limit_count
-        limit_time = self.config.fallensun.fallensun_config.limit_time
-        self.current_count = 0
-        self.limit_count: int = limit_count
-        self.limit_time: timedelta = timedelta(hours=limit_time.hour, minutes=limit_time.minute, seconds=limit_time.second)
-
-        self.ui_get_current_page()
-        self.ui_goto(page_main)
-        config: FallenSun = self.config.fallensun
-
-        success = True
-        match config.fallensun_config.user_status:
-            case UserStatus.LEADER: success = self.run_leader()
-            case UserStatus.MEMBER: success = self.run_member()
-            case UserStatus.ALONE: self.run_alone()
-            case UserStatus.WILD: self.run_wild()
-            case _: logger.error('Unknown user status')
-
-        # 下一次运行时间
-        if success:
-            self.set_next_run('FallenSun', finish=True, success=True)
-        else:
-            self.set_next_run('FallenSun', finish=False, success=False)
-
-        raise TaskEnd
-
-
-
-    def fallensun_enter(self) -> bool:
-        logger.info('Enter fallensun')
-        while True:
-            self.screenshot()
-            if self.appear(self.I_FORM_TEAM):
-                return True
-            if self.appear_then_click(self.I_FALLENSUN, interval=1):
-                continue
-
-    def check_layer(self, layer: str) -> bool:
-        """
-        检查挑战的层数, 并选中挑战的层
-        :return:
-        """
-        pos = self.list_find(self.L_LAYER_LIST, layer)
-        if pos:
-            self.device.click(x=pos[0], y=pos[1])
-            return True
-
-    def check_lock(self, lock: bool = True) -> bool:
-        """
-        检查是否锁定阵容, 要求在八岐大蛇界面
-        :param lock:
-        :return:
-        """
-        logger.info('Check lock: %s', lock)
-        if lock:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_FALLENSUN_LOCK):
-                    return True
-                if self.appear_then_click(self.I_FALLENSUN_UNLOCK, interval=1):
-                    continue
-        else:
-            while 1:
-                self.screenshot()
-                if self.appear(self.I_FALLENSUN_UNLOCK):
-                    return True
-                if self.appear_then_click(self.I_FALLENSUN_LOCK, interval=1):
-                    continue
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-    def run_leader(self):
-        logger.info('Start run leader')
-        self.ui_get_current_page()
-        self.ui_goto(page_soul_zones)
-        self.fallensun_enter()
-        layer = self.config.fallensun.fallensun_config.layer
-        self.check_layer(layer)
-        self.check_lock(self.config.fallensun.general_battle_config.lock_team_enable)
-        # 创建队伍
-        logger.info('Create team')
-        while 1:
-            self.screenshot()
-            if self.appear(self.I_FALLENSUN_MATCHING):
-                break
-            if self.appear_then_click(self.I_FORM_TEAM, interval=1):
-                continue
-        # 创建房间
-        self.create_room()
-        self.ensure_private()
-        self.create_ensure()
-
-        # 邀请队友
-        success = True
-        is_first = True
-        # 这个时候我已经进入房间了哦
-        while 1:
-            self.screenshot()
-            # 无论胜利与否, 都会出现是否邀请一次队友
-            # 区别在于,失败的话不会出现那个勾选默认邀请的框
-            if self.check_and_invite(self.config.fallensun.invite_config.default_invite):
-                continue
-
-            # 检查猫咪奖励
-            if self.appear_then_click(self.I_PET_PRESENT, action=self.C_WIN_3, interval=1):
-                continue
-
-            if self.current_count >= self.limit_count:
-                if self.is_in_room():
-                    logger.info('FallenSun count limit out')
-                    break
-
-            if datetime.now() - self.start_time >= self.limit_time:
-                if self.is_in_room():
-                    logger.info('FallenSun time limit out')
-                    break
-
-
-
-            # 如果没有进入房间那就不需要后面的邀请
-            if not self.is_in_room():
-                # 如果在探索界面或者是出现在组队界面, 那就是可能房间死了
-                # 要结束任务
-                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):
-                        logger.warning('FallenSun task failed')
-                        success = False
-                        break
-                continue
-
-            # 点击挑战
-            if not is_first:
-                if self.run_invite(config=self.config.fallensun.invite_config):
-                    self.run_general_battle(config=self.config.fallensun.general_battle_config)
-                else:
-                    # 邀请失败,退出任务
-                    logger.warning('Invite failed and exit this fallensun task')
-                    success = False
-                    break
-
-            # 第一次会邀请队友
-            if is_first:
-                if not self.run_invite(config=self.config.fallensun.invite_config, is_first=True):
-                    logger.warning('Invite failed and exit this fallensun task')
-                    success = False
-                    break
-                else:
-                    is_first = False
-                    self.run_general_battle(config=self.config.fallensun.general_battle_config)
-
-        # 当结束或者是失败退出循环的时候只有两个UI的可能,在房间或者是在组队界面
-        # 如果在房间就退出
-        if self.exit_room():
-            pass
-        # 如果在组队界面就退出
-        if self.exit_team():
-            pass
-
-        self.ui_get_current_page()
-        self.ui_goto(page_main)
-
-        if not success:
-            return False
-        return True
-
-    def run_member(self):
-        logger.info('Start run member')
-        self.ui_get_current_page()
-        # self.ui_goto(page_soul_zones)
-        # self.fallensun_enter()
-        # self.check_lock(self.config.fallensun.general_battle_config.lock_team_enable)
-
-        # 进入战斗流程
-        self.device.stuck_record_add('BATTLE_STATUS_S')
-        while 1:
-            self.screenshot()
-
-            # 检查猫咪奖励
-            if self.appear_then_click(self.I_PET_PRESENT, action=self.C_WIN_3, interval=1):
-                continue
-
-            if self.current_count >= self.limit_count:
-                logger.info('FallenSun count limit out')
-                break
-            if datetime.now() - self.start_time >= self.limit_time:
-                logger.info('FallenSun time limit out')
-                break
-
-            if self.check_then_accept():
-                continue
-
-            if self.is_in_room():
-                self.device.stuck_record_clear()
-                if self.wait_battle(wait_time=self.config.fallensun.invite_config.wait_time):
-                    self.run_general_battle(config=self.config.fallensun.general_battle_config)
-                else:
-                    break
-            # 队长秒开的时候,检测是否进入到战斗中
-            elif self.check_take_over_battle(False, config=self.config.fallensun.general_battle_config):
-                continue
-
-        while 1:
-            # 有一种情况是本来要退出的,但是队长邀请了进入的战斗的加载界面
-            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE):
-                break
-            # 如果可能在房间就退出
-            if self.exit_room():
-                pass
-            # 如果还在战斗中,就退出战斗
-            if self.exit_battle():
-                pass
-
-
-        self.ui_get_current_page()
-        self.ui_goto(page_main)
-        return True
-
-    def run_alone(self):
-        logger.info('Start run alone')
-        self.ui_get_current_page()
-        self.ui_goto(page_soul_zones)
-        self.fallensun_enter()
-        layer = self.config.fallensun.fallensun_config.layer
-        self.check_layer(layer)
-        self.check_lock(self.config.fallensun.general_battle_config.lock_team_enable)
-
-        def is_in_fallensun(screenshot=False) -> bool:
-            if screenshot:
-                self.screenshot()
-            return self.appear(self.I_FALLENSUN_FIRE)
-
-        while 1:
-            self.screenshot()
-
-            # 检查猫咪奖励
-            if self.appear_then_click(self.I_PET_PRESENT, action=self.C_WIN_3, interval=1):
-                continue
-
-            if not is_in_fallensun():
-                continue
-
-            if self.current_count >= self.limit_count:
-                logger.info('FallenSun count limit out')
-                break
-            if datetime.now() - self.start_time >= self.limit_time:
-                logger.info('FallenSun time limit out')
-                break
-
-            # 点击挑战
-            while 1:
-                self.screenshot()
-                if self.appear_then_click(self.I_FALLENSUN_FIRE, interval=1):
-                    pass
-
-                if not self.appear(self.I_FALLENSUN_FIRE):
-                    self.run_general_battle(config=self.config.fallensun.general_battle_config)
-                    break
-
-        # 回去
-        while 1:
-            self.screenshot()
-            if not self.appear(self.I_FORM_TEAM):
-                break
-            if self.appear_then_click(self.I_BACK_BL, interval=1):
-                continue
-
-        self.ui_current = page_soul_zones
-        self.ui_goto(page_main)
-
-
-
-    def run_wild(self):
-        logger.error('Wild mode is not implemented')
-        pass
-
-
-
-
-
-
-if __name__ == '__main__':
-    from module.config.config import Config
-    from module.device.device import Device
-    from memory_profiler import profile
-    c = Config('oas1')
-    d = Device(c)
-    t = ScriptTask(c, d)
-
-    # t.run()
-
-    # t.check_layer('悲')
-
-    from module.base.timer import timer
-
-    @timer
-    @profile
-    def test_memory():
-        t.screenshot()
-        print(t.ocr_appear(t.O_O_TEST_OCR))
-        print(t.L_LAYER_LIST.image_appear(t.device.image, '悲'))
-    for i in range(4):
-        test_memory()
-        print('=====================')
-
-
-
-
-
-
-