Example #1
0
def execute_script():
    """This is the main execution script"""
    load_dotenv()
    stop_hour = 4
    start_hour = 4

    while True:
        # logger.info("Main", "Executed once")
        try:
            current_hour = datetime.now().hour
            if stop_hour != start_hour:
                if stop_hour <= current_hour <= start_hour:
                    logger.info("Snooze", "Sleeping Time")
                    time.sleep(3600)
                    continue

            user1 = {"login_token": os.getenv("USER1")}
            mh_main = MouseHunt(user1)
            mh_main.automateHunt()

            user2 = {"login_token": os.getenv("USER2")}
            mh_acc2 = MouseHunt(user2)
            mh_acc2.automateHunt("speedy")

        except Exception as general_error:
            print(str(general_error))
            traceback.print_exc()

        # delay = 900 + 60 * random.randint(1, 5)
        # logger.info("Delay", f"Waking up in {delay/60} minutes")
        # time.sleep(delay)
        time.sleep(120)
Example #2
0
 def launch(self, powertype):
     logger.info(self.environment, f"Launching to {powertype} island")
     res = self.action({
         "action": "launch",
         "power_type": powertype,
         "use_saved_trap_setup": 0
     })
     return res
Example #3
0
    def armSkyPalaceSetup(self):
        status = False
        if not self.isItemArmed("weapon"):
            self.armSavedSetup()
            status = True

        # Now need to set things right
        # if self.getTrapSetup("trinket_id") != 1650:
        #     self.changeTrap(1650)
        # logger.info(self.environment, "Arming Rift ultimate luck charm")
        # status = True
        self.armExtraRichCC()

        if status:
            logger.info(self.environment, "Armed Sky Palace setup.")
Example #4
0
    def armPirateSetup(self):
        status = False
        if self.getTrapSetup("weapon_id") != 3087:
            self.changeTrap(3087)
            logger.info(self.environment, "Arming Slumbering Boulder Trap")
            status = True

        if self.getTrapSetup("bait_id") != 3090:
            self.changeTrap(3090)
            logger.info(self.environment, "Arming Pirate Cheese")
            status = True

        if self.getTrapSetup("trinket_id") != 1651:
            self.changeTrap(1651)
            logger.info(self.environment, "Arming Rift ultimate power charm")
            status = True

        if status:
            logger.info(self.environment,
                        "Armed pirate setup, ready to battle.")
Example #5
0
    def armWardenSetup(self):
        status = False
        if self.getTrapSetup("weapon_id") != 3087:
            self.changeTrap(3087)
            logger.info(self.environment, "Arming Slumbering Bolder Trap")
            status = True

        if self.getTrapSetup("bait_id") != 1967:
            self.changeTrap(1967)
            logger.info(self.environment, "Arming empowered SB+")
            status = True

        if self.getTrapSetup("trinket_id") != 1651:
            self.changeTrap(1651)
            logger.info(self.environment, "Arming Rift ultimate power charm")
            status = True

        if status:
            logger.info(self.environment,
                        "Armed warden setup, ready to battle.")
Example #6
0
    def armParagonSetup(self):
        status = False
        if self.getTrapSetup("bait_id") != 1967:
            self.changeTrap(1967)
            logger.info(self.environment, "Arming empowered SB+")
            status = True

        if self.getTrapSetup("trinket_id") != 1651:
            self.changeTrap(1651)
            logger.info(self.environment, "Arming Rift ultimate power charm")
            status = True

        if status:
            logger.info(self.environment,
                        "Armed paragon setup, ready to battle.")
