示例#1
0
def plan_construction(interface, empire):
    logger.debug('### plan construction')
    source = empire.capital
    construct_on_capital = len(empire) > 1
    while True:
        planet, construct = empire.idles.cheapest(construct_on_capital)
        if not planet:
            logger.info("No eligible planet for construction")
            break

        cost = construct.cost
        logger.info("Willing to construct %s on %s for %s", construct, planet,
                    cost.movable)

        if source.resources.movable < cost.movable:
            logger.info("Not enough resources on %s (having %s)", source,
                        source.resources.movable)
            break
        if source.fleet.capacity < cost.movable.total:
            logger.info("Fleet capacity too low on %s (able to move %s)",
                        source, source.fleet.capacity)
            break

        logger.warning('Sending resources to construct %s on %s', construct,
                       planet)
        travel_id = transport(interface,
                              empire,
                              source,
                              planet,
                              resources=cost)

        planet.waiting_for[travel_id] = construct.name
示例#2
0
文件: civil.py 项目: jaesivsm/pyogame
def plan_construction(interface, empire):
    logger.debug('### plan construction')
    source = empire.capital
    construct_on_capital = len(empire) > 1
    while True:
        planet, construct = empire.idles.cheapest(construct_on_capital)
        if not planet:
            logger.info("No eligible planet for construction")
            break

        cost = construct.cost
        logger.info("Willing to construct %s on %s for %s",
                    construct, planet, cost.movable)

        if source.resources.movable < cost.movable:
            logger.info("Not enough resources on %s (having %s)",
                        source, source.resources.movable)
            break
        if source.fleet.capacity < cost.movable.total:
            logger.info("Fleet capacity too low on %s (able to move %s)",
                        source, source.fleet.capacity)
            break

        logger.warning('Sending resources to construct %s on %s',
                    construct, planet)
        travel_id = transport(interface, empire,
                            source, planet, resources=cost)

        planet.waiting_for[travel_id] = construct.name
示例#3
0
def rapatriate(interface, empire, destination=None):
    logger.debug('### rapatriate')
    if not destination and empire.capital:
        destination = empire.capital
    assert destination, "Empire has no capital " \
            "and no destination has been provided"
    logger.info('Launching rapatriation to %s', destination)
    for source in empire:
        if destination is source:
            continue
        if not source.fleet:
            logger.info('no fleet on %s', source)
            continue
        if float(source.resources.total) / source.fleet.capacity < 2. / 3 \
                and not source.is_metal_tank_full \
                and not source.is_crystal_tank_full \
                and not source.is_deuterium_tank_full:
            logger.info('not enough resources on %s to bother repatriating',
                        source)
            continue
        transport(interface, empire, source, destination, all_ships=True)
示例#4
0
文件: civil.py 项目: jaesivsm/pyogame
def rapatriate(interface, empire, destination=None):
    logger.debug('### rapatriate')
    if not destination and empire.capital:
        destination = empire.capital
    assert destination, "Empire has no capital " \
            "and no destination has been provided"
    logger.info('Launching rapatriation to %s', destination)
    for source in empire:
        if destination is source:
            continue
        if not source.fleet:
            logger.info('no fleet on %s', source)
            continue
        if float(source.resources.total) / source.fleet.capacity < 2. / 3 \
                and not source.is_metal_tank_full \
                and not source.is_crystal_tank_full \
                and not source.is_deuterium_tank_full:
            logger.info('not enough resources on %s to bother repatriating',
                        source)
            continue
        transport(interface, empire, source, destination, all_ships=True)
示例#5
0
文件: civil.py 项目: jaesivsm/pyogame
def rapatriate(destination=None):
    logger.debug("### rapatriate")
    empire = Factory().empire
    if not destination and empire.capital:
        destination = empire.capital
    assert destination, "Empire has no capital " "and no destination has been provided"
    logger.info("Launching rapatriation to %s", destination)
    for source in empire:
        if destination is source:
            continue
        if not source.fleet:
            logger.info("no fleet on %s" % source)
            continue
        if (
            float(source.resources.total) / source.fleet.capacity < 2.0 / 3
            and not source.is_metal_tank_full
            and not source.is_crystal_tank_full
            and not source.is_deuterium_tank_full
        ):
            logger.info("not enough resources on %s to bother repatriating", source)
            continue
        transport(source, destination, all_ships=True)
示例#6
0
文件: civil.py 项目: jaesivsm/pyogame
def plan_construction():
    logger.debug("### plan construction")
    empire = Factory().empire
    source = empire.capital
    while True:
        planet = empire.idles.cheapest
        if not planet:
            logger.info("No eligible planet for construction")
            break
        cost = planet.to_construct.cost
        logger.info("Willing to construct %s on %s for %s", planet.to_construct, planet, cost.movable)

        if source.resources.movable < cost.movable:
            logger.info("Not enough ressources on %s (having %s)", source, source.resources.movable)
            break
        if source.fleet.capacity < cost.movable.total:
            logger.info("Fleet capacity too low on %s (able to move %s)", source, source.fleet.capacity)
            break

        logger.warn("Sending resources to construct %s on %s", planet.to_construct, planet)
        travel_id = transport(source, planet, resources=cost)

        planet.waiting_for[travel_id] = planet.to_construct.name