Search in sources :

Example 1 with R_get_universe_stations_station_id

use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id in project JCELechat by guiguilechat.

the class Universe method distancesOneConstelJump.

/**
 * get the distances to the sun of systems that are on the constellation, or
 * the adjacent constellations, of a station.
 *
 * @param stationId
 *          the id of the station
 * @return the map for each system to its tripdistance
 */
public Map<R_get_universe_systems_system_id, TripDistance> distancesOneConstelJump(int stationId) {
    R_get_universe_stations_station_id station = cache.stations(stationId).get();
    R_get_universe_systems_system_id system = cache.systems(station.system_id).get();
    List<R_get_universe_systems_system_id> destinations = systemsWithinOneConstelJump(system).collect(Collectors.toList());
    return destinations.parallelStream().collect(Collectors.toMap(sys -> sys, sys -> getDistance(station, sys).get()));
}
Also used : IntStream(java.util.stream.IntStream) R_get_universe_stations_station_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id) Accessors(lombok.experimental.Accessors) Getter(lombok.Getter) ObjHolderSimple(fr.lelouet.tools.holders.impl.ObjHolderSimple) HashMap(java.util.HashMap) ESIStatic(fr.guiguilechat.jcelechat.jcesi.disconnected.ESIStatic) MapHolder(fr.lelouet.tools.holders.interfaces.collections.MapHolder) R_get_universe_factions(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_factions) M_3_xnumber_ynumber_znumber(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.M_3_xnumber_ynumber_znumber) fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.flag(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.flag) Map(java.util.Map) R_get_universe_planets_planet_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_planets_planet_id) ListHolder(fr.lelouet.tools.holders.interfaces.collections.ListHolder) R_post_universe_names(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_post_universe_names) R_get_universe_stargates_stargate_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stargates_stargate_id) ObjHolder(fr.lelouet.tools.holders.interfaces.ObjHolder) R_get_universe_constellations_constellation_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_constellations_constellation_id) SetHolder(fr.lelouet.tools.holders.interfaces.collections.SetHolder) Collectors(java.util.stream.Collectors) Requested(fr.guiguilechat.jcelechat.jcesi.interfaces.Requested) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) R_get_universe_system_kills(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_system_kills) R_get_universe_systems_system_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_id) R_get_universe_systems_system_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_id) R_get_universe_stations_station_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id)

Example 2 with R_get_universe_stations_station_id

use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id in project JCELechat by guiguilechat.

the class NPCsTranslater method translate.