Example #7
0
    def execute(self):
        return
        if (self.isIslandFullyExplored() and not self.isOnHighAltitudeIsland(
        )  # comment to leave immediately on HAI
                and not self.isAtSkyPalace() and not self.isBattlingWarden()
                and not self.isBattlingParagon()):

            # Conditions to hunt out the island
            # Hunt out first island as much as possible
            if self.isFirstIslandCompleted():
                if self.getCorsairCheeseCount() <= 75:
                    logger.info(
                        self.environment,
                        f"First pirate island completed, leaving island.",
                    )
                    self.leaveTheIsland()

            # Need to keep this so it wouldn't leave the island
            elif self.isSecondIslandCompleted():  # Hunt out admieral
                if not self.isHuntingRichard(
                ) and self.getCorsairCheeseCount() <= 10:
                    logger.info(
                        self.environment,
                        f"Second pirate island completed, leaving island.",
                    )
                    self.leaveTheIsland()

            else:
                logger.info(self.environment,
                            f"Low Altitude Island is fully explored.")
                self.leaveTheIsland()

        # Commence loop to scramble door until the preferred door is available
        while True:
            # Determining the threshold to start hunting pirates.
            pirate_threshold = 30
            # Case 1 - at launch pad ready to go
            if self.isAtLaunchPad():
                # Do nothing, ready to launch
                if self.getStormCellsCount() >= 250:
                    logger.info(
                        self.environment,
                        f"Got enough storm cells.",
                    )
                    return

                while True:
                    power = None
                    # Determine the mode of moving to the islands
                    # Case 1-1: At high altitude island - always hunt pirate curds
                    if self.isAtHAI():
                        power = self.determineIslandTarget(
                            "high_pirate_loot")  # Two key one pirate icon mode
                        # return

                    # Case 1-2: Low altitude but for first 3 must hunt pirate seals
                    elif self.isFirstIsland():
                        logger.info(self.environment, f"Determine 1st island.")
                        # Case 1-2-1: Hunt pirate if there is enough pirate curds
                        if self.getCorsairCheeseCount() >= pirate_threshold:
                            power = self.determineIslandTarget("pirate")
                        # Case 1-2-2: Hunt normally if not enough pirate curds
                        else:
                            power = self.determineIslandTarget("low_richard")

                    elif self.isSecondIsland():
                        logger.info(self.environment, f"Determine 2nd island.")
                        if self.getCorsairCheeseCount() >= pirate_threshold:
                            power = self.determineIslandTarget("pirate")
                        else:
                            power = self.determineIslandTarget("low_richard")

                    elif self.isThirdIsland():
                        logger.info(self.environment, f"Determine 3rd island.")
                        power = self.determineIslandTarget()

                    elif self.isFourthIsland():
                        logger.info(self.environment, f"Determine 4th island.")
                        power = self.determineIslandTarget()

                    if power != None:
                        break
                    if power == None:
                        logger.info(
                            self.environment,
                            f"No suitable island found, triggering cyclone.",
                        )
                        self.useCyclone()  # Troubleshoot first
                        time.sleep(2)

                logger.info(self.environment, f"The Power is {power}")
                self.launch(power)

            # Case 2, on the island
            else:
                # Case 2-1 Battle trap setups
                if self.isBattlingWarden():
                    self.armWardenSetup()

                elif self.isBattlingParagon():
                    self.armParagonSetup()

                elif self.isAtSkyPalace():
                    self.armSkyPalaceSetup()
                    if self.getIslandProgress() >= 30:
                        self.disableBottledWind()
                    else:
                        self.enableBottledWind()

                elif self.isOnHighAltitudeIsland():
                    if self.getIslandProgress() >= 30:
                        self.disableBottledWind()
                    else:
                        self.enableBottledWind()

                    if self.hasReachedAdmiral():
                        self.armPirateSetup()
                    else:
                        self.armSavedSetup()

                # Case 2-3 Low Altitude island actions
                elif self.isFourthIsland():
                    self.armSavedSetup()
                    if self.hasReachedAdmiral():
                        self.disableBottledWind()
                        self.armPirateSetup()
                    else:
                        self.enableBottledWind()
                        self.armSavedSetup()

                elif self.isThirdIsland():
                    self.armSavedSetup()
                    if self.hasReachedAdmiral():
                        self.disableBottledWind()
                        self.armPirateSetup()
                    else:
                        self.enableBottledWind()
                        self.armSavedSetup()

                elif self.isSecondIsland():
                    if self.isHuntingRichard():
                        self.armSavedSetup()
                        if self.hasReachedAdmiral():
                            self.disableBottledWind()
                        else:
                            self.enableBottledWind()

                    if self.isHuntingPirates():
                        self.armPirateSetup()
                        if self.hasReachedAdmiral():
                            self.disableBottledWind()
                        else:
                            self.enableBottledWind()

                elif self.isFirstIsland():
                    self.armPirateSetup()
                    if self.hasReachedAdmiral():
                        self.disableBottledWind()
                    else:
                        self.enableBottledWind()

                return
