Search in sources :

Example 1 with Location

use of fr.guiguilechat.jcelechat.jcesi.tools.locations.Location in project JCELechat by guiguilechat.

the class Universe method location.

public Location location(long locationid) {
    Location ret = cachedLocationSystems.get(locationid);
    if (ret == null) {
        synchronized (cachedLocationSystems) {
            ret = cachedLocationSystems.get(locationid);
            if (ret == null) {
                ret = Location.resolve(parent, locationid);
                cachedLocationSystems.put(locationid, ret);
            }
        }
    }
    return ret;
}
Also used : Location(fr.guiguilechat.jcelechat.jcesi.tools.locations.Location)

Example 2 with Location

use of fr.guiguilechat.jcelechat.jcesi.tools.locations.Location in project JCELechat by guiguilechat.

the class Markets method getLocalMarket.

/**
 * get a pricing for a specific location id. If the locationd id is a region,
 * will get the market for that region. If a system, will get the market for
 * that system. If a structure or station, will get the market for that one.
 *
 * @param locationId
 * @return
 */
public IPricing getLocalMarket(long locationId) {
    // if a region : get the regional market.
    if (locationId >= 10000000l && locationId < 12000000l) {
        return getMarket((int) locationId);
    }
    IPricing lm = localMarket.get(locationId);
    if (lm == null) {
        synchronized (localMarket) {
            lm = localMarket.get(locationId);
            if (lm == null) {
                Location loc = Location.resolve(null, locationId);
                RegionalMarket rm = getMarket(loc.region().region_id);
                lm = rm.filter((int) locationId, 0, false);
                localMarket.put(locationId, lm);
            }
        }
    }
    return lm;
}
Also used : IPricing(fr.guiguilechat.jcelechat.jcesi.disconnected.modeled.market.IPricing) RegionalMarket(fr.guiguilechat.jcelechat.jcesi.disconnected.modeled.market.RegionalMarket) Location(fr.guiguilechat.jcelechat.jcesi.tools.locations.Location)

Example 3 with Location

use of fr.guiguilechat.jcelechat.jcesi.tools.locations.Location in project JCELechat by guiguilechat.

the class Assets method grow.

protected ItemForest grow(List<R_get_corporations_corporation_id_assets> assets) {
    ItemForest ret = new ItemForest();
    for (R_get_corporations_corporation_id_assets item : assets) {
        ret.itemsByID.put(item.item_id, new ItemNode(item));
    }
    // fetch the names
    name(ret.itemsByID);
    // place the items in the roots.
    for (ItemNode itemNode : ret.itemsByID.values()) {
        ItemNode parent = ret.itemsByID.get(itemNode.location_id);
        if (parent == null) {
            Location location = Location.resolve(con, itemNode.location_id);
            ret.roots.computeIfAbsent(location, loc -> new HashMap<>()).computeIfAbsent(itemNode.location_flag, f -> new ArrayList<>()).add(itemNode);
        } else {
            parent.contained.computeIfAbsent(itemNode.location_flag, f -> new ArrayList<>()).add(itemNode);
        }
    }
    return ret;
}
Also used : Arrays(java.util.Arrays) fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag) Hangar(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.Hangar) Getter(lombok.Getter) HashMap(java.util.HashMap) MapHolder(fr.lelouet.tools.holders.interfaces.collections.MapHolder) R_get_corporations_corporation_id_assets(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_corporations_corporation_id_assets) Impounded(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.Impounded) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Map(java.util.Map) ListHolder(fr.lelouet.tools.holders.interfaces.collections.ListHolder) StreamSupport(java.util.stream.StreamSupport) Location(fr.guiguilechat.jcelechat.jcesi.tools.locations.Location) CorpDeliveries(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.CorpDeliveries) Locked(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.Locked) AutoFit(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.AutoFit) DroneBay(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.DroneBay) ObjHolder(fr.lelouet.tools.holders.interfaces.ObjHolder) ShipHangar(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.ShipHangar) ItemForest(fr.guiguilechat.jcelechat.jcesi.connected.modeled.character.Assets.ItemForest) Unlocked(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.Unlocked) Set(java.util.Set) Collectors(java.util.stream.Collectors) Requested(fr.guiguilechat.jcelechat.jcesi.interfaces.Requested) List(java.util.List) Stream(java.util.stream.Stream) ESIAccount(fr.guiguilechat.jcelechat.jcesi.connected.modeled.ESIAccount) HangarAll(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.HangarAll) M_post_assets_names_2(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.M_post_assets_names_2) CorpSAG7(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.CorpSAG7) Entry(java.util.Map.Entry) CorpSAG6(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.CorpSAG6) CorpSAG5(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.CorpSAG5) ItemNode(fr.guiguilechat.jcelechat.jcesi.connected.modeled.character.Assets.ItemNode) CorpSAG4(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.CorpSAG4) CorpSAG3(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.CorpSAG3) CorpSAG2(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.CorpSAG2) Deliveries(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.Deliveries) CorpSAG1(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag.CorpSAG1) ItemNode(fr.guiguilechat.jcelechat.jcesi.connected.modeled.character.Assets.ItemNode) R_get_corporations_corporation_id_assets(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_corporations_corporation_id_assets) ItemForest(fr.guiguilechat.jcelechat.jcesi.connected.modeled.character.Assets.ItemForest) ArrayList(java.util.ArrayList) Location(fr.guiguilechat.jcelechat.jcesi.tools.locations.Location)

