implement parser EDCE
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
package ru.trader.controllers;
|
||||||
|
|
||||||
|
public class RouteSearchController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
fx:id="mainPane"
|
fx:id="mainPane"
|
||||||
>
|
>
|
||||||
<top>
|
<top>
|
||||||
|
<VBox>
|
||||||
<MenuBar>
|
<MenuBar>
|
||||||
<Menu text="%main.menu.file">
|
<Menu text="%main.menu.file">
|
||||||
<MenuItem text="%main.menu.file.save" onAction="#save"/>
|
<MenuItem text="%main.menu.file.save" onAction="#save"/>
|
||||||
@@ -43,6 +44,8 @@
|
|||||||
<Menu fx:id="langs" text="%main.menu.settings.language"/>
|
<Menu fx:id="langs" text="%main.menu.settings.language"/>
|
||||||
</Menu>
|
</Menu>
|
||||||
</MenuBar>
|
</MenuBar>
|
||||||
|
<fx:include fx:id="prof" source="profile.fxml"/>
|
||||||
|
</VBox>
|
||||||
</top>
|
</top>
|
||||||
<center>
|
<center>
|
||||||
<TabPane tabClosingPolicy="UNAVAILABLE" BorderPane.alignment="CENTER">
|
<TabPane tabClosingPolicy="UNAVAILABLE" BorderPane.alignment="CENTER">
|
||||||
|
|||||||
40
client/src/main/resources/view/profile.fxml
Normal file
40
client/src/main/resources/view/profile.fxml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
<?import ru.trader.view.support.cells.OfferListCell?>
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import ru.trader.view.support.NumberField?>
|
||||||
|
<HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:controller="ru.trader.controllers.ProfileController"
|
||||||
|
spacing="4" >
|
||||||
|
<Label text="Имя:" />
|
||||||
|
<TextField fx:id="name" />
|
||||||
|
<Label text="Баланс:" />
|
||||||
|
<NumberField fx:id="balance" />
|
||||||
|
<Label text="Система:" />
|
||||||
|
<TextField fx:id="systemText" />
|
||||||
|
<Button fx:id="btnAddSystem"/>
|
||||||
|
<Label text="Станция:" />
|
||||||
|
<ComboBox fx:id="station" />
|
||||||
|
<Button fx:id="btnAddStation"/>
|
||||||
|
<VBox>
|
||||||
|
<HBox>
|
||||||
|
<Label text="Трюм:" />
|
||||||
|
<NumberField fx:id="cargo" />
|
||||||
|
</HBox>
|
||||||
|
<HBox>
|
||||||
|
<Label text="Топливный бак:" />
|
||||||
|
<NumberField fx:id="tank" />
|
||||||
|
</HBox>
|
||||||
|
<HBox>
|
||||||
|
<Label text="Масса:" />
|
||||||
|
<NumberField fx:id="mass" />
|
||||||
|
</HBox>
|
||||||
|
<HBox>
|
||||||
|
<Label text="Двигатель:" />
|
||||||
|
<ComboBox fx:id="engine" />
|
||||||
|
</HBox>
|
||||||
|
</VBox>
|
||||||
|
</HBox>
|
||||||
40
client/src/main/resources/view/routeSearch.fxml
Normal file
40
client/src/main/resources/view/routeSearch.fxml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
<?import ru.trader.view.support.cells.OfferListCell?>
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import ru.trader.view.support.NumberField?>
|
||||||
|
<HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:controller="ru.trader.controllers.RouteSearchController"
|
||||||
|
spacing="4" >
|
||||||
|
<Label text="Имя:" />
|
||||||
|
<TextField fx:id="name" />
|
||||||
|
<Label text="Баланс:" />
|
||||||
|
<NumberField fx:id="balance" />
|
||||||
|
<Label text="Система:" />
|
||||||
|
<TextField fx:id="systemText" />
|
||||||
|
<Button fx:id="btnAddSystem"/>
|
||||||
|
<Label text="Станция:" />
|
||||||
|
<ComboBox fx:id="station" />
|
||||||
|
<Button fx:id="btnAddStation"/>
|
||||||
|
<VBox>
|
||||||
|
<HBox>
|
||||||
|
<Label text="Трюм:" />
|
||||||
|
<NumberField fx:id="cargo" />
|
||||||
|
</HBox>
|
||||||
|
<HBox>
|
||||||
|
<Label text="Топливный бак:" />
|
||||||
|
<NumberField fx:id="tank" />
|
||||||
|
</HBox>
|
||||||
|
<HBox>
|
||||||
|
<Label text="Масса:" />
|
||||||
|
<NumberField fx:id="mass" />
|
||||||
|
</HBox>
|
||||||
|
<HBox>
|
||||||
|
<Label text="Двигатель:" />
|
||||||
|
<ComboBox fx:id="engine" />
|
||||||
|
</HBox>
|
||||||
|
</VBox>
|
||||||
|
</HBox>
|
||||||
6
pom.xml
6
pom.xml
@@ -15,6 +15,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<jdk.version>1.8</jdk.version>
|
<jdk.version>1.8</jdk.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<jackson.version>2.6.0</jackson.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
@@ -89,6 +90,11 @@
|
|||||||
<artifactId>jzmq</artifactId>
|
<artifactId>jzmq</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>${jackson.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,10 @@
|
|||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient</artifactId>
|
||||||
<version>4.5</version>
|
<version>4.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
123
utils/src/main/java/ru/trader/edce/Converter.java
Normal file
123
utils/src/main/java/ru/trader/edce/Converter.java
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
package ru.trader.edce;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Converter {
|
||||||
|
|
||||||
|
private final static Map<Long, String> ITEM_ID = new HashMap<>(85, 0.9f);
|
||||||
|
private final static Map<String, String> GROUP_ID = new HashMap<>(10, 0.9f);
|
||||||
|
|
||||||
|
static {
|
||||||
|
ITEM_ID.put(128049204L, "explosives");
|
||||||
|
ITEM_ID.put(128049202L, "hydrogenfuel");
|
||||||
|
ITEM_ID.put(128049203L, "mineraloil");
|
||||||
|
ITEM_ID.put(128049205L, "pesticides");
|
||||||
|
ITEM_ID.put(128049241L, "clothing");
|
||||||
|
ITEM_ID.put(128049240L, "consumertechnology");
|
||||||
|
ITEM_ID.put(128049238L, "domesticappliances");
|
||||||
|
ITEM_ID.put(128049177L, "algae");
|
||||||
|
ITEM_ID.put(128049182L, "animalmeat");
|
||||||
|
ITEM_ID.put(128049189L, "coffee");
|
||||||
|
ITEM_ID.put(128049183L, "fish");
|
||||||
|
ITEM_ID.put(128049184L, "foodcartridges");
|
||||||
|
ITEM_ID.put(128049178L, "fruitandvegetables");
|
||||||
|
ITEM_ID.put(128049180L, "grain");
|
||||||
|
ITEM_ID.put(128049185L, "syntheticmeat");
|
||||||
|
ITEM_ID.put(128049188L, "tea");
|
||||||
|
ITEM_ID.put(128049197L, "polymers");
|
||||||
|
ITEM_ID.put(128049199L, "semiconductors");
|
||||||
|
ITEM_ID.put(128049200L, "superconductors");
|
||||||
|
ITEM_ID.put(128049214L, "beer");
|
||||||
|
ITEM_ID.put(128049216L, "liquor");
|
||||||
|
ITEM_ID.put(128049212L, "basicnarcotics");
|
||||||
|
ITEM_ID.put(128049213L, "tobacco");
|
||||||
|
ITEM_ID.put(128049215L, "wine");
|
||||||
|
ITEM_ID.put(128064028L, "atmosphericprocessors");
|
||||||
|
ITEM_ID.put(128049222L, "cropharvesters");
|
||||||
|
ITEM_ID.put(128049223L, "marinesupplies");
|
||||||
|
ITEM_ID.put(128049220L, "microbialfurnaces");
|
||||||
|
ITEM_ID.put(128049221L, "mineralextractors");
|
||||||
|
ITEM_ID.put(128049217L, "powergenerators");
|
||||||
|
ITEM_ID.put(128049218L, "waterpurifiers");
|
||||||
|
ITEM_ID.put(128049208L, "agriculturalmedicines");
|
||||||
|
ITEM_ID.put(128049210L, "basicmedicines");
|
||||||
|
ITEM_ID.put(128049670L, "combatstabilisers");
|
||||||
|
ITEM_ID.put(128049209L, "performanceenhancers");
|
||||||
|
ITEM_ID.put(128049669L, "progenitorcells");
|
||||||
|
ITEM_ID.put(128049176L, "aluminium");
|
||||||
|
ITEM_ID.put(128049168L, "beryllium");
|
||||||
|
ITEM_ID.put(128049162L, "cobalt");
|
||||||
|
ITEM_ID.put(128049175L, "copper");
|
||||||
|
ITEM_ID.put(128049170L, "gallium");
|
||||||
|
ITEM_ID.put(128049154L, "gold");
|
||||||
|
ITEM_ID.put(128049169L, "indium");
|
||||||
|
ITEM_ID.put(128049173L, "lithium");
|
||||||
|
ITEM_ID.put(128671118L, "osmium");
|
||||||
|
ITEM_ID.put(128049153L, "palladium");
|
||||||
|
ITEM_ID.put(128049152L, "platinum");
|
||||||
|
ITEM_ID.put(128049155L, "silver");
|
||||||
|
ITEM_ID.put(128049171L, "tantalum");
|
||||||
|
ITEM_ID.put(128049174L, "titanium");
|
||||||
|
ITEM_ID.put(128049172L, "uranium");
|
||||||
|
ITEM_ID.put(128049165L, "bauxite");
|
||||||
|
ITEM_ID.put(128049156L, "bertrandite");
|
||||||
|
ITEM_ID.put(128049159L, "coltan");
|
||||||
|
ITEM_ID.put(128049158L, "gallite");
|
||||||
|
ITEM_ID.put(128049157L, "indite");
|
||||||
|
ITEM_ID.put(128049161L, "lepidolite");
|
||||||
|
ITEM_ID.put(128668550L, "painite");
|
||||||
|
ITEM_ID.put(128049163L, "rutile");
|
||||||
|
ITEM_ID.put(128049160L, "uraninite");
|
||||||
|
ITEM_ID.put(128667728L, "imperialslaves");
|
||||||
|
ITEM_ID.put(128066403L, ""); // Drones
|
||||||
|
ITEM_ID.put(128671443L, "sap8corecontainer");
|
||||||
|
ITEM_ID.put(128049231L, "advancedcatalysers");
|
||||||
|
ITEM_ID.put(128049229L, "animalmonitors");
|
||||||
|
ITEM_ID.put(128049230L, "aquaponicsystems");
|
||||||
|
ITEM_ID.put(128049228L, "autofabricators");
|
||||||
|
ITEM_ID.put(128049672L, "bioreducinglichen");
|
||||||
|
ITEM_ID.put(128049225L, "computercomponents");
|
||||||
|
ITEM_ID.put(128049226L, "hazardousenvironmentsuits");
|
||||||
|
ITEM_ID.put(128049671L, "resonatingseparators");
|
||||||
|
ITEM_ID.put(128049227L, "robotics");
|
||||||
|
ITEM_ID.put(128049232L, "landenrichmentsystems");
|
||||||
|
ITEM_ID.put(128049190L, "leather");
|
||||||
|
ITEM_ID.put(128049191L, "naturalfabrics");
|
||||||
|
ITEM_ID.put(128049193L, "syntheticfabrics");
|
||||||
|
ITEM_ID.put(128049244L, "biowaste");
|
||||||
|
ITEM_ID.put(128049246L, "chemicalwaste");
|
||||||
|
ITEM_ID.put(128049248L, "scrap");
|
||||||
|
ITEM_ID.put(128049234L, "battleweapons");
|
||||||
|
ITEM_ID.put(128049236L, "nonlethalweapons");
|
||||||
|
ITEM_ID.put(128049233L, "personalweapons");
|
||||||
|
ITEM_ID.put(128049235L, "reactivearmour");
|
||||||
|
|
||||||
|
GROUP_ID.put("Chemicals", "chemicals");
|
||||||
|
GROUP_ID.put("Consumer Items", "consumer_items");
|
||||||
|
GROUP_ID.put("Foods", "foods");
|
||||||
|
GROUP_ID.put("Industrial Materials", "engineered_ceramics"); // Polymers
|
||||||
|
GROUP_ID.put("Machinery", "machinery");
|
||||||
|
GROUP_ID.put("Medicines", "medicines");
|
||||||
|
GROUP_ID.put("Metals", "metals");
|
||||||
|
GROUP_ID.put("Minerals", "minerals");
|
||||||
|
GROUP_ID.put("Narcotics", "drugs");
|
||||||
|
GROUP_ID.put("NonMarketable", ""); // Drones
|
||||||
|
GROUP_ID.put("Salvage", "salvage"); // S A P8 Core Container
|
||||||
|
GROUP_ID.put("Slaves", "slaves");
|
||||||
|
GROUP_ID.put("Technology", "technology"); // Aquaponic Systems
|
||||||
|
GROUP_ID.put("Textiles", "textiles");
|
||||||
|
GROUP_ID.put("Waste ", "waste");
|
||||||
|
GROUP_ID.put("Weapons", "weapons");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getItemId(long edId){
|
||||||
|
return ITEM_ID.get(edId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getGroupId(String edName){
|
||||||
|
return GROUP_ID.get(edName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
19
utils/src/main/java/ru/trader/edce/EDCEParser.java
Normal file
19
utils/src/main/java/ru/trader/edce/EDCEParser.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package ru.trader.edce;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import ru.trader.edce.entities.EDPacket;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class EDCEParser {
|
||||||
|
|
||||||
|
|
||||||
|
public static EDPacket parseJSON(String json) throws IOException {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
return mapper.readValue(json, EDPacket.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
22
utils/src/main/java/ru/trader/edce/entities/Cargo.java
Normal file
22
utils/src/main/java/ru/trader/edce/entities/Cargo.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package ru.trader.edce.entities;
|
||||||
|
|
||||||
|
public class Cargo {
|
||||||
|
private int capacity;
|
||||||
|
private int qty;
|
||||||
|
|
||||||
|
public int getCapacity() {
|
||||||
|
return capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCapacity(int capacity) {
|
||||||
|
this.capacity = capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getQty() {
|
||||||
|
return qty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQty(int qty) {
|
||||||
|
this.qty = qty;
|
||||||
|
}
|
||||||
|
}
|
||||||
32
utils/src/main/java/ru/trader/edce/entities/Commander.java
Normal file
32
utils/src/main/java/ru/trader/edce/entities/Commander.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package ru.trader.edce.entities;
|
||||||
|
|
||||||
|
public class Commander {
|
||||||
|
private String name;
|
||||||
|
private long credits;
|
||||||
|
private boolean docked;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCredits() {
|
||||||
|
return credits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCredits(long credits) {
|
||||||
|
this.credits = credits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDocked() {
|
||||||
|
return docked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDocked(boolean docked) {
|
||||||
|
this.docked = docked;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
86
utils/src/main/java/ru/trader/edce/entities/Commodity.java
Normal file
86
utils/src/main/java/ru/trader/edce/entities/Commodity.java
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
package ru.trader.edce.entities;
|
||||||
|
|
||||||
|
|
||||||
|
public class Commodity {
|
||||||
|
private long id;
|
||||||
|
private String name;
|
||||||
|
private long buyPrice;
|
||||||
|
private long sellPrice;
|
||||||
|
private int demandBracket;
|
||||||
|
private int stockBracket;
|
||||||
|
private long stock;
|
||||||
|
private long demand;
|
||||||
|
private String categoryname;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBuyPrice() {
|
||||||
|
return buyPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBuyPrice(long buyPrice) {
|
||||||
|
this.buyPrice = buyPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSellPrice() {
|
||||||
|
return sellPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSellPrice(long sellPrice) {
|
||||||
|
this.sellPrice = sellPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDemandBracket() {
|
||||||
|
return demandBracket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDemandBracket(int demandBracket) {
|
||||||
|
this.demandBracket = demandBracket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStockBracket() {
|
||||||
|
return stockBracket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStockBracket(int stockBracket) {
|
||||||
|
this.stockBracket = stockBracket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStock() {
|
||||||
|
return stockBracket != 0 ? stock : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStock(long stock) {
|
||||||
|
this.stock = stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getDemand() {
|
||||||
|
return demandBracket != 0 ? demand : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDemand(long demand) {
|
||||||
|
this.demand = demand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategoryname() {
|
||||||
|
return categoryname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryname(String categoryname) {
|
||||||
|
this.categoryname = categoryname;
|
||||||
|
}
|
||||||
|
}
|
||||||
40
utils/src/main/java/ru/trader/edce/entities/EDPacket.java
Normal file
40
utils/src/main/java/ru/trader/edce/entities/EDPacket.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package ru.trader.edce.entities;
|
||||||
|
|
||||||
|
public class EDPacket {
|
||||||
|
private Commander commander;
|
||||||
|
private System lastSystem;
|
||||||
|
private Starport lastStarport;
|
||||||
|
private Ship ship;
|
||||||
|
|
||||||
|
public Commander getCommander() {
|
||||||
|
return commander;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommander(Commander commander) {
|
||||||
|
this.commander = commander;
|
||||||
|
}
|
||||||
|
|
||||||
|
public System getLastSystem() {
|
||||||
|
return lastSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastSystem(System lastSystem) {
|
||||||
|
this.lastSystem = lastSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Starport getLastStarport() {
|
||||||
|
return lastStarport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastStarport(Starport lastStarport) {
|
||||||
|
this.lastStarport = lastStarport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ship getShip() {
|
||||||
|
return ship;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShip(Ship ship) {
|
||||||
|
this.ship = ship;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
utils/src/main/java/ru/trader/edce/entities/Fuel.java
Normal file
22
utils/src/main/java/ru/trader/edce/entities/Fuel.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package ru.trader.edce.entities;
|
||||||
|
|
||||||
|
public class Fuel {
|
||||||
|
private double capacity;
|
||||||
|
private double lvl;
|
||||||
|
|
||||||
|
public double getCapacity() {
|
||||||
|
return capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCapacity(double capacity) {
|
||||||
|
this.capacity = capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getLvl() {
|
||||||
|
return lvl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLvl(double lvl) {
|
||||||
|
this.lvl = lvl;
|
||||||
|
}
|
||||||
|
}
|
||||||
40
utils/src/main/java/ru/trader/edce/entities/Module.java
Normal file
40
utils/src/main/java/ru/trader/edce/entities/Module.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package ru.trader.edce.entities;
|
||||||
|
|
||||||
|
public class Module {
|
||||||
|
private long id;
|
||||||
|
private String category;
|
||||||
|
private String name;
|
||||||
|
private long cost;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategory(String category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCost() {
|
||||||
|
return cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCost(long cost) {
|
||||||
|
this.cost = cost;
|
||||||
|
}
|
||||||
|
}
|
||||||
73
utils/src/main/java/ru/trader/edce/entities/Ship.java
Normal file
73
utils/src/main/java/ru/trader/edce/entities/Ship.java
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package ru.trader.edce.entities;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Ship {
|
||||||
|
private String name;
|
||||||
|
private Fuel fuel;
|
||||||
|
private Cargo cargo;
|
||||||
|
private Map<String, Slot> modules = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Fuel getFuel() {
|
||||||
|
return fuel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFuel(Fuel fuel) {
|
||||||
|
this.fuel = fuel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cargo getCargo() {
|
||||||
|
return cargo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCargo(Cargo cargo) {
|
||||||
|
this.cargo = cargo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Slot> getModules() {
|
||||||
|
return modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModules(Map<String, Slot> modules) {
|
||||||
|
this.modules = modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public double getFuelLvl(){
|
||||||
|
return fuel != null ? fuel.getLvl() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public double getFuelCapacity(){
|
||||||
|
return fuel != null ? fuel.getCapacity() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public int getCargoCapacity(){
|
||||||
|
return cargo != null ? cargo.getCapacity() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public int getCargoLimit(){
|
||||||
|
return cargo != null ? cargo.getCapacity() - cargo.getQty() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Module getFSD(){
|
||||||
|
if (modules == null) return null;
|
||||||
|
Slot fsd = modules.get("FrameShiftDrive");
|
||||||
|
return fsd != null ? fsd.getModule() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package ru.trader.edce.entities;
|
||||||
|
|
||||||
|
public class ShipyardItem {
|
||||||
|
private long id;
|
||||||
|
private String name;
|
||||||
|
private long basevalue;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBasevalue() {
|
||||||
|
return basevalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBasevalue(long basevalue) {
|
||||||
|
this.basevalue = basevalue;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
utils/src/main/java/ru/trader/edce/entities/Slot.java
Normal file
13
utils/src/main/java/ru/trader/edce/entities/Slot.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package ru.trader.edce.entities;
|
||||||
|
|
||||||
|
public class Slot {
|
||||||
|
private Module module;
|
||||||
|
|
||||||
|
public Module getModule() {
|
||||||
|
return module;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModule(Module module) {
|
||||||
|
this.module = module;
|
||||||
|
}
|
||||||
|
}
|
||||||
54
utils/src/main/java/ru/trader/edce/entities/Starport.java
Normal file
54
utils/src/main/java/ru/trader/edce/entities/Starport.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package ru.trader.edce.entities;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Starport {
|
||||||
|
private long id;
|
||||||
|
private String name;
|
||||||
|
private String faction;
|
||||||
|
private List<Commodity> commodities = new ArrayList<>();
|
||||||
|
private Map<String, Module> modules = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFaction() {
|
||||||
|
return faction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFaction(String faction) {
|
||||||
|
this.faction = faction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Commodity> getCommodities() {
|
||||||
|
return commodities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommodities(List<Commodity> commodities) {
|
||||||
|
this.commodities = commodities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Module> getModules() {
|
||||||
|
return modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModules(Map<String, Module> modules) {
|
||||||
|
this.modules = modules;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
utils/src/main/java/ru/trader/edce/entities/System.java
Normal file
31
utils/src/main/java/ru/trader/edce/entities/System.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package ru.trader.edce.entities;
|
||||||
|
|
||||||
|
public class System {
|
||||||
|
private long id;
|
||||||
|
private String name;
|
||||||
|
private String faction;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFaction() {
|
||||||
|
return faction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFaction(String faction) {
|
||||||
|
this.faction = faction;
|
||||||
|
}
|
||||||
|
}
|
||||||
170
utils/src/test/java/ru/trader/edce/ParseTest.java
Normal file
170
utils/src/test/java/ru/trader/edce/ParseTest.java
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
package ru.trader.edce;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import ru.trader.edce.entities.*;
|
||||||
|
import ru.trader.edce.entities.System;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ParseTest extends Assert {
|
||||||
|
private final static Logger LOG = LoggerFactory.getLogger(EDSessionDemo.class);
|
||||||
|
|
||||||
|
private String read(InputStream is){
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))){
|
||||||
|
while ((line = reader.readLine()) != null){
|
||||||
|
if (builder.length() > 0){
|
||||||
|
builder.append("\n");
|
||||||
|
}
|
||||||
|
builder.append(line);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.error("Error on read file", e);
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParse() throws Exception {
|
||||||
|
LOG.info("Test parse json");
|
||||||
|
InputStream is = getClass().getResourceAsStream("/edce/edce.json");
|
||||||
|
String json = read(is);
|
||||||
|
LOG.trace("Parse json:");
|
||||||
|
LOG.trace("{}", json);
|
||||||
|
EDPacket packet = EDCEParser.parseJSON(json);
|
||||||
|
Commander commander = packet.getCommander();
|
||||||
|
assertNotNull(commander);
|
||||||
|
assertEquals("MoHax", commander.getName());
|
||||||
|
assertEquals(13882052, commander.getCredits());
|
||||||
|
assertTrue(commander.isDocked());
|
||||||
|
System system = packet.getLastSystem();
|
||||||
|
assertNotNull(system);
|
||||||
|
assertEquals(65179, system.getId());
|
||||||
|
assertEquals("Ennead", system.getName());
|
||||||
|
assertEquals("Federation", system.getFaction());
|
||||||
|
Starport starport = packet.getLastStarport();
|
||||||
|
assertNotNull(starport);
|
||||||
|
assertEquals(3223840768L, starport.getId());
|
||||||
|
assertEquals("Watt Ring", starport.getName());
|
||||||
|
assertEquals("Federation", starport.getFaction());
|
||||||
|
List<Commodity> commodities = starport.getCommodities();
|
||||||
|
assertTrue(!commodities.isEmpty());
|
||||||
|
Commodity commodity = commodities.get(0);
|
||||||
|
assertEquals(128049202L, commodity.getId());
|
||||||
|
assertEquals("Hydrogen Fuel", commodity.getName());
|
||||||
|
assertEquals(0, commodity.getBuyPrice());
|
||||||
|
assertEquals(152, commodity.getSellPrice());
|
||||||
|
assertEquals(0, commodity.getStockBracket());
|
||||||
|
assertEquals(2, commodity.getDemandBracket());
|
||||||
|
assertEquals(0, commodity.getStock());
|
||||||
|
assertEquals(659426, commodity.getDemand());
|
||||||
|
assertEquals("Chemicals", commodity.getCategoryname());
|
||||||
|
Ship ship = packet.getShip();
|
||||||
|
assertNotNull(ship);
|
||||||
|
assertEquals("CobraMkIII", ship.getName());
|
||||||
|
assertEquals(16, ship.getFuelCapacity(), 0.0001);
|
||||||
|
assertEquals(16, ship.getFuelLvl(), 0.0001);
|
||||||
|
assertEquals(12, ship.getCargoCapacity());
|
||||||
|
assertEquals(8, ship.getCargoLimit());
|
||||||
|
Module fsd = ship.getFSD();
|
||||||
|
assertNotNull(fsd);
|
||||||
|
assertEquals(128064117L, fsd.getId());
|
||||||
|
assertEquals("Int_Hyperdrive_Size4_Class5", fsd.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParse2() throws Exception {
|
||||||
|
LOG.info("Test parse json in cruise");
|
||||||
|
InputStream is = getClass().getResourceAsStream("/edce/edce_cruise.json");
|
||||||
|
String json = read(is);
|
||||||
|
LOG.trace("Parse json:");
|
||||||
|
LOG.trace("{}", json);
|
||||||
|
EDPacket packet = EDCEParser.parseJSON(json);
|
||||||
|
Commander commander = packet.getCommander();
|
||||||
|
assertNotNull(commander);
|
||||||
|
assertEquals("MoHax", commander.getName());
|
||||||
|
assertEquals(23883052, commander.getCredits());
|
||||||
|
assertFalse(commander.isDocked());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParse3() throws Exception {
|
||||||
|
LOG.info("Test parse json3");
|
||||||
|
InputStream is = getClass().getResourceAsStream("/edce/edce3.json");
|
||||||
|
String json = read(is);
|
||||||
|
LOG.trace("Parse json:");
|
||||||
|
LOG.trace("{}", json);
|
||||||
|
EDPacket packet = EDCEParser.parseJSON(json);
|
||||||
|
System system = packet.getLastSystem();
|
||||||
|
assertNotNull(system);
|
||||||
|
assertEquals(63318, system.getId());
|
||||||
|
assertEquals("CD-58 538", system.getName());
|
||||||
|
assertEquals("Federation", system.getFaction());
|
||||||
|
Starport starport = packet.getLastStarport();
|
||||||
|
assertNotNull(starport);
|
||||||
|
assertEquals(3223873536L, starport.getId());
|
||||||
|
assertEquals("Haberlandt Orbital", starport.getName());
|
||||||
|
assertEquals("Federation", starport.getFaction());
|
||||||
|
List<Commodity> commodities = starport.getCommodities();
|
||||||
|
assertTrue(!commodities.isEmpty());
|
||||||
|
Commodity commodity = commodities.stream().filter(c -> "Explosives".equals(c.getName())).findFirst().get();
|
||||||
|
assertEquals(182, commodity.getBuyPrice());
|
||||||
|
assertEquals(169, commodity.getSellPrice());
|
||||||
|
assertEquals(3, commodity.getStockBracket());
|
||||||
|
assertEquals(0, commodity.getDemandBracket());
|
||||||
|
assertEquals(115475, commodity.getStock());
|
||||||
|
assertEquals(0, commodity.getDemand());
|
||||||
|
assertEquals("Chemicals", commodity.getCategoryname());
|
||||||
|
commodity = commodities.stream().filter(c -> "Coffee".equals(c.getName())).findFirst().get();
|
||||||
|
assertEquals(0, commodity.getBuyPrice());
|
||||||
|
assertEquals(1286, commodity.getSellPrice());
|
||||||
|
assertEquals(0, commodity.getStockBracket());
|
||||||
|
assertEquals(1, commodity.getDemandBracket());
|
||||||
|
assertEquals(0, commodity.getStock());
|
||||||
|
assertEquals(1441, commodity.getDemand());
|
||||||
|
assertEquals("Foods", commodity.getCategoryname());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParse6() throws Exception {
|
||||||
|
LOG.info("Test parse json6");
|
||||||
|
InputStream is = getClass().getResourceAsStream("/edce/edce6.json");
|
||||||
|
String json = read(is);
|
||||||
|
LOG.trace("Parse json:");
|
||||||
|
LOG.trace("{}", json);
|
||||||
|
EDPacket packet = EDCEParser.parseJSON(json);
|
||||||
|
Commander commander = packet.getCommander();
|
||||||
|
assertNotNull(commander);
|
||||||
|
assertEquals("MoHax", commander.getName());
|
||||||
|
assertEquals(23317276, commander.getCredits());
|
||||||
|
assertTrue(commander.isDocked());
|
||||||
|
System system = packet.getLastSystem();
|
||||||
|
assertNotNull(system);
|
||||||
|
assertEquals(7034, system.getId());
|
||||||
|
assertEquals("Iota Horologii", system.getName());
|
||||||
|
assertEquals("Federation", system.getFaction());
|
||||||
|
Starport starport = packet.getLastStarport();
|
||||||
|
assertNotNull(starport);
|
||||||
|
assertEquals(3223721472L, starport.getId());
|
||||||
|
assertEquals("Bessemer Station", starport.getName());
|
||||||
|
assertEquals("Federation", starport.getFaction());
|
||||||
|
List<Commodity> commodities = starport.getCommodities();
|
||||||
|
assertTrue(commodities.isEmpty());
|
||||||
|
Ship ship = packet.getShip();
|
||||||
|
assertNotNull(ship);
|
||||||
|
assertEquals("CobraMkIII", ship.getName());
|
||||||
|
assertEquals(16, ship.getFuelCapacity(), 0.0001);
|
||||||
|
assertEquals(12.47372, ship.getFuelLvl(), 0.0001);
|
||||||
|
assertEquals(0, ship.getCargoCapacity());
|
||||||
|
assertEquals(0, ship.getCargoLimit());
|
||||||
|
Module fsd = ship.getFSD();
|
||||||
|
assertNotNull(fsd);
|
||||||
|
assertEquals(128064117L, fsd.getId());
|
||||||
|
assertEquals("Int_Hyperdrive_Size4_Class5", fsd.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6717,8 +6717,8 @@
|
|||||||
"lvl": 1
|
"lvl": 1
|
||||||
},
|
},
|
||||||
"cargo": {
|
"cargo": {
|
||||||
"capacity": 0,
|
"capacity": 12,
|
||||||
"qty": 0,
|
"qty": 4,
|
||||||
"items": []
|
"items": []
|
||||||
},
|
},
|
||||||
"passengers": [],
|
"passengers": [],
|
||||||
|
|||||||
Reference in New Issue
Block a user