private static void translate(LinkedHashMap<Integer, Eagents> eagents, LinkedHashMap<String, Agent> agents, LinkedHashMap<String, Corporation> corporations, LinkedHashMap<Integer, LPOffer> offers) {
    ESIAccess esi = ESIAccess.INSTANCE;
    CacheStatic cache = ESIStatic.INSTANCE.cache();
    // prefetch
    MapHolder<Integer, R_get_corporations_corporation_id> corporationsHolder = ((ListHolder<Integer>) cache.corporations.npccorps().follow(l -> {
        l.parallelStream().forEach(cache.corporations::get);
    })).toMap(i -> i, i -> cache.corporations.get(i).get());
    MapHolder<Integer, R_get_universe_factions> factionsHolder = cache.universe.factions().toMap(f -> f.faction_id);
    eagents.values().parallelStream().map(ag -> ag.locationID).distinct().forEach(lid -> Location.resolve(null, lid).system());
    // 
    LinkedHashMap<Integer, EnpcCorporations> ecorps = EnpcCorporations.load();
    Map<Integer, String> idx2name = EinvNames.loadById();
    Map<Integer, R_get_corporations_corporation_id> npcCorps = corporationsHolder.get();
    Map<Integer, R_get_universe_factions> factionById = factionsHolder.get();
    Map<Integer, Location> agentsLocation = eagents.entrySet().parallelStream().collect(Collectors.toMap(eag -> eag.getKey(), eag -> Location.resolve(null, eag.getValue().locationID)));
    logger.info("NPC prefetch received");
    for (Entry<Integer, Eagents> eagt : eagents.entrySet()) {
        Agent agent = new Agent();
        Eagents agt = eagt.getValue();
        agent.id = eagt.getKey();
        agent.corporation = ecorps.get(agt.corporationID).enName();
        agent.name = idx2name.get(agent.id);
        agent.isLocator = agt.isLocator;
        agent.level = agt.level;
        agent.type = AGENT_TYPE.of(agt.agentTypeID);
        if (agent.type == null) {
            logger.warn("no type for agent " + agent.name + " typeID=" + agt.agentTypeID);
        }
        agent.division = AGENT_DIVISION.of(agt.divisionID);
        if (agent.division == null) {
            logger.warn("no division for agent " + agent.name + " divisionID=" + agt.divisionID);
        }
        Location loc = agentsLocation.get(agent.id);
        if (loc != null) {
            agent.system = loc.system().name;
            R_get_universe_stations_station_id station = loc.station();
            if (station != null) {
                agent.station = station.name;
                agent.stationId = agt.locationID;
            }
            agents.put(agent.name, agent);
        } else {
            logger.warn("invalid location for agent " + agent.name + " locid=" + agt.locationID);
        }
    }
    logger.info("translated agents data");
    for (Entry<Integer, EnpcCorporations> e : ecorps.entrySet()) {
        Corporation add = new Corporation();
        add.id = e.getKey();
        EnpcCorporations snpc = e.getValue();
        add.name = snpc.enName();
        R_get_universe_factions faction = factionById.get(snpc.factionID);
        if (faction == null) {
            logger.debug("can't find faction from id " + snpc.factionID + " for corporation " + add.name);
        } else {
            add.faction = faction.name;
        }
        R_get_corporations_corporation_id esicorp = npcCorps.get(add.id);
        if (esicorp != null && esicorp.faction_id != 0) {
            add.warfare = factionById.get(esicorp.faction_id).name;
        }
        add.concordRate = EnpcCorporations.concordRates().getOrDefault(add.id, 0.0);
        if (add.id == EnpcCorporations.CONCORD_ID) {
            add.concordRate = 1.0;
        }
        corporations.put(add.name, add);
    }
    Map<Integer, LPOffer> covertedOffers = corporations.values().stream().parallel().flatMap(c -> {
        Requested<R_get_loyalty_stores_corporation_id_offers[]> req = esi.connection.get_loyalty_stores_offers(c.id, null);
        return req.isOk() ? Stream.of(req.getOK()) : Stream.empty();
    }).map(offer -> makeOffer(offer)).filter(o -> o != null).collect(Collectors.toMap(off -> off.id, off -> off, (o1, o2) -> o1));
    offers.putAll(covertedOffers);
    corporations.values().stream().parallel().forEach(c -> loadCorpOffers(c, esi.connection, offers));
}
Also used : R_get_universe_stations_station_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id) ItemRef(fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer.ItemRef) FileTools(fr.guiguilechat.jcelechat.model.FileTools) Corporation(fr.guiguilechat.jcelechat.model.sde.npcs.Corporation) LoggerFactory(org.slf4j.LoggerFactory) AGENT_DIVISION(fr.guiguilechat.jcelechat.model.sde.npcs.Agent.AGENT_DIVISION) EinvNames(fr.guiguilechat.jcelechat.model.sde.load.bsd.EinvNames) ESIStatic(fr.guiguilechat.jcelechat.jcesi.disconnected.ESIStatic) Agent(fr.guiguilechat.jcelechat.model.sde.npcs.Agent) LPOffer(fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer) MapHolder(fr.lelouet.tools.holders.interfaces.collections.MapHolder) ESIAccess(fr.guiguilechat.jcelechat.jcesi.disconnected.modeled.ESIAccess) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Eblueprints(fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints) R_get_universe_factions(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_factions) Map(java.util.Map) ListHolder(fr.lelouet.tools.holders.interfaces.collections.ListHolder) Location(fr.guiguilechat.jcelechat.jcesi.tools.locations.Location) Material(fr.guiguilechat.jcelechat.model.sde.load.fsd.Eblueprints.Material) CacheStatic(fr.guiguilechat.jcelechat.jcesi.disconnected.CacheStatic) Collectors(java.util.stream.Collectors) File(java.io.File) R_get_loyalty_stores_corporation_id_offers(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_loyalty_stores_corporation_id_offers) AGENT_TYPE(fr.guiguilechat.jcelechat.model.sde.npcs.Agent.AGENT_TYPE) Eagents(fr.guiguilechat.jcelechat.model.sde.load.fsd.Eagents) Requested(fr.guiguilechat.jcelechat.jcesi.interfaces.Requested) Stream(java.util.stream.Stream) R_get_corporations_corporation_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_corporations_corporation_id) Entry(java.util.Map.Entry) EnpcCorporations(fr.guiguilechat.jcelechat.model.sde.load.fsd.EnpcCorporations) Comparator(java.util.Comparator) Collections(java.util.Collections) EtypeIDs(fr.guiguilechat.jcelechat.model.sde.load.fsd.EtypeIDs) Requested(fr.guiguilechat.jcelechat.jcesi.interfaces.Requested) R_get_corporations_corporation_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_corporations_corporation_id) R_get_loyalty_stores_corporation_id_offers(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_loyalty_stores_corporation_id_offers) R_get_universe_stations_station_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id) ListHolder(fr.lelouet.tools.holders.interfaces.collections.ListHolder) R_get_universe_factions(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_factions) CacheStatic(fr.guiguilechat.jcelechat.jcesi.disconnected.CacheStatic) EnpcCorporations(fr.guiguilechat.jcelechat.model.sde.load.fsd.EnpcCorporations) LPOffer(fr.guiguilechat.jcelechat.model.sde.npcs.LPOffer) Agent(fr.guiguilechat.jcelechat.model.sde.npcs.Agent) Corporation(fr.guiguilechat.jcelechat.model.sde.npcs.Corporation) ESIAccess(fr.guiguilechat.jcelechat.jcesi.disconnected.modeled.ESIAccess) Eagents(fr.guiguilechat.jcelechat.model.sde.load.fsd.Eagents) Location(fr.guiguilechat.jcelechat.jcesi.tools.locations.Location)

