Ejemplo n.º 1
0
def handle_interfaces_mismatch():
    """
    Handle cases when AI and universe generation interfaces mismatch.
    """

    try:
        import freeorion as fo

        universe = fo.get_universe()
        empire_of_first_ai = fo.get_empire(2)
        galaxy_data = fo.get_galaxy_setup_data()
        return fo, universe, empire_of_first_ai, galaxy_data
    except ImportError:
        pass

    try:
        import freeOrionAIInterface as fo

        universe = fo.getUniverse()
        empire_of_first_ai = fo.getEmpire(2)
        galaxy_data = fo.getGalaxySetupData()
        return fo, universe, empire_of_first_ai, galaxy_data

    except ImportError:
        pass
Ejemplo n.º 2
0
def inspect_universe_generation_interface(*args, **kwargs):
    import freeorion as fo
    tech = fo.getTech('LRN_NASCENT_AI')
    universe = fo.get_universe()
    empire = fo.get_empire(1)
    rules = fo.getGameRules()
    ship_hull = fo.getShipHull('SH_XENTRONIUM')
    species = fo.getSpecies('SP_ABADDONI')
    generate_stub(
        fo,
        instances=[
            fo.getFieldType('FLD_ION_STORM'),
            fo.getBuildingType('BLD_SHIPYARD_BASE'),
            ship_hull,
            ship_hull.slots,
            fo.getShipPart('SR_WEAPON_1_1'),
            fo.getSpecial('MODERATE_TECH_NATIVES_SPECIAL'),
            species,
            fo.diplomaticMessage(1, 2,
                                 fo.diplomaticMessageType.acceptPeaceProposal),
            rules,
            tech,
            tech.unlockedItems,
            universe,
            universe.effectAccounting,
            universe.buildingIDs,
            fo.get_galaxy_setup_data(),
            empire,
            empire.colour,
            empire.productionQueue,
            empire.researchQueue,
        ],
        classes_to_ignore=(
            'IntBoolMap',
            'IntDblMap',
            'IntFltMap',
            'IntIntMap',
            'IntPairVec',
            'IntSetSet',
            'MeterTypeAccountingInfoVecMap',
            'MeterTypeMeterMap',
            'MeterTypeStringPair',
            'MonsterFleetPlan',
            'PairIntInt_IntMap',
            'RuleValueStringStringPair',
            'ShipPartMeterMap',
            'VisibilityIntMap',
            'AccountingInfoVec',
            'IntSet',
            'StringSet',
            'StringVec',
        ),
        path=".",
        dump=False,
    )
def inspect_universe_generation_interface(*args, **kwargs):
    import freeorion as fo
    universe = fo.get_universe()

    # this field should be visible to AI
    empire_of_first_ai = fo.get_empire(2)  # first AI
    fo.create_field_in_system(
        "FLD_NEBULA_1", 100,
        universe.getPlanet(empire_of_first_ai.capitalID).systemID)
    instances = list(get_item_with_location(get_common_instances()))

    generate_stub(
        fo,
        instances=instances,
        classes_to_ignore=classes_to_exclude_from_universe,
        path=".",
        dump=False,
    )
def inspect_universe_generation_interface(*args, **kwargs):
    import freeorion as fo
    tech = fo.getTech('LRN_ARTIF_MINDS')
    universe = fo.get_universe()
    empire = fo.get_empire(1)
    rules = fo.getGameRules()
    hull_type = fo.getHullType('SH_XENTRONIUM')
    species = fo.getSpecies('SP_ABADDONI')
    inspect(
        fo,
        instances=[
            fo.getFieldType('FLD_ION_STORM'),
            fo.getBuildingType('BLD_SHIPYARD_BASE'),
            hull_type,
            hull_type.slots,
            fo.getPartType('SR_WEAPON_1_1'),
            fo.getSpecial('MODERATE_TECH_NATIVES_SPECIAL'),
            species,
            fo.diplomaticMessage(1, 2, fo.diplomaticMessageType.acceptPeaceProposal),
            rules,
            tech,
            tech.unlockedItems,
            rules.getRulesAsStrings,
            universe,
            universe.effectAccounting,
            universe.buildingIDs,
            fo.get_galaxy_setup_data(),
            empire,
            empire.colour,
            empire.productionQueue,
            empire.researchQueue,
        ],
        classes_to_ignore=(
            'IntBoolMap', 'IntDblMap', 'IntFltMap', 'IntIntMap', 'IntPairVec', 'IntSetSet',
            'MeterTypeAccountingInfoVecMap', 'MeterTypeMeterMap', 'MeterTypeStringPair', 'MonsterFleetPlan',
            'PairIntInt_IntMap', 'RuleValueStringStringPair', 'ShipPartMeterMap', 'VisibilityIntMap',
            'AccountingInfoVec', 'IntSet', 'StringSet', 'StringVec',
        ),
        path=".",
    )
