Search in sources :

Example 1 with R_get_universe_systems_system_id

use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_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_systems_system_id

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

the class ShowDeathPerShipRatio method main.

public static void main(String[] args) {
    CacheStatic cache = ESIStatic.INSTANCE.cache();
    for (Integer r : cache.universe.systems().get()) {
        cache.universe.systems(r);
    }
    MapHolder<Integer, R_get_universe_system_kills> kills = cache.universe.system_kills().toMap(sys -> sys.system_id);
    MapHolder<Integer, R_get_universe_system_jumps> jumps_m = cache.universe.system_jumps().toMap(sys -> sys.system_id);
    // useless because wh are not given their kill statistics
    Set<Integer> whconstels = IntStream.range(11000001, 11000033 + 1).parallel().mapToObj(r_i -> cache.universe.regions(r_i)).flatMapToInt(h -> IntStream.of(h.get().constellations)).mapToObj(i -> i).collect(Collectors.toSet());
    Set<Integer> abyssConstels = IntStream.range(12000001, 12000005 + 1).parallel().mapToObj(r_i -> cache.universe.regions(r_i)).flatMapToInt(h -> IntStream.of(h.get().constellations)).mapToObj(i -> i).collect(Collectors.toSet());
    // System.err.println("constel ids=" + whconstels);
    // HS, LS, NS, WH, abyssal
    String[] indexNames = { "HS", "LS", "NS", "WS", "abyss" };
    long[] npc_kills = new long[indexNames.length];
    long[] ship_kills = new long[indexNames.length];
    long[] jumps = new long[indexNames.length];
    int[] totalsystems = new int[indexNames.length];
    int[] nokills = new int[indexNames.length];
    int[] nojumps = new int[indexNames.length];
    int[] nokilljump = new int[indexNames.length];
    for (Integer sys_id : cache.universe.systems().get()) {
        R_get_universe_systems_system_id system = cache.universe.systems(sys_id).get();
        int index = 0;
        if (whconstels.contains(system.constellation_id)) {
            index = 3;
        } else if (abyssConstels.contains(system.constellation_id)) {
            index = 4;
        } else {
            index = system.security_status > 0.45 ? 0 : system.security_status > 0.0 ? 1 : 2;
        }
        R_get_universe_system_kills syskills = kills.get().get(system.system_id);
        if (syskills != null) {
            npc_kills[index] += syskills.npc_kills;
            ship_kills[index] += syskills.ship_kills;
        } else {
            nokills[index]++;
        }
        R_get_universe_system_jumps sysjumps = jumps_m.get().get(system.system_id);
        if (sysjumps != null) {
            jumps[index] += sysjumps.ship_jumps;
        } else {
            nojumps[index]++;
        }
        if (syskills == null && sysjumps == null) {
            nokilljump[index]++;
            nokills[index]--;
            nojumps[index]--;
        }
        totalsystems[index]++;
    }
    System.out.println("space\tship kills\tnpc kills\tjumps\tnpc / ship\tnpc / jumps\t#systems\tnokilldata\tnojumpdata\tnok&j");
    for (int i = 0; i < indexNames.length; i++) {
        System.out.println(indexNames[i] + "\t" + ship_kills[i] + "\t" + npc_kills[i] + "\t" + jumps[i] + "\t" + 1.0f * npc_kills[i] / ship_kills[i] + "\t" + 1.0f * npc_kills[i] / jumps[i] + "\t" + totalsystems[i] + "\t" + nokills[i] + "\t" + nojumps[i] + "\t" + nokilljump[i]);
    }
}
Also used : IntStream(java.util.stream.IntStream) R_get_universe_system_kills(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_system_kills) Set(java.util.Set) R_get_universe_systems_system_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_id) MapHolder(fr.lelouet.tools.holders.interfaces.collections.MapHolder) Collectors(java.util.stream.Collectors) R_get_universe_system_jumps(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_system_jumps) R_get_universe_system_jumps(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_system_jumps) R_get_universe_systems_system_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_id) R_get_universe_system_kills(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_system_kills)

Example 3 with R_get_universe_systems_system_id

use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_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_systems_system_id

use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_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_systems_system_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_id)4 R_get_universe_constellations_constellation_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_constellations_constellation_id)3 R_get_universe_stations_station_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id)3 R_get_universe_system_kills (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_system_kills)3 MapHolder (fr.lelouet.tools.holders.interfaces.collections.MapHolder)3 Collectors (java.util.stream.Collectors)3 IntStream (java.util.stream.IntStream)3 ESIStatic (fr.guiguilechat.jcelechat.jcesi.disconnected.ESIStatic)2 Requested (fr.guiguilechat.jcelechat.jcesi.interfaces.Requested)2 M_3_xnumber_ynumber_znumber (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.M_3_xnumber_ynumber_znumber)2 R_get_universe_factions (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_factions)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_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 ListHolder (fr.lelouet.tools.holders.interfaces.collections.ListHolder)2 SetHolder (fr.lelouet.tools.holders.interfaces.collections.SetHolder)2 HashMap (java.util.HashMap)2