Example 3 with R_get_universe_stations_station_id

use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id in project JCELechat by guiguilechat.

the class Location method resolve.

/**
 * @see https://docs.esi.evetech.net/docs/asset_location_id
 */
public static Location resolve(ESIAccount account, long locationid) {
    if (locationid < Integer.MAX_VALUE) {
        R_get_universe_stations_station_id station;
        int prefix = (int) locationid / 1000000;
        switch(prefix) {
            case // region
            10:
                R_get_universe_regions_region_id region = ESIStatic.INSTANCE.cache().universe.regions((int) locationid).get();
                return new Location(region, locationid, region.name, LOCTYPE.REGION);
            case // constellation
            20:
                R_get_universe_constellations_constellation_id constel = ESIStatic.INSTANCE.cache().universe.constellations((int) locationid).get();
                return new Location(constel, locationid, constel.name, LOCTYPE.CONSTEL);
            case 30:
            case 31:
            case // system
            32:
                R_get_universe_systems_system_id system = ESIStatic.INSTANCE.cache().universe.systems((int) locationid).get();
                return new Location(system, locationid, system.name, LOCTYPE.SYSTEM);
            case 60:
            case 61:
            case 62:
            case 63:
            case // station
            64:
                station = ESIStatic.INSTANCE.cache().universe.stations((int) locationid).get();
                return new Location(station, locationid, station == null ? "missing" + locationid : station.name, LOCTYPE.STATION);
            case // office id
            66:
                station = ESIStatic.INSTANCE.cache().universe.stations((int) locationid - 6000001).get();
                return new Location(station, locationid, station == null ? "missing" + locationid : station.name, LOCTYPE.OFFICE);
            case // conquerable office
            67:
                station = ESIStatic.INSTANCE.cache().universe.stations((int) locationid - 6000000).get();
                return new Location(station, locationid, station == null ? "missing" + locationid : station.name, LOCTYPE.CONQSTATION);
            default:
                logger.warn("locationid not handled " + locationid + " prefix " + prefix);
                return new Location(null, locationid, "unknown" + locationid, LOCTYPE.STRUCTURE);
        }
    } else {
        // structures.
        if (ESIAccess.INSTANCE.universe.isPublicStructure(locationid)) {
        // can't do anything. stil need an account.
        }
        if (account != null) {
            Requested<R_get_universe_structures_structure_id> req = account.connection().get_universe_structures(locationid, null);
            if (req.isOk()) {
                R_get_universe_structures_structure_id struct = req.getOK();
                return new Location(struct, locationid, struct.name, LOCTYPE.STRUCTURE);
            }
        }
        return new Location(null, locationid, "unknown" + locationid, LOCTYPE.STRUCTURE);
    }
}
Also used : R_get_universe_regions_region_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_regions_region_id) R_get_universe_constellations_constellation_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_constellations_constellation_id) R_get_universe_systems_system_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_id) R_get_universe_structures_structure_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_structures_structure_id) R_get_universe_stations_station_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id)

Example 4 with R_get_universe_stations_station_id

use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id in project JCELechat by guiguilechat.

the class Universe method computeDistance.

/**
 * get the trip distance, from one station to the sun of a system
 *
 * @param systemOrigin
 * @param systemDest
 * @return the number of jumps and the total amount of UA to jump
 */