Example #8
0
 def armExtraRichCC(self):
     if self.getTrapSetup("bait_id") != 3274:
         self.changeTrap(3274)
         logger.info(self.environment, "Arming Extra Rich Cloud Cheesecake")
Example #9
0
        # logger.info("Main", "Executed once")
        try:
            current_hour = datetime.now().hour
            if stop_hour != start_hour:
                if stop_hour <= current_hour <= start_hour:
                    logger.info("Snooze", "Sleeping Time")
                    time.sleep(3600)
                    continue

            user1 = {"login_token": os.getenv("USER1")}
            mh_main = MouseHunt(user1)
            mh_main.automateHunt()

            user2 = {"login_token": os.getenv("USER2")}
            mh_acc2 = MouseHunt(user2)
            mh_acc2.automateHunt("speedy")

        except Exception as general_error:
            print(str(general_error))
            traceback.print_exc()

        # delay = 900 + 60 * random.randint(1, 5)
        # logger.info("Delay", f"Waking up in {delay/60} minutes")
        # time.sleep(delay)
        time.sleep(120)


if __name__ == "__main__":
    logger.info("Main", "Launching Application")
    execute_script()
Example #10
0
 def armSavedSetup(self):
     if not self.isArmingSavedSetup():
         res = self.action({"action": "arm_saved_setup"})
         logger.info(self.environment, f"Arming saved setup")
         return res
Example #11
0
 def useCyclone(self):
     res = self.action({"action": "reroll"})
     logger.info(self.environment, f"Randomize Adventure Board")
     return res
Example #12
0
 def leaveTheIsland(self):
     res = self.action({"action": "retreat"})
     logger.info(self.environment, f"Leaving the island")
     return res
Example #13
0
 def disableBottledWind(self):
     if self.getBottledWindStatus() == True:
         logger.info(self.environment, "Disabled bottled wind.")
         self.toggleBottledWind()
