use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_types_type_id in project JCELechat by guiguilechat.
the class TypeAttributesController method attribute.
@RequestMapping(value = "/attribute/{attId}", produces = MediaType.APPLICATION_XML_VALUE)
public String attribute(@PathVariable int attId, int... typeIds) {
R_get_dogma_attributes_attribute_id attr = ESIStatic.INSTANCE.cache().dogma.attributes(attId).get();
if (attr == null) {
return "invalid attribute";
}
if (typeIds != null) {
for (int typeId : typeIds) {
ESIStatic.INSTANCE.cache().universe.types(typeId);
}
}
StringBuilder sb = new StringBuilder("<attribute id=\"" + attId + "\" name=\"" + attr.name + "\">\n");
if (typeIds != null) {
for (int typeId : typeIds) {
float value = attr.default_value;
R_get_universe_types_type_id type = ESIStatic.INSTANCE.cache().universe.types(typeId).get();
if (type != null && type.dogma_attributes != null) {
for (get_dogma_dynamic_items_type_id_item_id_dogma_attributes att : type.dogma_attributes) {
if (att.attribute_id == attId) {
value = att.value;
break;
}
}
}
sb.append("<type id=\"" + typeId + "\">").append("<value>").append(value).append("</value></type>\n");
}
}
sb.append("</attribute>");
return sb.toString();
}
use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_types_type_id in project JCELechat by guiguilechat.
the class ShowTank method showEntity.
public static void showEntity(String nameFilter, int typeId) {
R_get_universe_types_type_id type = ESIStatic.INSTANCE.cache().universe.types(typeId).get();
if (nameFilter != null && !type.name.matches(nameFilter)) {
return;
}
R_get_universe_groups_group_id group = ESIStatic.INSTANCE.cache().universe.groups(type.group_id).get();
Map<Integer, Double> 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 -> (double) att.value));
// shield
double shieldEMResonnance = attIdToValue.getOrDefault(271, 1.0);
double shieldTHResonnance = attIdToValue.getOrDefault(274, 1.0);
double shieldKIResonnance = attIdToValue.getOrDefault(273, 1.0);
double shieldEXResonnance = attIdToValue.getOrDefault(272, 1.0);
double shieldHP = attIdToValue.getOrDefault(263, 0.0);
// armor
double armorEMResonnance = attIdToValue.getOrDefault(267, 1.0);
double armorTHResonnance = attIdToValue.getOrDefault(270, 1.0);
double armorKIResonnance = attIdToValue.getOrDefault(269, 1.0);
double armorEXResonnance = attIdToValue.getOrDefault(268, 1.0);
double armorHP = attIdToValue.getOrDefault(265, 0.0);
// hull
double hullEMResonnance = attIdToValue.getOrDefault(113, 1.0);
double hullTHResonnance = attIdToValue.getOrDefault(110, 1.0);
double hullKIResonnance = attIdToValue.getOrDefault(109, 1.0);
double hullEXResonnance = attIdToValue.getOrDefault(111, 1.0);
double hullHP = attIdToValue.getOrDefault(9, 0.0);
// total ehp
double EMEHP = shieldHP / shieldEMResonnance + armorHP / armorEMResonnance + hullHP / hullEMResonnance;
double THEHP = shieldHP / shieldTHResonnance + armorHP / armorTHResonnance + hullHP / hullTHResonnance;
double KIEHP = shieldHP / shieldKIResonnance + armorHP / armorKIResonnance + hullHP / hullKIResonnance;
double EXEHP = shieldHP / shieldEXResonnance + armorHP / armorEXResonnance + hullHP / hullEXResonnance;
System.out.println(type.name + "\t" + typeId + "\t" + group.name + "\t" + nf.format(EMEHP) + "\t" + nf.format(THEHP) + "\t" + nf.format(KIEHP) + "\t" + nf.format(EXEHP));
}
use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_types_type_id in project JCELechat by guiguilechat.
the class TypeGrouper method semantic.
public int semantic(int typeid) {
if (!semantics.containsKey(typeid)) {
synchronized (semantics) {
if (!semantics.containsKey(typeid)) {
R_get_universe_types_type_id type = access.universe.types(typeid).get();
R_get_universe_types_type_id sem = semantic(type);
semantics.put(typeid, sem.type_id);
return sem.type_id;
}
}
}
return semantics.get(typeid);
}
use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_types_type_id in project JCELechat by guiguilechat.
the class TypeGrouper method semantic.
private R_get_universe_types_type_id semantic(R_get_universe_types_type_id type) {
// replace a bp by its type
R_get_universe_types_type_id product = type;
if (BPGROUPS.contains(type.group_id)) {
fr.guiguilechat.jcelechat.model.sde.industry.Blueprint bp = fr.guiguilechat.jcelechat.model.sde.industry.Blueprint.of(type.type_id);
product = access.universe.types(bp.manufacturing.products.get(0).id).get();
}
Map<Integer, Double> atts = new HashMap<>();
atts.put(0, (double) product.group_id);
if (product.dogma_attributes == null) {
atts.put(-1, (double) product.type_id);
} else {
for (get_dogma_dynamic_items_type_id_item_id_dogma_attributes att : product.dogma_attributes) {
atts.put(att.attribute_id, (double) att.value);
}
}
Set<R_get_universe_types_type_id> set = semantic2Types.computeIfAbsent(atts, o -> new LinkedHashSet<>());
set.add(type);
return set.iterator().next();
}
use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_types_type_id 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);
}
}
Aggregations