Esempio n. 1
0
    def get_pokemon_slot_left(self):
        pokemon_count = inventory.Pokemons.get_space_used()

        if pokemon_count != self.last_pokemon_count:
            self.last_pokemon_count = pokemon_count
            self.logger.info("Pokemon Bag: %s / %s", pokemon_count, self.max_pokemon_storage)
            inventory.update_web_inventory()

        return inventory.Pokemons.get_space_left()
Esempio n. 2
0
    def get_pokemon_slot_left(self):
        pokemon_count = inventory.Pokemons.get_space_used()

        if pokemon_count != self.last_pokemon_count:
            self.last_pokemon_count = pokemon_count
            self.logger.info("Pokemon Bag: %s / %s", pokemon_count, self.max_pokemon_storage)
            inventory.update_web_inventory()

        return inventory.Pokemons.get_space_left()
Esempio n. 3
0
    def work(self):
        inventory.update_web_inventory()

        return WorkerResult.SUCCESS
 def work(self):
     inventory.update_web_inventory()
 def work(self):
     inventory.update_web_inventory()
    def work(self):
        if (not self.enabled) or (self.get_pokemon_slot_left() > 5):
            return WorkerResult.SUCCESS

        self.open_inventory()

        try_evolve_all = []
        try_upgrade_all = []
        keep_all = []

        for rule in self.config_keep:
            mode = rule.get("mode", "by_family")
            names = rule.get("names", [])
            whitelist_names, blacklist_names = self.get_colorlist_names(names)

            if mode == "by_pokemon":
                for pokemon_id, pokemon_list in self.group_by_pokemon_id(
                        inventory.pokemons().all()):
                    name = inventory.pokemons().name_for(pokemon_id)

                    if name in blacklist_names:
                        continue

                    if whitelist_names and (name not in whitelist_names):
                        continue

                    try_evolve, try_upgrade, keep = self.get_best_pokemon_for_rule(
                        pokemon_list, rule)
                    try_evolve_all += try_evolve
                    try_upgrade_all += try_upgrade
                    keep_all += keep
            elif mode == "by_family":
                for family_id, pokemon_list in self.group_by_family_id(
                        inventory.pokemons().all()):
                    matching_names = self.get_family_names(family_id)

                    if any(n in blacklist_names for n in matching_names):
                        continue

                    if whitelist_names and not any(n in whitelist_names
                                                   for n in matching_names):
                        continue

                    if family_id == 133:  # "Eevee"
                        try_evolve, try_upgrade, keep = self.get_multi_best_pokemon_for_rule(
                            pokemon_list, rule, 3)
                    else:
                        try_evolve, try_upgrade, keep = self.get_best_pokemon_for_rule(
                            pokemon_list, rule)

                    try_evolve_all += try_evolve
                    try_upgrade_all += try_upgrade
                    keep_all += keep
            elif mode == "overall":
                pokemon_list = []

                for pokemon in inventory.pokemons().all():
                    name = pokemon.name

                    if name in blacklist_names:
                        continue

                    if whitelist_names and (name not in whitelist_names):
                        continue

                    pokemon_list.append(pokemon)

                try_evolve, try_upgrade, keep = self.get_best_pokemon_for_rule(
                    pokemon_list, rule)
                try_evolve_all += try_evolve
                try_upgrade_all += try_upgrade
                keep_all += keep

        try_evolve_all = self.unique_pokemon_list(try_evolve_all)
        try_upgrade_all = self.unique_pokemon_list(try_upgrade_all)
        keep_all = self.unique_pokemon_list(keep_all)

        transfer_all = []
        evolve_all = []
        upgrade_all = []
        xp_all = []

        for family_id, pokemon_list in self.group_by_family_id(
                inventory.pokemons().all()):
            try_evolve = [
                p for p in try_evolve_all if self.get_family_id(p) == family_id
            ]
            try_upgrade = [
                p for p in try_upgrade_all
                if self.get_family_id(p) == family_id
            ]
            keep = [p for p in keep_all if self.get_family_id(p) == family_id]

            transfer, evolve, upgrade, xp = self.get_evolution_plan(
                family_id, pokemon_list, try_evolve, try_upgrade, keep)

            transfer_all += transfer
            evolve_all += evolve
            upgrade_all += upgrade
            xp_all += xp

        self.apply_optimization(transfer_all, evolve_all, upgrade_all, xp_all)
        inventory.update_web_inventory()

        return WorkerResult.SUCCESS