Exemplo n.º 1
0
 def check_bonus(world: XNovaWorld):
     bonus_url = world.get_bonus_url()
     if bonus_url is not None:
         logger.info("Detected that bonus is available, get it!")
         world.signal(world.SIGNAL_GET_URL, url=bonus_url, referer="?set=overview")
         time.sleep(10)
         world.clear_bonus_url()
         time.sleep(2)
Exemplo n.º 2
0
 def check_bonus(world: XNovaWorld):
     bonus_url = world.get_bonus_url()
     if bonus_url is not None:
         logger.info('Detected that bonus is available, get it!')
         world.signal(world.SIGNAL_GET_URL,
                      url=bonus_url,
                      referer='?set=overview')
         time.sleep(10)
         world.clear_bonus_url()
         time.sleep(2)
Exemplo n.º 3
0
    def check_planet_buildings(world: XNovaWorld, planet: XNPlanet):
        # is there any building in progress on planet now?
        build_in_progress = False
        bitem = XNPlanetBuildingItem()
        for bitem_ in planet.buildings_items:
            if bitem_.is_in_progress():
                build_in_progress = True
                bitem = bitem_
                break
        if build_in_progress:
            logger.info(
                "Planet [{0}] has still build in progress {1} lv {2}".format(planet.name, bitem.name, bitem.level + 1)
            )
            return
        # no builds in progress, we can continue

        bitem = calc_planet_next_building(planet)
        if bitem is None:
            logger.error(
                "Planet [{0}]: for some reason could not calculate "
                "next building, some internal error? Try to relogin and "
                "refresh all world.".format(planet.name)
            )
            return

        logger.info("Planet [{0}] Next building will be: {1} lv {2}".format(planet.name, bitem.name, bitem.level + 1))
        logger.info(
            "Planet [{0}] Its price: {1}m {2}c {3}d".format(
                planet.name, bitem.cost_met, bitem.cost_cry, bitem.cost_deit
            )
        )
        logger.info(
            "Planet [{0}] We have: {1}m {2}c {3}d".format(
                planet.name, int(planet.res_current.met), int(planet.res_current.cry), int(planet.res_current.deit)
            )
        )
        # do we have enough resources to build it?
        if (
            (planet.res_current.met >= bitem.cost_met)
            and (planet.res_current.cry >= bitem.cost_cry)
            and (planet.res_current.deit >= bitem.cost_deit)
        ):
            logger.info("Planet [{0}] We have enough resources to build it, trigger!".format(planet.name))
            world.signal(world.SIGNAL_BUILD_ITEM, planet_id=planet.planet_id, bitem=bitem, quantity=0)
            logger.info(
                "Planet [{0}] Signal to build this item has been sent to world thread, wait 10s...".format(planet.name)
            )
            time.sleep(10)  # actually wait
        else:
            logger.warn(
                "Planet [{0}] We DO NOT have enough resources to build [{1} lv {2}]...".format(
                    planet.name, bitem.name, bitem.level + 1
                )
            )
Exemplo n.º 4
0
    def check_planet_buildings(world: XNovaWorld, planet: XNPlanet):
        # is there any building in progress on planet now?
        build_in_progress = False
        bitem = XNPlanetBuildingItem()
        for bitem_ in planet.buildings_items:
            if bitem_.is_in_progress():
                build_in_progress = True
                bitem = bitem_
                break
        if build_in_progress:
            logger.info(
                'Planet [{0}] has still build in progress {1} lv {2}'.format(
                    planet.name, bitem.name, bitem.level + 1))
            return
        # no builds in progress, we can continue

        bitem = calc_planet_next_building(planet)
        if bitem is None:
            logger.error(
                'Planet [{0}]: for some reason could not calculate '
                'next building, some internal error? Try to relogin and '
                'refresh all world.'.format(planet.name))
            return

        logger.info('Planet [{0}] Next building will be: {1} lv {2}'.format(
            planet.name, bitem.name, bitem.level + 1))
        logger.info('Planet [{0}] Its price: {1}m {2}c {3}d'.format(
            planet.name, bitem.cost_met, bitem.cost_cry, bitem.cost_deit))
        logger.info('Planet [{0}] We have: {1}m {2}c {3}d'.format(
            planet.name, int(planet.res_current.met),
            int(planet.res_current.cry), int(planet.res_current.deit)))
        # do we have enough resources to build it?
        if (planet.res_current.met >= bitem.cost_met) and \
                (planet.res_current.cry >= bitem.cost_cry) and \
                (planet.res_current.deit >= bitem.cost_deit):
            logger.info(
                'Planet [{0}] We have enough resources to build it, trigger!'.
                format(planet.name))
            world.signal(world.SIGNAL_BUILD_ITEM,
                         planet_id=planet.planet_id,
                         bitem=bitem,
                         quantity=0)
            logger.info(
                'Planet [{0}] Signal to build this item has been sent to world thread, wait 10s...'
                .format(planet.name))
            time.sleep(10)  # actually wait
        else:
            logger.warn(
                'Planet [{0}] We DO NOT have enough resources to build [{1} lv {2}]...'
                .format(planet.name, bitem.name, bitem.level + 1))