コード例 #1
0
 def eat_apple(self):
     x = util.get_crd(util.get_sh(self.shifts), self.apple)
     self.tap(x[0])
     self.counts -= 1
     time.sleep(0.2)
     y = util.get_crd(util.get_sh(self.shifts), "assets/decide.png")
     self.tap(y[0])
コード例 #2
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
 def eat_apple(self):
     x = util.get_crd(util.get_sh(self.shifts), self.apple)
     self.tap(x[0])
     self.counts -= 1
     time.sleep(0.2)
     y = util.get_crd(util.get_sh(self.shifts), crds.IMAGE["decide"])
     self.tap(y[0])
コード例 #3
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
    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.")
コード例 #4
0
ファイル: Automata.py プロジェクト: kcn3388/FGO-Automata
 def eat_apple(self):
     path = f"assets/{self.apple}.png"
     x = util.get_crd(util.get_sh(self.shifts), path)
     self.tap(x[0])
     self.counts -= 1
     time.sleep(0.2)
     y = util.get_crd(util.get_sh(self.shifts), crds.IMAGE["decide"])
     self.tap(y[0])
     print("[INFO] AP Recovered.")
コード例 #5
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])
コード例 #6
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
 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.")
コード例 #7
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
 def dynamica_select(self):
     # tap Attack to show cards
     self.tap(crds.ATTACK, 100, 100)
     time.sleep(1)
     # init the class
     dym = Dynamica(sft=self.shifts)
     util.get_sh(self.shifts)
     util.split_cards("tmp.png")
     out = dym.dynamic_battle()  # get order
     for i in out:
         self.tap(crds.CARDS[i], 40, 90)
         time.sleep(0.2)
コード例 #8
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!")
コード例 #9
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)
コード例 #10
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
    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)
コード例 #11
0
ファイル: Automata.py プロジェクト: rico-chen/FGO-Automata
 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
コード例 #12
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
 def get_current_battle(self) -> int:
     """ Get current Battle ID
     Returns
     -------
         int
     a number of current battle
     """
     return util.get_battle_id(util.get_sh(self.shifts))
コード例 #13
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
 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
コード例 #14
0
 def select_support(self, spt: str = None):
     time.sleep(0.3)
     if spt is None:
         spt = self.support
     x = util.get_crd(util.get_sh(self.shifts), spt)
     if len(x) == 0:
         self.tap((860, 430), 300, 100)
     else:
         self.tap(x[0])
コード例 #15
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
コード例 #16
0
ファイル: Automata.py プロジェクト: kcn3388/FGO-Automata
    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(util.get_sh(self.shifts), crds.IMAGE["finish"],
                                0.8):
                    return

            if self.reached_battle(target):
                return
            # select cards
            self.dynamica_select()
            time.sleep(1)
コード例 #17
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
 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)
コード例 #18
0
    def advance_support(self, spt: str = None, tms: int = 3):
        """ Advance Support Selection

        Parameters
        ----------
            spt: str, optional
        Override the initially set support.

            tms: int, optional
        Max support list update times. (Default: 3)

        Raises
        ------
            Exception("Desired support not found!")
        Raises when reached maxium update times.
        """
        time.sleep(0.3)
        if spt is None:
            spt = self.support
        x = util.get_crd(util.get_sh(self.shifts), spt)
        counter = False
        times = tms
        while len(x) == 0:
            if not counter:
                self.swipe((1000, 800), (1000, 300), 0.5 +
                           0.1 * random.randrange(1, 10))
                counter = True
            else:
                update = self.update_support()
                if update:
                    counter = False
                    times -= 1
                    if times < 0:
                        raise Exception("Desired support not found!")
                else:
                    time.sleep(3)
            time.sleep(0.5)
            x = util.get_crd(util.get_sh(self.shifts), spt)
        self.tap(x[0])
        print("[INFO] Support selected.")
コード例 #19
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.")
コード例 #20
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)
コード例 #21
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
 def select_support(self, spt: str = None):
     """ Select Support
     Parameters
     ----------
         spt: str, optional
     Override the initially set support.
     """
     time.sleep(0.3)
     if spt is None:
         spt = self.support
     x = util.get_crd(util.get_sh(self.shifts), spt)
     if len(x) == 0:
         self.tap((860, 430), 300, 100)
     else:
         self.tap(x[0])
コード例 #22
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
    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
コード例 #23
0
ファイル: Automata.py プロジェクト: rico-chen/FGO-Automata
    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)
コード例 #24
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
 def wait(self, pic: str):
     while not util.standby(util.get_sh(self.shifts), pic):
         time.sleep(0.2)
コード例 #25
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
 def start_battle(self):
     while not util.standby(util.get_sh(self.shifts), crds.IMAGE["start"]):
         time.sleep(0.2)
     x = util.get_crd(util.get_sh(self.shifts), crds.IMAGE["start"])
     self.tap(x[0])
     print("[INFO] Battle started.")
コード例 #26
0
 def toggle_master_skill(self):
     while not util.standby(util.get_sh(self.shifts), "assets/attack.png"):
         time.sleep(0.2)
     self.tap(crds.MASTER)
コード例 #27
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
 def is_finished(self) -> bool:
     time.sleep(0.2)
     return util.standby(util.get_sh(self.shifts), crds.IMAGE["finish"],
                         0.7)
コード例 #28
0
ファイル: Automata.py プロジェクト: Tsuasahi/FGO-Automata
 def toggle_master_skill(self):
     while not util.standby(util.get_sh(self.shifts), crds.IMAGE["attack"]):
         time.sleep(0.2)
     self.tap(crds.MASTER)