Esempio n. 1
0
 def match_mark(self, cur: int) -> float:
     resist = "assets/extra/resist.png"
     weak = "assets/extra/weak.png"
     mark = f"temp/{cur}.png"
     if util.standby(mark, resist, threshold=0.8):
         return 0.5
     elif util.standby(mark, weak, threshold=0.8):
         return 2
     else:
         return 1
Esempio n. 2
0
 def match_mark(self, cur: int) -> float:
     resist = crds.CARD_IMAGE["resist"]
     weak = crds.CARD_IMAGE["weak"]
     mark = f"temp/{cur}.png"
     if util.standby(mark, resist, threshold=0.8):
         return 0.5
     elif util.standby(mark, weak, threshold=0.8):
         return 2
     else:
         return 1
Esempio n. 3
0
 def update_support(self):
     if util.standby("images/update.png"):
         util.tap(835, 125)
         time.sleep(0.5)
         if util.standby("images/close.png"):
             util.tap(640, 560)
             print("[INFO] Wait to refresh friend list")
             time.sleep(2)
         else:
             util.tap(840, 560)
             print("[INFO] friend list refresh")
         time.sleep(0.5)
Esempio n. 4
0
 def select_servant_skill(self, skill: int, tar: int = 0):
     while not util.standby(util.get_sh(self.shifts), "assets/attack.png"):
         time.sleep(0.2)
     self.tap(crds.SERVANT_SKILLS[skill - 1], 5, 5)
     time.sleep(1)
     if tar != 0:
         self.select_servant(tar)
Esempio n. 5
0
    def select_servant_skill(self, skill: int, tar: int = 0, extend=False):
        """ Select Servant Skill
        Parameters
        ----------
            skill: int
        The id of the skill. 1~9 counted from left.

            tar: int, optional
        The id of target servant. 1~3 counted from left.
        (If the skill has target servant)

            extend: bool
        Extend skill time for 1 sec if needed. Default: false

        Examples
        --------
        Here are examples::

            select_servant_skill(1) # skill w/o target servants
            select_servant_skill(3, 2) # skill w/ target servants
        """
        while not util.standby(util.get_sh(self.shifts), crds.IMAGE["attack"]):
            time.sleep(0.2)
        self.tap(crds.SERVANT_SKILLS[skill - 1], 5, 5)
        time.sleep(1)
        if tar != 0:
            self.select_servant(tar)
        if extend:
            time.sleep(1)
Esempio n. 6
0
    def select_checkpoint(self, ckp: str = None):
        """ Select Checkpoint
        Parameters
        ----------
            ckp: str, optional
        Override the initially set checkpoint.

        Raises
        ------
            Exception("Out of AP!")
        When out of AP.
        """
        self.wait(self.checkpoint)
        if ckp is None:
            ckp = self.checkpoint
        coordinates = util.get_crd(util.get_sh(self.shifts), ckp)
        self.tap(coordinates[0], 100)
        time.sleep(0.2)
        # check whether out of AP
        # Not tested
        # in progress
        if util.standby(util.get_sh(self.shifts), crds.IMAGE["no_ap"]):
            if self.counts > 0:
                self.eat_apple()
            else:
                raise Exception("Out of AP!")
        print("[INFO] Checkpoint selected.")
Esempio n. 7
0
    def select_cards(self, cards: [int]):
        """ Select Order Cards
        Parameters
        ----------
            cards: list
        A list of numbers of the card id (1~5 -> normal cards, 6,7,8 -> NP cards). 
        It should have maximum 3 number.   

        Examples
        --------
        Here are examples::

            select_cards([6]) # left the rest 2 randomly choosen
            select_cards([6,2]) # left the last 1 randomly choosen
            select_cards([1,2,3])
        """
        while not util.standby(util.get_sh(self.shifts), crds.IMAGE["attack"]):
            time.sleep(0.2)
        # tap ATTACK
        self.tap(crds.ATTACK, 100, 100)
        time.sleep(1.3)
        while len(cards) < 3:
            x = random.randrange(1, 6)
            if x in cards:
                continue
            cards.append(x)
        # tap CARDS
        for card in cards:
            self.tap(crds.CARDS[card - 1], 40, 90)
            time.sleep(0.2)
        print("[INFO] Selected cards: ", cards)
Esempio n. 8
0
 def select_servant(self, servant: int):
     while not util.standby("images/select.png"):
         print("[SKILL] Waiting for servent select")
         time.sleep(0.2)
     pos = self.cfg['servent']['%s' % servant]
     pos = pos.split(',')
     util.list_tap(pos)
     time.sleep(0.5)