Ejemplo n.º 5
0
def inspect_universe_generation():
    """
    Inspect function for universe generation interface.

    We have no way to run it without modifying of game code.

    To generate interface
    put call before return section of universe_generation.universe_generator.create_universe function
    """
    import freeorion as fo
    techs = fo.techs()
    universe = fo.get_universe()
    planet_ids = universe.planetIDs

    system_ids = universe.systemIDs
    system = universe.getSystem(system_ids[0])

    building_ids = universe.buildingIDs
    building = universe.getBuilding(building_ids[0])
    empire_ids = fo.get_all_empires()
    empire = fo.get_empire(empire_ids[0])
    fields_ids = universe.fieldIDs
    field = universe.getField(fields_ids[0])

    fleets_ids = universe.fleetIDs
    fleet = universe.getFleet(fleets_ids[0])
    tech = fo.getTech(techs[0])
    unlocked_items = tech.unlockedItems

    ship = universe.getShip(list(fleet.shipIDs)[0])
    # meter = ship.getMeter(fo.meterType.maxFuel)

    design = ship.design

    universe_object = universe.getObject(universe.systemIDs[0])

    # fo.getHullType ?

    species = None
    special = None
    planets = [universe.getPlanet(pid) for pid in planet_ids]
    for planet in planets:
        species_name = planet.speciesName
        if species_name:
            species = fo.getSpecies(species_name)
        specials = list(planet.specials)
        if specials:
            special = fo.getSpecial(specials[0])

    inspect(
        fo,
        instances=[
            fo.get_galaxy_setup_data(),
            universe,
            planet_ids,
            universe.getPlanet(planet_ids[0]),
            system,
            techs,
            tech,
            tech.unlockedTechs,
            building,
            fo.getBuildingType(building.buildingTypeName),
            empire,
            field,
            fo.getFieldType(field.fieldTypeName),
            fleet,
            ship,
            # meter,
            design,
            fleet.shipIDs,  # int set wtf?
            universe_object,
            system.starlanesWormholes,
            empire.systemSupplyRanges,
            empire.supplyProjections(),
            empire.obstructedStarlanes(),
            empire.planetsWithWastedPP,
            unlocked_items,
            species,
            special
        ],
        classes_to_ignore=(
            'FleetPlan', 'GGColor', 'MonsterFleetPlan', 'PlayerSetupData', 'ShipPartMeterMap', 'ShipSlotVec',
            'VisibilityIntMap', 'diplomaticMessage', 'diplomaticStatusUpdate', 'meter',
        ),
        path=''
    )
    # fo.sys_get_star_type(system),
    # fo.planet_get_size(pid),
    # fo.planet_get_type(planet),
    # fo.species_get_planet_environment(species, planet_type),
    # fo.species_preferred_focus(species),

    # fo.getBuildingType(string)
    # fo.getFieldType(string)
    # fo.getHullType(string)
    # fo.getPartType(string)
    # fo.getShipDesign(number)
    # fo.getSpecial(string)
    # fo.getSpecies(string)
    # fo.getTech(string)
    # fo.getTechCategories(obj)
    # fo.get_empire(number)
    # fo.planet_get_species(number)
    # fo.techsInCategory(string)
    exit(1)
Ejemplo n.º 6
0
def inspect_universe_generation():
    """
    Inspect function for universe generation interface.

    We have no way to run it without modifying of game code.

    To generate interface
    put call before return section of universe_generation.universe_generator.create_universe function
    """
    import freeorion as fo
    techs = fo.techs()
    universe = fo.get_universe()
    planet_ids = universe.planetIDs

    system_ids = universe.systemIDs
    system = universe.getSystem(system_ids[0])

    building_ids = universe.buildingIDs
    building = universe.getBuilding(building_ids[0])
    empire_ids = fo.get_all_empires()
    empire = fo.get_empire(empire_ids[0])
    fields_ids = universe.fieldIDs
    field = universe.getField(fields_ids[0])

    fleets_ids = universe.fleetIDs
    fleet = universe.getFleet(fleets_ids[0])
    tech = fo.getTech(techs[0])
    unlocked_items = tech.unlockedItems

    ship = universe.getShip(list(fleet.shipIDs)[0])
    # meter = ship.getMeter(fo.meterType.maxFuel)

    design = ship.design

    universe_object = universe.getObject(universe.systemIDs[0])

    # fo.getHullType ?

    species = None
    special = None
    planets = [universe.getPlanet(pid) for pid in planet_ids]
    for planet in planets:
        species_name = planet.speciesName
        if species_name:
            species = fo.getSpecies(species_name)
        specials = list(planet.specials)
        if specials:
            special = fo.getSpecial(specials[0])

    inspect(
        fo,
        instances=[
            fo.get_galaxy_setup_data(),
            universe,
            planet_ids,
            universe.getPlanet(planet_ids[0]),
            system,
            techs,
            tech,
            tech.unlockedTechs,
            building,
            fo.getBuildingType(building.buildingTypeName),
            empire,
            field,
            fo.getFieldType(field.fieldTypeName),
            fleet,
            ship,
            # meter,
            design,
            fleet.shipIDs,  # int set wtf?
            universe_object,
            system.starlanesWormholes,
            empire.systemSupplyRanges,
            empire.supplyProjections(),
            empire.obstructedStarlanes(),
            empire.planetsWithWastedPP,
            unlocked_items,
            species,
            special
        ],
        classes_to_ignore=(
            'FleetPlan',
            'GGColor',
            'MonsterFleetPlan',
            'PlayerSetupData',
            'ShipPartMeterMap',
            'ShipSlotVec',
            'VisibilityIntMap',
            'diplomaticMessage',
            'diplomaticStatusUpdate',
            'meter',
        ),
        path='')
    # fo.sys_get_star_type(system),
    # fo.planet_get_size(pid),
    # fo.planet_get_type(planet),
    # fo.species_get_planet_environment(species, planet_type),
    # fo.species_preferred_focus(species),

    # fo.getBuildingType(string)
    # fo.getFieldType(string)
    # fo.getHullType(string)
    # fo.getShipPart(string)
    # fo.getShipDesign(number)
    # fo.getSpecial(string)
    # fo.getSpecies(string)
    # fo.getTech(string)
    # fo.getTechCategories(obj)
    # fo.get_empire(number)
    # fo.planet_get_species(number)
    # fo.techsInCategory(string)
    exit(1)