Example 4 with Location

use of fr.guiguilechat.jcelechat.jcesi.tools.locations.Location in project JCELechat by guiguilechat.

the class Assets method grow.

protected ItemForest grow(List<R_get_characters_character_id_assets> assets) {
    ItemForest ret = new ItemForest();
    for (R_get_characters_character_id_assets item : assets) {
        ret.itemsByID.put(item.item_id, new ItemNode(item));
    }
    // fetch the names
    name(ret.itemsByID);
    // place the items in the roots.
    for (ItemNode itemNode : ret.itemsByID.values()) {
        ItemNode parent = ret.itemsByID.get(itemNode.location_id);
        if (parent == null) {
            Location location = Location.resolve(con, itemNode.location_id);
            ret.roots.computeIfAbsent(location, loc -> new HashMap<>()).computeIfAbsent(itemNode.location_flag, f -> new ArrayList<>()).add(itemNode);
        } else {
            parent.contained.computeIfAbsent(itemNode.location_flag, f -> new ArrayList<>()).add(itemNode);
        }
    }
    return ret;
}
Also used : Arrays(java.util.Arrays) fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag) Accessors(lombok.experimental.Accessors) fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_characters_character_id_assets_location_type(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_characters_character_id_assets_location_type) Getter(lombok.Getter) R_get_universe_types_type_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_types_type_id) AutoFit(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_characters_character_id_assets_location_flag.AutoFit) RequiredArgsConstructor(lombok.RequiredArgsConstructor) fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_type(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_type) HashMap(java.util.HashMap) R_get_characters_character_id_assets(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_characters_character_id_assets) MapHolder(fr.lelouet.tools.holders.interfaces.collections.MapHolder) R_get_corporations_corporation_id_assets(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_corporations_corporation_id_assets) ESIAccess(fr.guiguilechat.jcelechat.jcesi.disconnected.modeled.ESIAccess) ShipHangar(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_characters_character_id_assets_location_flag.ShipHangar) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Deliveries(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_characters_character_id_assets_location_flag.Deliveries) Map(java.util.Map) HangarAll(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_characters_character_id_assets_location_flag.HangarAll) Unlocked(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_characters_character_id_assets_location_flag.Unlocked) ListHolder(fr.lelouet.tools.holders.interfaces.collections.ListHolder) StreamSupport(java.util.stream.StreamSupport) Location(fr.guiguilechat.jcelechat.jcesi.tools.locations.Location) ObjHolder(fr.lelouet.tools.holders.interfaces.ObjHolder) Collectors(java.util.stream.Collectors) Requested(fr.guiguilechat.jcelechat.jcesi.interfaces.Requested) List(java.util.List) Stream(java.util.stream.Stream) ESIAccount(fr.guiguilechat.jcelechat.jcesi.connected.modeled.ESIAccount) M_post_assets_names_2(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.M_post_assets_names_2) Entry(java.util.Map.Entry) Locked(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_characters_character_id_assets_location_flag.Locked) Hangar(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_characters_character_id_assets_location_flag.Hangar) fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_characters_character_id_assets_location_flag(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_characters_character_id_assets_location_flag) R_get_characters_character_id_assets(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_characters_character_id_assets) ArrayList(java.util.ArrayList) Location(fr.guiguilechat.jcelechat.jcesi.tools.locations.Location)

Example 5 with Location

use of fr.guiguilechat.jcelechat.jcesi.tools.locations.Location 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)

Aggregations

Location (fr.guiguilechat.jcelechat.jcesi.tools.locations.Location)5 Requested (fr.guiguilechat.jcelechat.jcesi.interfaces.Requested)3 ListHolder (fr.lelouet.tools.holders.interfaces.collections.ListHolder)3 MapHolder (fr.lelouet.tools.holders.interfaces.collections.MapHolder)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Entry (java.util.Map.Entry)3 Collectors (java.util.stream.Collectors)3 Stream (java.util.stream.Stream)3 ESIAccount (fr.guiguilechat.jcelechat.jcesi.connected.modeled.ESIAccount)2 ESIAccess (fr.guiguilechat.jcelechat.jcesi.disconnected.modeled.ESIAccess)2 M_post_assets_names_2 (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.M_post_assets_names_2)2 R_get_corporations_corporation_id_assets (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_corporations_corporation_id_assets)2 fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.get_corporations_corporation_id_assets_location_flag)2 ObjHolder (fr.lelouet.tools.holders.interfaces.ObjHolder)2 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 StreamSupport (java.util.stream.StreamSupport)2