Esempio n. 9
0
    def use_dynamica(self, target: int):
        """
        NOT TESTED!
        """
        while True:  # repeat until reached battle
            # wait for turn start
            while not util.standby(util.get_sh(self.shifts), crds.IMAGE["attack"]):
                time.sleep(0.2)
                # end if finished battle
                if util.standby("tmp.png", crds.IMAGE["finish"], 0.8):
                    return

            if self.reached_battle(target):
                return
            # select cards
            self.dynamica_select()
            time.sleep(1)
Esempio n. 10
0
 def toggle_master_skill(self):
     while not util.standby("images/attack.png"):
         print("[BATTLE] Waiting for Attack button", end="\r")
         time.sleep(0.2)
     pos = self.cfg['master']['button']
     pos = pos.split(',')
     util.list_tap(pos)
     print("[M_Skill] Toggle master skill bar")
Esempio n. 11
0
 def change_servant(self, org: int, tar: int):
     while not util.standby(util.get_sh(self.shifts),
                            "assets/order_change.png"):
         time.sleep(0.2)
     self.tap(crds.SERVANTS[org - 1], 90, 90)
     time.sleep(0.1)
     self.tap(crds.SERVANTS[tar + 2], 90, 90)
     time.sleep(0.1)
     self.tap((950, 950), 100)  # confirm btn
Esempio n. 12
0
 def finish_battle(self):
     while not util.standby(util.get_sh(self.shifts), "assets/item.png"):
         xs = util.get_crd(util.get_sh(self.shifts), "assets/close.png")
         if len(xs) != 0:
             self.tap(xs[0])
         self.tap((960, 540), 400, 200)
         time.sleep(0.2)
     time.sleep(0.2)
     x = util.get_crd(util.get_sh(self.shifts), "assets/item.png")
     self.tap(x[0])
Esempio n. 13
0
 def select_task(self, ckp: str):
     print("[INFO] Waiting Task selected")
     while not util.standby(self.checkpoint):
         time.sleep(0.2)
     util.tap(1100, 170)
     time.sleep(1)
     if util.standby("images/noap.png"):
         print("[INFO] Out of AP!")
         if self.counts > 0:
             self.counts -= 1
             self.eat_apple()
         elif self.counts == -1:
             util.tap(635, 610)
             self.wait_ap(self.timer)
             self.select_task(self.checkpoint)
         else:
             print("[INFO] Out of appale count")
             raise Exception("[INFO]Out of AP!")
     print("[INFO] Task selected.")
Esempio n. 14
0
 def select_servant(self, servant: int):
     """ Select Servant
     Parameters
     ----------
         servant: int
     The id of the servant. 1~3 counted from left.
     """
     while not util.standby(util.get_sh(self.shifts), crds.IMAGE["select"]):
         time.sleep(0.2)
     self.tap(crds.TARGETS[servant - 1], 100, 100)
Esempio n. 15
0
 def finish_battle(self):
     while not util.standby("images/next.png"):
         print("[FINISH] Waiting next button")
         util.tap(920, 45)
         self.needattack()
         time.sleep(0.2)
     util.tap(1105, 670)
     flag = 0
     while not util.standby(self.checkpoint):
         if flag == 0 and util.standby("images/friendrequest.png"):
             print("[FINISH] Check friend request screen")
             util.tap(330, 610)
             print("[FINISH] Reject friend request")
             flag = 1
         elif flag == 1:
             util.tap(920, 45)
         else:
             util.tap(920, 45)
         time.sleep(1)
     print("[INFO] Battle Finished.")
Esempio n. 16
0
 def finish_battle(self):
     while not util.standby(util.get_sh(self.shifts), crds.IMAGE["item"]):
         xs = util.get_crd(util.get_sh(self.shifts), crds.IMAGE["close"])
         if len(xs) != 0:
             self.tap(xs[0])
         self.tap((960, 540), 400, 200)
         time.sleep(0.2)
     time.sleep(0.2)
     x = util.get_crd(util.get_sh(self.shifts), crds.IMAGE["item"])
     self.tap(x[0])
     print("[INFO] Battle Finished.")
Esempio n. 17
0
 def waiting_phase(self, phase: int):
     if phase == 1:
         while not util.standby("images/phase1.png", 0.78):
             util.tap(920, 45)
             if self.debug:
                 print("Waiting for phase1")
             time.sleep(0.2)
     elif phase == 2:
         while not util.standby("images/phase2.png", 0.78):
             util.tap(920, 45)
             if self.debug:
                 print("Waiting for phase2")
             self.needattack()
             time.sleep(0.2)
     elif phase == 3:
         while not util.standby("images/phase3.png", 0.78):
             util.tap(920, 45)
             if self.debug:
                 print("Waiting for phase3")
             self.needattack()
             time.sleep(0.2)