Example #14
0
 def enableBottledWind(self):
     if self.getBottledWindStatus(
     ) == False and self.getBottledWindCount() > 1:
         logger.info(self.environment, "Enabled bottled wind.")
         self.toggleBottledWind()
    def execute(self):
        sandCount = ""
        mode = None

        while True:
            if len(self.args) != 0:
                mode = self.args[0]

            # Brew the potions, if any
            if self.getItemsCount("ancient_string_cheese_potion") > randint(
                    6, 10):
                self.convertPotionToCheese(
                    "ancient_string_cheese_potion",
                    self.getItemsCount("ancient_string_cheese_potion"),
                )
            if self.getItemsCount("runic_string_cheese_potion") > randint(
                    4, 10):
                self.convertPotionToCheese(
                    "runic_string_cheese_potion",
                    self.getItemsCount("runic_string_cheese_potion"),
                )

            # Toggle for the case at acolyte chamber
            if self.getObeliskCharge() == 100 and self.isItemActive(
                    "rift_quantum_quartz_stat_item"):
                self.toggleQuantumQuarts()
                # self.changeTrap(2524) # Use festive ultimate lucky power charm
                # self.changeTrap(1288) # Use festive ultimate luck charm
                self.changeTrap(473)  # Use ultimate luck charm
                logger.info(self.environment,
                            "Obelisk fully charged, disable Quantum Quarts.")

            # Change trap setup after having suficient sand
            if (self.getCurrentChamber() == "timewarp_chamber" and
                    self.getItemsCount("rift_hourglass_sand_stat_item") > 44):
                if self.getTrapSetup("bait_id") != 1424:
                    self.changeTrap(1424)
                    logger.info(
                        self.environment,
                        "Armed brie string cheese due to sufficient sand.",
                    )

            # Refil brie string cheese if running low
            if self.getItemsCount("brie_string_cheese") < 200:
                purchase(self.login_token, 1424, 30)
                logger.info(self.environment,
                            "Purchased 30 brie string cheese.")

            # End loop if portals are closed
            if not self.isPortalsOpened():
                return

            # # Select the portal and enter the chamber, then change trap setup
            determinedPortal = None
            while determinedPortal == None:
                determinedPortal = self.determineChamberToEnter(mode)
                if determinedPortal == None:
                    self.scramblePortal()
                    time.sleep(10)

            sandCount += "with sandCount " + str(
                self.getItemsCount("rift_hourglass_sand_stat_item"))
            logger.info(self.environment,
                        f"Entering {determinedPortal} {sandCount}")
            self.selectChamber(determinedPortal)
            self.chamberTrapSetup(loadouts[determinedPortal])
            return
