use of fr.lelouet.tools.holders.interfaces.ObjHolder in project JCELechat by guiguilechat.
the class ShowAttributes method showEntity.
public static void showEntity(R_get_universe_types_type_id type, String... filters) {
R_get_universe_groups_group_id group = ESIStatic.INSTANCE.cache().universe.groups(type.group_id).get();
R_get_universe_categories_category_id cat = ESIStatic.INSTANCE.cache().universe.categories(group.category_id).get();
System.out.println(type.name + "(" + type.type_id + ") group=" + group.name + "(" + group.group_id + ") category=" + cat.name + "(" + cat.category_id + ")");
Set<Integer> usedAttIds = new HashSet<>();
Map<Integer, Float> attIdToValue = Stream.of(type.dogma_attributes != null ? type.dogma_attributes : new get_dogma_dynamic_items_type_id_item_id_dogma_attributes[0]).collect(Collectors.toMap(att -> att.attribute_id, att -> att.value));
if (type.dogma_effects != null) {
List<ObjHolder<R_get_dogma_effects_effect_id>> effects = Stream.of(type.dogma_effects).map(eff -> ESIStatic.INSTANCE.cache().dogma.effects(eff.effect_id)).collect(Collectors.toList());
for (ObjHolder<R_get_dogma_effects_effect_id> h : effects) {
R_get_dogma_effects_effect_id e = h.get();
if (filters != null && filters.length != 0) {
// effect.
if (Stream.of(filters).filter(filter -> !e.name.toLowerCase().contains(filter.toLowerCase())).findAny().isPresent()) {
continue;
}
}
System.out.print("\t" + e.name + "(" + e.effect_id + ")" + "category=" + e.effect_category + " " + e.description);
List<String> flags = new ArrayList<>();
if (e.disallow_auto_repeat) {
flags.add("disallow_auto_repeat");
}
if (e.electronic_chance) {
flags.add("electronic_chance");
}
if (e.is_assistance) {
flags.add("is_assistance");
}
if (e.is_offensive) {
flags.add("is_offensive");
}
if (e.is_warp_safe) {
flags.add("is_warp_safe");
}
if (e.range_chance) {
flags.add("range_chance");
}
if (!flags.isEmpty()) {
System.out.println("[" + flags.stream().collect(Collectors.joining("|")) + "]");
} else {
System.out.println();
}
if (e.modifiers != null && e.modifiers.length != 0) {
for (get_dogma_effects_effect_id_modifiers m : e.modifiers) {
if (m.modified_attribute_id != 0 && m.modifying_attribute_id != 0) {
R_get_dogma_attributes_attribute_id modified = ESIStatic.INSTANCE.cache().dogma.attributes(m.modified_attribute_id).get();
usedAttIds.add(m.modifying_attribute_id);
System.out.println("\t\t\t" + m.func + " : " + m.domain + "." + modified.display_name + " " + getOperator(m.operator) + " " + getAttValue(attIdToValue, m.modifying_attribute_id));
}
}
}
if (e.range_attribute_id != 0) {
usedAttIds.add(e.range_attribute_id);
System.out.println("\t\trange(" + e.range_attribute_id + ")=" + printAttValue(attIdToValue, e.range_attribute_id));
}
if (e.falloff_attribute_id != 0) {
usedAttIds.add(e.falloff_attribute_id);
System.out.println("\t\tfalloff(" + e.falloff_attribute_id + ")=" + printAttValue(attIdToValue, e.falloff_attribute_id));
}
if (e.tracking_speed_attribute_id != 0) {
usedAttIds.add(e.tracking_speed_attribute_id);
System.out.println("\t\ttracking speed(" + e.tracking_speed_attribute_id + ")=" + printAttValue(attIdToValue, e.tracking_speed_attribute_id));
}
if (e.duration_attribute_id != 0) {
usedAttIds.add(e.duration_attribute_id);
System.out.println("\t\tduration(" + e.duration_attribute_id + ")=" + printAttValue(attIdToValue, e.duration_attribute_id));
}
if (e.discharge_attribute_id != 0) {
usedAttIds.add(e.discharge_attribute_id);
System.out.println("\t\tdischarge(" + e.discharge_attribute_id + ")=" + printAttValue(attIdToValue, e.discharge_attribute_id));
}
if (e.pre_expression != 0) {
System.out.println("\t\tpre=" + e.pre_expression);
}
if (e.post_expression != 0) {
System.out.println("\t\tpost=" + e.post_expression);
}
}
}
if (type.dogma_attributes != null) {
Stream.of(type.dogma_attributes).sorted((a1, a2) -> a1.attribute_id - a2.attribute_id).parallel().map(att -> {
R_get_dogma_attributes_attribute_id dogattr = ESIStatic.INSTANCE.cache().dogma.attributes(att.attribute_id).get();
if (filters != null) {
for (String filter : filters) {
if (filter != null && !dogattr.name.toLowerCase().contains(filter.toLowerCase())) {
return null;
}
}
}
if (usedAttIds.contains(att.attribute_id)) {
return null;
}
return "\t" + dogattr.name + "(" + att.attribute_id + ")=" + printAttValue(attIdToValue, att.attribute_id);
}).filter(s -> s != null).forEachOrdered(System.out::println);
}
}
use of fr.lelouet.tools.holders.interfaces.ObjHolder in project JCELechat by guiguilechat.
the class Universe method systemsWithinOneConstelJump.
/**
* stream over the system in one system constellation, or in neighbor
* constellations
*
* @param system
* @return a new stream.
*/
public Stream<R_get_universe_systems_system_id> systemsWithinOneConstelJump(R_get_universe_systems_system_id system) {
R_get_universe_constellations_constellation_id constel = cache.constellations(system.constellation_id).get();
List<ObjHolder<R_get_universe_systems_system_id>> systemsholders = adjacentConstels(constel).flatMapToInt(co -> IntStream.of(co.systems)).mapToObj(cache::systems).collect(Collectors.toList());
return systemsholders.parallelStream().map(sh -> sh.get());
}
use of fr.lelouet.tools.holders.interfaces.ObjHolder in project JCELechat by guiguilechat.
the class ShowFrigateTracking method main.
public static void main(String[] args) {
boolean showdetails = false;
R_get_universe_categories_category_id catEntities = ESIAccess.INSTANCE.universe.cache().categories(11).get();
List<ObjHolder<R_get_universe_groups_group_id>> groupholders = IntStream.of(catEntities.groups).mapToObj(gid -> ESIAccess.INSTANCE.universe.cache().groups(gid)).collect(Collectors.toList());
List<R_get_universe_groups_group_id> groups = groupholders.stream().map(ObjHolder::get).collect(Collectors.toList());
List<ObjHolder<R_get_universe_types_type_id>> typeHolders = groups.stream().flatMap(g -> IntStream.of(g.types).mapToObj(tid -> ESIAccess.INSTANCE.universe.cache().types(tid))).collect(Collectors.toList());
List<R_get_universe_types_type_id> types = typeHolders.stream().map(ObjHolder::get).collect(Collectors.toList());
Collections.sort(types, (t1, t2) -> t1 == null || t2 == null ? 0 : t1.name.compareTo(t2.name));
System.out.println("name\ttracking20km\ttracking50km\ttracking80km" + (showdetails ? "\tspeed\tsig\torbit" : ""));
for (R_get_universe_types_type_id t : types) {
if (t == null || t.radius > 80 || t.dogma_attributes == null) {
continue;
}
float speed = 0;
float orbit = 0;
for (get_dogma_dynamic_items_type_id_item_id_dogma_attributes att : t.dogma_attributes) {
if (att.attribute_id == 51) {
speed = att.value;
}
if (att.attribute_id == 416) {
orbit = att.value;
}
}
if (speed <= 0) {
// System.err.println("skip " + t.name + " for small speed");
continue;
}
if (orbit <= 0) {
// System.err.println("skip " + t.name + " for small orbit");
continue;
}
float t20 = speed * orbit / 20000 / 20000 * 40000 / t.radius;
float t50 = speed * orbit / 50000 / 50000 * 40000 / t.radius;
float t80 = speed * orbit / 80000 / 80000 * 40000 / t.radius;
System.out.println(t.name + "\t" + t20 + "\t" + t50 + "\t" + t80 + (showdetails ? "\t" + speed + "\t" + t.radius + "\t" + orbit : ""));
}
}
use of fr.lelouet.tools.holders.interfaces.ObjHolder in project JCELechat by guiguilechat.
the class EveCharacter method getStanding.
public ObjHolder<Float> getStanding(int id) {
ObjHolder<Float> ret = cacheStanding.get(id);
if (ret == null) {
MapHolder<Integer, M_get_standings_3> std = getStandings();
synchronized (cacheStanding) {
ret = cacheStanding.get(id);
if (ret == null) {
ret = std.at(id, new M_get_standings_3()).map(m -> m.standing);
cacheStanding.put(id, ret);
}
}
}
return ret;
}
use of fr.lelouet.tools.holders.interfaces.ObjHolder 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;
}
Aggregations