Esempio n. 18
0
 def change_servant(self, org: int, tar: int):
     while not util.standby("images/order_change.png"):
         print("[M_Skill] Waiting for order change")
         time.sleep(0.2)
     pos = self.cfg['servent']['s%s', org]
     pos = pos.split(',')
     util.list_tap(pos)
     time.sleep(0.1)
     pos = self.cfg['servent']['a%s', tar]
     pos = pos.split(',')
     util.list_tap(pos)
     time.sleep(0.1)
     util.tap(650, 620)  # confirm btn
Esempio n. 19
0
 def select_master_skill(self, skill: int, org: int = 0, tar: int = 0):
     while not util.standby("images/attack.png"):
         print("[BATTLE] Waiting for Attack button", end="\r")
         time.sleep(0.2)
     self.toggle_master_skill()
     pos = self.cfg['master']['%s' % skill]
     pos = pos.split(',')
     util.list_tap(pos)
     print("[M_Skill] Use master skill", skill)
     if org != 0 and tar == 0:
         self.select_servant(org)
     elif org != 0:
         self.change_servant(org, tar)
Esempio n. 20
0
 def select_checkpoint(self, ckp: str = None):
     self.wait(self.checkpoint)
     if ckp is None:
         ckp = self.checkpoint
     crds = util.get_crd(util.get_sh(self.shifts), self.checkpoint)
     self.tap(crds[0], 100)
     time.sleep(0.2)
     # check whether out of AP
     # Not tested
     if util.standby(util.get_sh(self.shifts),
                     "assets/noap.png"):  # in progress
         if self.counts > 0:
             self.eat_apple()
         else:
             raise Exception("Out of AP!")
Esempio n. 21
0
 def select_cards(self, cards: [int]):
     while not util.standby(util.get_sh(self.shifts), "assets/attack.png"):
         time.sleep(0.2)
     # tap ATTACK
     self.tap(crds.ATTACK, 100, 100)
     time.sleep(1)
     while len(cards) < 3:
         x = random.randrange(1, 6)
         if x in cards:
             continue
         cards.append(x)
     # tap CARDS
     for card in cards:
         self.tap(crds.CARDS[card - 1], 50, 100)
         time.sleep(0.2)
Esempio n. 22
0
 def update_support(self) -> bool:
     """ Update Support List
     Returns
     -------
         bool
     `True` if successfully updated, otherwise is `False`.
     """
     btn = util.get_crd(util.get_sh(self.shifts), "assets/update.png")
     self.tap(btn[0], 1, 1)
     time.sleep(0.1)
     if util.standby(util.get_sh(self.shifts), "assets/uplist.png"):
         self.tap((1240, 840), 10, 5)
         return True
     else:
         self.tap((950, 840))
         return False
Esempio n. 23
0
 def select_servant_skill(self, skill: int, tar: int = 0):
     while not util.standby("images/attack.png"):
         print("[BATTLE] Waiting for Attack button", end="\r")
         time.sleep(1)
     pos = self.cfg['skills']['%s' % skill]
     pos = pos.split(',')
     util.tap(pos[0], pos[1])
     if tar != 0:
         print("[Skill] Use servent", str(int((skill-1)/3 + 1)),
               "skill", str((skill-1) % 3 + 1), "to servent", tar)
         time.sleep(1)
         self.select_servant(tar)
     else:
         print("[Skill] Use servent", str(int((skill-1)/3 + 1)),
               "skill", str((skill-1) % 3 + 1))
         time.sleep(1)
Esempio n. 24
0
 def update_support(self) -> bool:
     """ Update Support List
     Returns
     -------
         bool
     `True` if successfully updated, otherwise is `False`.
     """
     btn = util.get_crd(util.get_sh(self.shifts),
                        crds.IMAGE["update_support"])
     self.tap(btn[0], 1, 1)
     time.sleep(0.1)
     if util.standby(util.get_sh(self.shifts),
                     crds.IMAGE["confirm_update"]):
         self.tap((1240, 840), 10, 5)
         return True
     else:
         self.tap((950, 840))
         return False
Esempio n. 25
0
    def change_servant(self, org: int, tar: int):
        """ Change Servant
        Parameters
        ----------
            org: int
        Servant id on the left side(1~3) 

            tar: int
        Servant id on the right side(1~3)
        """
        while not util.standby(util.get_sh(self.shifts),
                               crds.IMAGE["order_change"]):
            time.sleep(0.2)
        self.tap(crds.SERVANTS[org - 1], 90, 90)
        time.sleep(0.1)
        self.tap(crds.SERVANTS[tar + 2], 90, 90)
        time.sleep(0.1)
        self.tap((950, 950), 100)  # confirm btn