Example #16
0
    def determineIslandTarget(self, mode="normal"):
        weaponMap = self.sortSkyMapGrid()

        # Debugging
        for power in weaponMap:
            logger.info(self.environment, f"{power} : {weaponMap[power]}")

        def assignScore(map):
            if map == "ore_bonus":
                return 2
            if map == "gem_bonus":
                return 2
            if map == "sky_cheese":
                return 1
            if map == "loot_cache":
                return 3
            if map == "sky_pirates":
                return 4
            if map[0:13] == "paragon_cache":
                return 5
            if map[-6:] == "shrine":
                return 5
            return 0

        # key is to make everything 3,2,1,0
        if self.getItemCount(3077) < 5:
            mode = "poor"

        scoring = []
        logger.info(self.environment, f"{mode} mode grid search")

        for power in weaponMap:
            # Pirate Mode
            if mode == "pirate":
                # Prioritize pirate hunting
                if weaponMap[power].count("sky_pirates") != 2:
                    continue
                if weaponMap[power][0] != "sky_pirates":
                    continue

                skipping = True
                for slot in weaponMap[power]:
                    if slot[-6:] == "shrine":
                        skipping = False
                if skipping:
                    continue

            elif mode == "low_richard":
                hasTwoLoot = ("sky_pirates" in weaponMap[power]
                              and weaponMap[power].count("loot_cache") == 2)
                if not (hasTwoLoot):
                    continue

                skipping = True
                for slot in weaponMap[power]:
                    if slot[-6:] == "shrine":
                        skipping = False
                if skipping:
                    continue

            elif mode == "high_pirate_loot":
                hasOnePirate = ("loot_cache" in weaponMap[power]
                                and weaponMap[power].count("sky_pirates") == 1)
                hasTwoLoot = ("sky_pirates" in weaponMap[power]
                              and weaponMap[power].count("loot_cache") == 2)
                if not (hasOnePirate or hasTwoLoot):
                    continue

            # Pirate mode on high altitude island, prioritize pirate on high altitude
            elif mode == "admiral":
                hasTwoLoot = ("loot_cache" in weaponMap[power]
                              and weaponMap[power].count("sky_pirates") == 2)
                hasTwoPirate = ("sky_pirates" in weaponMap[power]
                                and weaponMap[power].count("loot_cache") == 2)
                hasTwoLoot = False  # Not gonna care for richard
                if not (hasTwoPirate or hasTwoLoot):
                    continue
                if hasTwoPirate:
                    print(
                        f"{power} has two pirate {hasTwoPirate} and one loot cache"
                    )
                if hasTwoLoot:
                    print(
                        f"{power} has two loot cache {hasTwoLoot} and one one pirate"
                    )
                # else:
                #     continue
                # if not ('loot_cache' in weaponMap[power] and weaponMap[power].count('sky_pirates') == 2):
                #     continue

            # Loot mode on high altitude island, prioritize pirate on loot
            elif mode == "high_loot":
                if "loot_cache" in weaponMap[power]:
                    print(f"{power}: {weaponMap[power]}")
                    print(
                        f'gem bonus: {weaponMap[power].count("gem_bonus")}, ore bonus: {weaponMap[power].count("ore_bonus")}'
                    )

                    if not (weaponMap[power].count("gem_bonus") == 2
                            or weaponMap[power].count("ore_bonus") == 2):
                        print(f"{power}: not consideered")
                        continue

                elif not (weaponMap[power].count("gem_bonus") == 3
                          or weaponMap[power].count("ore_bonus") == 3):
                    print(f"{power}: not consideered")
                    continue

            # Loot prioritize on getting a shrine, with the shortest distance
            elif mode == "poor":
                skipping = True
                for slot in weaponMap[power]:
                    if slot[-6:] == "shrine":
                        skipping = False
                if skipping:
                    continue

            # The first tile must be paragon or shrine
            else:
                if not (weaponMap[power][0][0:13] == "paragon_cache"
                        or weaponMap[power][0][-6:] == "shrine"):
                    continue

                # Count the number of empty skies
                noEmptySky = [
                    item for item in weaponMap[power] if item != "empty_sky"
                ]
                if weaponMap[power][0][0:13] == "paragon_cache":
                    if len(noEmptySky) < 4:
                        continue
                if weaponMap[power][0][-6:] == "shrine":
                    if len(noEmptySky) < 2:
                        continue
            score = (assignScore(weaponMap[power][0]) * 1000 +
                     assignScore(weaponMap[power][1]) * 100 +
                     assignScore(weaponMap[power][2]) * 10 +
                     assignScore(weaponMap[power][3]) * 1)
            scoring.append({"power": power, "score": score})

        newlist = sorted(scoring, key=lambda k: k["score"], reverse=True)

        for item in newlist:
            # logger.info(
            #     self.environment, f'{item["power"]} : {weaponMap[item["power"]]}'
            # )
            return item["power"]
    def determineChamberToEnter(self, mode):
        """
        This method determines the chamber to enter, the priorities are:
        1. Enter Security Chamber to disable alarm
        2. Enter Guard Barracks if the alarm was triggered
        3. Hidden Treasury for gold
        4. Then Lucky tower for loot
        5. Acolyte Chamber if conditions are met
        6. Timewarp chamber if conditions are met
        7. runic chamber if all else fails
        8. ancient chamber if oh well....
        9. Gear works, seriously?
        10. Enter the tower
        11. Never bother to enter ingress chamber

        returns the name of the chamber
        """

        self.refreshUserData()
        portals = self.getCurrentPortals()
        portals = list(set(portals))
        logger.info(self.environment, portals)

        aa_sand_threshold = 45  # For entering acolyate chamber
        runic_threshold = aa_sand_threshold  # For entering acolyate chamber
        runic_upper_threshold = 400  # For stop entering runic chambers
        timewramp_runicRqd_thresdhold = (
            40  # Required amount of runic cheese before enteiring timewarp
        )

        # Banished chambers
        if "ingress_chamber" in portals:
            portals.remove("ingress_chamber")

        if "basic_chamber" in portals:
            portals.remove("basic_chamber")

        # Loop begin
        if "entrance_chamber" in portals:
            logger.info(self.environment, "Starting the loop again....")
            return "basic_chamber"

        # Revert to normal mode conditions
        if mode == "speedy" and self.getItemsCount("runic_string_cheese") < 60:
            logger.info(self.environment,
                        "Insufficient RSC, converting to normal mode")
            mode = None

        # Go straight to the AA under speedy and can afford to scramble
        if mode == "speedy":
            if ("magic_chamber" in portals and
                    self.getItemsCount("rift_scramble_portals_stat_item") > 3):
                portals.remove("magic_chamber")

            if ("potion_chamber" in portals and
                    self.getItemsCount("rift_scramble_portals_stat_item") > 3):
                portals.remove("potion_chamber")

            if ("lucky_chamber" in portals and
                    self.getItemsCount("rift_scramble_portals_stat_item") > 3):
                portals.remove("lucky_chamber")

            if ("treasury_chamber" in portals and
                    self.getItemsCount("rift_scramble_portals_stat_item") > 3):
                portals.remove("treasury_chamber")

        # Condition 1s - Always enter
        if "guard_chamber" in portals:
            # logger.info(self.environment, "Entering Guard Barracks")
            return "guard_chamber"

        # Actively remove the status effect, if inflicted.
        if self.isStatusEffectsActive(
                "un") and "silence_chamber" not in portals:
            logger.info(self.environment, "Scrambling for security chamber")
            return None

        # Condition 1s - Always enter
        if "silence_chamber" in portals:
            # logger.info(self.environment, "Entering Silence Chamber")
            return "silence_chamber"

        # Condition 1s - Always enter
        if "security_chamber" in portals:
            # logger.info(self.environment, "Entering Security Chamber")
            return "security_chamber"

        # Condition - Enter Acolyte chamber if all conditions are met
        if (self.getItemsCount("rift_hourglass_sand_stat_item") >
                aa_sand_threshold
                and self.getItemsCount("runic_string_cheese") > runic_threshold
                and self.isStatusEffectsActive("ng")
                and "acolyte_chamber" in portals):
            logger.info(self.environment,
                        "Acolyte Condiiton met, entering chamber")
            return "acolyte_chamber"

        # # Condition - Money is money
        # if 'lucky_chamber' in portals:
        #     # logger.info(self.environment, "Entering Lucky Chamber.")
        #     return 'lucky_chamber'

        # # Condition - Money is money
        # if 'treasury_chamber' in portals:
        #     # logger.info(self.environment, "Entering Treasury Chamber.")
        #     return 'treasury_chamber'

        # Condition - Don't get into timewarp if not enough runic cheese
        if ("timewarp_chamber" in portals
                and self.getItemsCount("rift_hourglass_sand_stat_item") <=
                aa_sand_threshold and self.getItemsCount("runic_string_cheese")
                > timewramp_runicRqd_thresdhold):
            logger.info(self.environment, "Gathering hourglass sand.")
            return "timewarp_chamber"

        # Condition - Don't get into timewarp if have enough time sand
        if ("timewarp_chamber" in portals
                and self.getItemsCount("rift_hourglass_sand_stat_item") >
                aa_sand_threshold):
            logger.info(self.environment,
                        "Removing timewarp due to sufficient time sand.")
            portals.remove("timewarp_chamber")

        # Condition - Get runic string cheese, but not too much
        if ("magic_chamber" in portals
                and self.getItemsCount("runic_string_cheese") <=
                runic_upper_threshold):
            logger.info(self.environment, "Gathering Runic cheese.")
            return "magic_chamber"

        # if 'potion_chamber' in portals:
        #     logger.info(self.environment, "Gathering Ancient String cheese.")
        #     return 'potion_chamber'

        if self.getItemsCount("rift_scramble_portals_stat_item") < 2:
            #     logger.info(self.environment, "Critically low portal scramblers.")
            initialPortals = list(set(self.getCurrentPortals()))
            #     if 'potion_charmber' in initialPortals:
            #         return 'potion_chamber'

            if "magic_chamber" in initialPortals:
                return "magic_chamber"

            return initialPortals[0]

        logger.info(self.environment, "No suitable portal, scrambling.")
        return None
 def logging(self, message):
     logger.info(
         self.environment,
         f"{message}",
     )