protected TripDistance computeDistance(R_get_universe_stations_station_id station, R_get_universe_systems_system_id destination) {
    TripDistance ret = new TripDistance();
    if (pochvenSystems == null) {
        synchronized (this) {
            if (pochvenSystems == null) {
                List<ObjHolder<R_get_universe_constellations_constellation_id>> constellations = IntStream.of(con.cache().universe.regions(10000070).get().constellations).mapToObj(c -> con.cache().universe.constellations(c)).collect(Collectors.toList());
                pochvenSystems = constellations.parallelStream().flatMapToInt(c -> IntStream.of(c.get().systems)).toArray();
                log.debug("pochven systems are " + IntStream.of(pochvenSystems).boxed().collect(Collectors.toList()));
            }
        }
    }
    List<R_get_universe_systems_system_id> systems = con.cache().route.get(pochvenSystems, null, destination.system_id, flag.secure, station.system_id).get().parallelStream().map(si -> cache.systems(si).get()).collect(Collectors.toList());
    M_3_xnumber_ynumber_znumber lastPos = station.position;
    R_get_universe_systems_system_id lastSys = cache.systems(station.system_id).get();
    // System.err.println("starting from " + station.name);
    for (R_get_universe_systems_system_id nextSys : systems) {
        if (nextSys.system_id == lastSys.system_id) {
            continue;
        }
        R_get_universe_systems_system_id flastSys = lastSys;
        R_get_universe_stargates_stargate_id nextGate = IntStream.of(lastSys.stargates).mapToObj(stargate -> cache.stargates(stargate).get()).filter(sg -> sg.destination.system_id == nextSys.system_id).findFirst().orElseThrow(() -> new RuntimeException("can't find gate from " + flastSys.name + " to " + nextSys.name));
        double dist_AU = distance(lastPos, nextGate.position) / M_PER_AU;
        // System.err.println("dist to " + nextSys.name + " is " + dist_AU);
        ret.AU += dist_AU;
        ret.jumps++;
        lastSys = nextSys;
        lastPos = cache.stargates(nextGate.destination.stargate_id).get().position;
    }
    double dist_AU = distance(lastPos, SUN_POS) / M_PER_AU;
    // System.err.println("dist to sun is " + dist_AU);
    ret.AU += dist_AU;
    return ret;
}
Also used : IntStream(java.util.stream.IntStream) R_get_universe_stations_station_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id) Accessors(lombok.experimental.Accessors) Getter(lombok.Getter) ObjHolderSimple(fr.lelouet.tools.holders.impl.ObjHolderSimple) HashMap(java.util.HashMap) ESIStatic(fr.guiguilechat.jcelechat.jcesi.disconnected.ESIStatic) MapHolder(fr.lelouet.tools.holders.interfaces.collections.MapHolder) R_get_universe_factions(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_factions) M_3_xnumber_ynumber_znumber(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.M_3_xnumber_ynumber_znumber) fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.flag(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.flag) Map(java.util.Map) R_get_universe_planets_planet_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_planets_planet_id) ListHolder(fr.lelouet.tools.holders.interfaces.collections.ListHolder) R_post_universe_names(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_post_universe_names) R_get_universe_stargates_stargate_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stargates_stargate_id) ObjHolder(fr.lelouet.tools.holders.interfaces.ObjHolder) R_get_universe_constellations_constellation_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_constellations_constellation_id) SetHolder(fr.lelouet.tools.holders.interfaces.collections.SetHolder) Collectors(java.util.stream.Collectors) Requested(fr.guiguilechat.jcelechat.jcesi.interfaces.Requested) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) R_get_universe_system_kills(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_system_kills) R_get_universe_systems_system_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_id) ObjHolder(fr.lelouet.tools.holders.interfaces.ObjHolder) R_get_universe_stargates_stargate_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stargates_stargate_id) R_get_universe_systems_system_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_id) M_3_xnumber_ynumber_znumber(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.M_3_xnumber_ynumber_znumber)

Aggregations

R_get_universe_stations_station_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id)4 ESIStatic (fr.guiguilechat.jcelechat.jcesi.disconnected.ESIStatic)3 Requested (fr.guiguilechat.jcelechat.jcesi.interfaces.Requested)3 R_get_universe_constellations_constellation_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_constellations_constellation_id)3 R_get_universe_factions (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_factions)3 R_get_universe_systems_system_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_id)3 ListHolder (fr.lelouet.tools.holders.interfaces.collections.ListHolder)3 MapHolder (fr.lelouet.tools.holders.interfaces.collections.MapHolder)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 Stream (java.util.stream.Stream)3 M_3_xnumber_ynumber_znumber (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.M_3_xnumber_ynumber_znumber)2 R_get_universe_planets_planet_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_planets_planet_id)2 R_get_universe_stargates_stargate_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stargates_stargate_id)2 R_get_universe_system_kills (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_system_kills)2 R_post_universe_names (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_post_universe_names)2 fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.flag (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.flag)2 ObjHolderSimple (fr.lelouet.tools.holders.impl.ObjHolderSimple)2 ObjHolder (fr.lelouet.tools.holders.interfaces.ObjHolder)2 SetHolder (fr.lelouet.tools.holders.interfaces.collections.SetHolder)2