Esempio n. 26
0
 def advance_support(self, spt: str = None, tms: int = 3):
     if spt is None:
         spt = self.support
     flag1 = True
     flag2 = True
     while flag1:
         spt_pos = util.standby(spt)
         if spt_pos == False:
             print("[INFO] Friend not found")
             if flag2:
                 bar_pos = util.standby("images/bar.png")
                 if bar_pos == False:
                     if self.debug:
                         print("no bar")
                     self.update_support()
                 else:
                     if self.debug:
                         print("have bar")
                     flag2 = False
                     end_pos = util.standby("images/friendEnd.png")
                     end_pos = end_pos[:1]
                     if end_pos == False:
                         print("[INFO] End of friend list")
                         self.update_support()
                         flag2 = True
                     else:
                         gap_pos, gap_h, gap_w = util.standby(
                             "images/friend_gap.png", 0.8, True)
                         util.swipe(
                             gap_pos[0]+(gap_w/2), gap_pos[1]+(gap_h/2), gap_pos[0]+(gap_w/2), 210, 1.5)
             else:
                 end_pos = util.standby("images/friendEnd.png")
                 if end_pos[0] != False:
                     print("[INFO] End of friend list")
                     self.update_support()
                     flag2 = True
                 else:
                     if self.debug:
                         print("swipe down")
                     gap_pos, gap_h, gap_w = util.standby(
                         "images/friend_gap.png", 0.8, True)
                     util.swipe(
                         gap_pos[0]+(gap_w/2), gap_pos[1]+(gap_h/2), gap_pos[0]+(gap_w/2), 210, 1.5)
         else:
             flag1 = False
             spt_center = [int(spt_pos[0][0]+5),
                           int(spt_pos[0][1]+5)]
             util.list_tap(spt_center)
Esempio n. 27
0
    def finish_battle(self, cont=True):
        """ Finish Battle
        In `Free Quest`, there will be a continue battle option

        Parameters
        ----------
            cont: bool
        Defalut: `True` this will tap `閉じる` or `关闭` (close). when set to `False`, no action will be taken.
        """
        while not util.standby(util.get_sh(self.shifts), crds.IMAGE["item"]):
            xs = util.get_crd(util.get_sh(self.shifts), crds.IMAGE["close"])
            if len(xs) != 0:
                self.tap(xs[0])
            self.tap((960, 540), 400, 200)
            time.sleep(0.2)
        time.sleep(0.2)
        x = util.get_crd(util.get_sh(self.shifts), crds.IMAGE["item"])
        self.tap(x[0])
        if cont:
            time.sleep(0.5)
            self.tap((650, 850))
        print("[INFO] Battle Finished.")
Esempio n. 28
0
 def select_cards(self, cards: [int]):
     time.sleep(1)
     while not util.standby("images/attack.png"):
         print("[BATTLE] Waiting for Attack button", end="\r")
         time.sleep(0.2)
     # tap ATTACK
     pos = self.cfg['attack']['button']
     pos = pos.split(',')
     util.list_tap(pos)
     time.sleep(1)
     while len(cards) < 3:
         x = random.randrange(1, 6)
         if x in cards:
             continue
         cards.append(x)
     # tap CARDS
     for card in cards:
         pos = self.cfg['attack']['%s' % card]
         pos = pos.split(',')
         util.list_tap(pos)
         time.sleep(0.2)
     print("[BATTLE] Selected cards: ", cards)
Esempio n. 29
0
    def select_servant_skill(self, skill: int, tar: int = 0):
        """ Select Servant Skill
        Parameters
        ----------
            skill: int
        The id of the skill. 1~9 counted from left.

            tar: int, optional
        The id of target servant. 1~3 counted from left.
        (If the skill has target servant)

        Examples
        --------
        Here are examples::

            select_servant_skill(1) # skill w/o target servants
            select_servant_skill(3, 2) # skill w/ target servants
        """
        while not util.standby(util.get_sh(self.shifts), "assets/attack.png"):
            time.sleep(0.2)
        self.tap(crds.SERVANT_SKILLS[skill - 1], 5, 5)
        time.sleep(1)
        if tar != 0:
            self.select_servant(tar)
Esempio n. 30
0
 def wait(self, pic: str):
     while not util.standby(util.get_sh(self.shifts), pic):
         time.sleep(0.2)