add station select on route select
This commit is contained in:
@@ -5,7 +5,6 @@ import javafx.beans.binding.Bindings;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ComboBox;
|
||||
@@ -13,11 +12,9 @@ import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.TableView;
|
||||
import ru.trader.Main;
|
||||
import ru.trader.model.*;
|
||||
import ru.trader.model.support.BindingsHelper;
|
||||
import ru.trader.view.support.NumberField;
|
||||
import ru.trader.view.support.RouteNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class RouterController {
|
||||
@@ -44,9 +41,16 @@ public class RouterController {
|
||||
|
||||
@FXML
|
||||
private ComboBox<SystemModel> source;
|
||||
|
||||
@FXML
|
||||
private ComboBox<StationModel> sStation;
|
||||
|
||||
@FXML
|
||||
private ComboBox<SystemModel> target;
|
||||
|
||||
@FXML
|
||||
private ComboBox<StationModel> tStation;
|
||||
|
||||
@FXML
|
||||
private TableView<OrderModel> tblOrders;
|
||||
|
||||
@@ -83,6 +87,25 @@ public class RouterController {
|
||||
market.getAnalyzer().setJumps(n.intValue());
|
||||
Main.SETTINGS.setJumps(n.intValue());
|
||||
});
|
||||
source.valueProperty().addListener((ov, o, n) -> {
|
||||
if (n != ModelFabric.NONE_SYSTEM){
|
||||
ObservableList<StationModel> stations = FXCollections.observableArrayList(ModelFabric.NONE_STATION);
|
||||
stations.addAll(n.getStations());
|
||||
sStation.setItems(stations);
|
||||
} else {
|
||||
sStation.setItems(FXCollections.observableArrayList(ModelFabric.NONE_STATION));
|
||||
}
|
||||
});
|
||||
target.valueProperty().addListener((ov, o, n) -> {
|
||||
if (n != ModelFabric.NONE_SYSTEM){
|
||||
ObservableList<StationModel> stations = FXCollections.observableArrayList(ModelFabric.NONE_STATION);
|
||||
stations.addAll(n.getStations());
|
||||
tStation.setItems(stations);
|
||||
} else {
|
||||
tStation.setItems(FXCollections.observableArrayList(ModelFabric.NONE_STATION));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
balance.setOnAction((v)->cargo.requestFocus());
|
||||
cargo.setOnAction((v) -> tank.requestFocus());
|
||||
@@ -132,14 +155,16 @@ public class RouterController {
|
||||
private void onAdd(OrderModel order){
|
||||
totalProfit.add(order.getProfit());
|
||||
totalBalance.add(order.getProfit());
|
||||
source.getSelectionModel().select(order.getBuyOffer().getSystem());
|
||||
source.setValue(order.getBuyer().getSystem());
|
||||
sStation.setValue(order.getBuyer());
|
||||
balance.setDisable(true);
|
||||
}
|
||||
|
||||
private void onRemove(OrderModel order) {
|
||||
totalProfit.sub(order.getProfit());
|
||||
totalBalance.sub(order.getProfit());
|
||||
source.getSelectionModel().select(order.getStation().getSystem());
|
||||
source.setValue(order.getSystem());
|
||||
sStation.setValue(order.getStation());
|
||||
if (orders.isEmpty()) {
|
||||
balance.setDisable(false);
|
||||
source.setDisable(false);
|
||||
@@ -189,30 +214,24 @@ public class RouterController {
|
||||
}
|
||||
|
||||
public void showOrders(){
|
||||
//TODO: fix set balanace
|
||||
SystemModel s = source.getSelectionModel().getSelectedItem();
|
||||
SystemModel t = target.getSelectionModel().getSelectedItem();
|
||||
OrderModel order;
|
||||
if (t == ModelFabric.NONE_SYSTEM){
|
||||
order = Screeners.showOrders(market.getOrders(s, totalBalance.getValue().doubleValue()));
|
||||
} else {
|
||||
order = Screeners.showOrders(market.getOrders(s, t, totalBalance.getValue().doubleValue()));
|
||||
}
|
||||
SystemModel s = source.getValue();
|
||||
SystemModel t = target.getValue();
|
||||
StationModel sS = sStation.getValue();
|
||||
StationModel tS = tStation.getValue();
|
||||
OrderModel order = Screeners.showOrders(market.getOrders(s, sS, t, tS, totalBalance.getValue().doubleValue()));
|
||||
if (order!=null){
|
||||
//TODO: fix set balanace
|
||||
orders.add(order);
|
||||
addOrderToPath(order);
|
||||
}
|
||||
}
|
||||
|
||||
public void showRoutes(){
|
||||
SystemModel s = source.getSelectionModel().getSelectedItem();
|
||||
SystemModel t = target.getSelectionModel().getSelectedItem();
|
||||
PathRouteModel path;
|
||||
if (t == ModelFabric.NONE_SYSTEM){
|
||||
path = Screeners.showRouters(market.getRoutes(s, totalBalance.getValue().doubleValue()));
|
||||
} else {
|
||||
path = Screeners.showRouters(market.getRoutes(s, t, totalBalance.getValue().doubleValue()));
|
||||
}
|
||||
SystemModel s = source.getValue();
|
||||
SystemModel t = target.getValue();
|
||||
StationModel sS = sStation.getValue();
|
||||
StationModel tS = tStation.getValue();
|
||||
PathRouteModel path = Screeners.showRouters(market.getRoutes(s, sS, t, tS, totalBalance.getValue().doubleValue()));
|
||||
if (path!=null){
|
||||
orders.addAll(path.getOrders());
|
||||
addRouteToPath(path);
|
||||
|
||||
@@ -12,6 +12,8 @@ import ru.trader.graph.PathRoute;
|
||||
import ru.trader.model.support.BindingsHelper;
|
||||
import ru.trader.model.support.Notificator;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
public class MarketModel {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(MarketModel.class);
|
||||
@@ -74,15 +76,41 @@ public class MarketModel {
|
||||
}
|
||||
|
||||
public ObservableList<OrderModel> getOrders(SystemModel from, double balance) {
|
||||
return BindingsHelper.observableList(analyzer.getOrders(from.getSystem(), balance), modeler::get);
|
||||
return getOrders(from, ModelFabric.NONE_STATION, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, balance);
|
||||
}
|
||||
|
||||
public ObservableList<OrderModel> getOrders(SystemModel from, SystemModel to, double balance) {
|
||||
return BindingsHelper.observableList(analyzer.getOrders(from.getSystem(), to.getSystem(), balance), modeler::get);
|
||||
return getOrders(from, ModelFabric.NONE_STATION, to, ModelFabric.NONE_STATION, balance);
|
||||
}
|
||||
|
||||
public ObservableList<OrderModel> getOrders(StationModel from, StationModel to, double balance) {
|
||||
return BindingsHelper.observableList(analyzer.getOrders(from.getStation(), to.getStation(), balance), modeler::get);
|
||||
return getOrders(from.getSystem(), from, to.getSystem(), to, balance);
|
||||
}
|
||||
|
||||
public ObservableList<OrderModel> getOrders(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo, double balance) {
|
||||
Collection<Order> orders;
|
||||
if (stationFrom != null && stationFrom != ModelFabric.NONE_STATION){
|
||||
if (stationTo != null && stationTo != ModelFabric.NONE_STATION){
|
||||
orders = analyzer.getOrders(stationFrom.getStation(), stationTo.getStation(), balance);
|
||||
} else {
|
||||
if (to != null && to != ModelFabric.NONE_SYSTEM){
|
||||
orders = analyzer.getOrders(stationFrom.getStation(), to.getSystem(), balance);
|
||||
} else {
|
||||
orders = analyzer.getOrders(stationFrom.getStation(), balance);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (stationTo != null && stationTo != ModelFabric.NONE_STATION){
|
||||
orders = analyzer.getOrders(from.getSystem(), stationTo.getStation(), balance);
|
||||
} else {
|
||||
if (to != null && to != ModelFabric.NONE_SYSTEM){
|
||||
orders = analyzer.getOrders(from.getSystem(), to.getSystem(), balance);
|
||||
} else {
|
||||
orders = analyzer.getOrders(from.getSystem(), balance);
|
||||
}
|
||||
}
|
||||
}
|
||||
return BindingsHelper.observableList(orders, modeler::get);
|
||||
}
|
||||
|
||||
public ObservableList<OrderModel> getTop(double balance){
|
||||
@@ -90,13 +118,41 @@ public class MarketModel {
|
||||
}
|
||||
|
||||
public ObservableList<PathRouteModel> getRoutes(SystemModel from, double balance){
|
||||
return BindingsHelper.observableList(analyzer.getPaths(from.getSystem(), balance), modeler::get);
|
||||
return getRoutes(from, ModelFabric.NONE_STATION, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, balance);
|
||||
}
|
||||
|
||||
public ObservableList<PathRouteModel> getRoutes(SystemModel from, SystemModel to, double balance){
|
||||
return BindingsHelper.observableList(analyzer.getPaths(from.getSystem(), to.getSystem(), balance), modeler::get);
|
||||
return getRoutes(from, ModelFabric.NONE_STATION, to, ModelFabric.NONE_STATION, balance);
|
||||
}
|
||||
|
||||
public ObservableList<PathRouteModel> getRoutes(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo, double balance) {
|
||||
Collection<PathRoute> routes;
|
||||
if (stationFrom != null && stationFrom != ModelFabric.NONE_STATION){
|
||||
if (stationTo != null && stationTo != ModelFabric.NONE_STATION){
|
||||
routes = analyzer.getPaths(stationFrom.getStation(), stationTo.getStation(), balance);
|
||||
} else {
|
||||
if (to != null && to != ModelFabric.NONE_SYSTEM){
|
||||
routes = analyzer.getPaths(stationFrom.getStation(), to.getSystem(), balance);
|
||||
} else {
|
||||
routes = analyzer.getPaths(stationFrom.getStation(), balance);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (stationTo != null && stationTo != ModelFabric.NONE_STATION){
|
||||
routes = analyzer.getPaths(from.getSystem(), stationTo.getStation(), balance);
|
||||
} else {
|
||||
if (to != null && to != ModelFabric.NONE_SYSTEM){
|
||||
routes = analyzer.getPaths(from.getSystem(), to.getSystem(), balance);
|
||||
} else {
|
||||
routes = analyzer.getPaths(from.getSystem(), balance);
|
||||
}
|
||||
}
|
||||
}
|
||||
return BindingsHelper.observableList(routes, modeler::get);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ObservableList<PathRouteModel> getTopRoutes(double balance){
|
||||
return BindingsHelper.observableList(analyzer.getTopPaths(balance), modeler::get);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import ru.trader.core.*;
|
||||
import ru.trader.graph.PathRoute;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -102,6 +103,7 @@ public class ModelFabric {
|
||||
}
|
||||
|
||||
public static SystemModel NONE_SYSTEM = new FAKE_SYSTEM_MODEL();
|
||||
public static StationModel NONE_STATION = new FAKE_STATION_MODEL();
|
||||
|
||||
private static class FAKE_SYSTEM_MODEL extends SystemModel {
|
||||
FAKE_SYSTEM_MODEL() {
|
||||
@@ -174,4 +176,100 @@ public class ModelFabric {
|
||||
}
|
||||
}
|
||||
|
||||
private static class FAKE_STATION_MODEL extends StationModel {
|
||||
|
||||
FAKE_STATION_MODEL() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
Vendor getStation() {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String value) {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDistance() {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDistance(double value) {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasService(SERVICE_TYPE service) {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<SERVICE_TYPE> getServices() {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addService(SERVICE_TYPE service) {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeService(SERVICE_TYPE service) {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemModel getSystem() {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OfferModel> getSells() {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OfferModel> getBuys() {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfferModel add(OFFER_TYPE type, ItemModel item, double price, long count) {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(OfferModel offer) {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSell(ItemModel item) {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBuy(ItemModel item) {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDistance(StationModel other) {
|
||||
throw new UnsupportedOperationException("Is fake system, unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ public class StationModel {
|
||||
return market.getModeler().get(offer, item);
|
||||
}
|
||||
|
||||
StationModel() {
|
||||
this.station = null;
|
||||
this.market = null;
|
||||
}
|
||||
|
||||
StationModel(Vendor station, MarketModel market) {
|
||||
this.station = station;
|
||||
this.market = market;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<ColumnConstraints fillWidth="true"/>
|
||||
</columnConstraints>
|
||||
|
||||
<TitledPane GridPane.rowSpan="3" text="%market.systems" minWidth="250" prefHeight="530" collapsible="false">
|
||||
<TitledPane GridPane.rowSpan="3" text="%market.systems" minWidth="250" prefHeight="570" collapsible="false">
|
||||
<ListView fx:id="systems">
|
||||
<contextMenu>
|
||||
<ContextMenu>
|
||||
|
||||
@@ -40,13 +40,15 @@
|
||||
</columnConstraints>
|
||||
<Label text="%router.pane.route.from" />
|
||||
<ComboBox fx:id="source" prefWidth="160" GridPane.columnIndex="1" />
|
||||
<Label text="%router.pane.route.to" GridPane.rowIndex="1"/>
|
||||
<ComboBox fx:id="target" prefWidth="160" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
<Label text="%router.pane.route.jumps" GridPane.rowIndex="2" />
|
||||
<NumberField fx:id="jumps" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||
<ComboBox fx:id="sStation" prefWidth="160" GridPane.rowIndex="1" GridPane.columnIndex="1" />
|
||||
<Label text="%router.pane.route.to" GridPane.rowIndex="2"/>
|
||||
<ComboBox fx:id="target" prefWidth="160" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
<ComboBox fx:id="tStation" prefWidth="160" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
<Label text="%router.pane.route.jumps" GridPane.rowIndex="4" />
|
||||
<NumberField fx:id="jumps" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||
|
||||
<Separator GridPane.columnSpan="2" GridPane.rowIndex="3" GridPane.margin="$separator_margin"/>
|
||||
<VBox GridPane.columnSpan="2" GridPane.rowIndex="4" spacing="5">
|
||||
<Separator GridPane.columnSpan="2" GridPane.rowIndex="5" GridPane.margin="$separator_margin"/>
|
||||
<VBox GridPane.columnSpan="2" GridPane.rowIndex="6" spacing="5">
|
||||
<HBox alignment="CENTER" spacing="5">
|
||||
<Button fx:id="editBtn" text="%dialog.button.edit" onAction="#editOrders"/>
|
||||
<Button fx:id="removeBtn" text="%dialog.button.remove" onAction="#removeSelected"/>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ru.trader.core;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.graph.*;
|
||||
@@ -38,15 +37,25 @@ public class MarketAnalyzer {
|
||||
return top;
|
||||
}
|
||||
|
||||
public Collection<Order> getOrders(Vendor vendor, double balance) {
|
||||
Collection<Place> places = market.get();
|
||||
Graph<Place> graph = new Graph<Place>(vendor.getPlace(), places, tank, maxDistance, true, jumps, Path::new);
|
||||
return getOrders(graph, Collections.singleton(vendor), balance, 0);
|
||||
}
|
||||
|
||||
public Collection<Order> getOrders(Place place, double balance) {
|
||||
return getOrders(place, balance, 0);
|
||||
}
|
||||
|
||||
private Collection<Order> getOrders(Place place, double balance, double lowProfit) {
|
||||
List<Order> res = new ArrayList<>(20);
|
||||
Collection<Place> places = market.get();
|
||||
Graph<Place> graph = new Graph<>(place, places, tank, maxDistance, true, jumps, Path::new);
|
||||
for (Vendor vendor : place.get()) {
|
||||
return getOrders(graph, place.get(), balance, lowProfit);
|
||||
}
|
||||
|
||||
private Collection<Order> getOrders(Graph<Place> graph, Collection<Vendor> sellers, double balance, double lowProfit) {
|
||||
List<Order> res = new ArrayList<>(20);
|
||||
for (Vendor vendor : sellers) {
|
||||
for (Offer sell : vendor.getAllSellOffers()) {
|
||||
LOG.trace("Sell offer {}", sell);
|
||||
if (sell.getCount() == 0) continue;
|
||||
@@ -75,62 +84,77 @@ public class MarketAnalyzer {
|
||||
return res;
|
||||
}
|
||||
|
||||
public Collection<Order> getOrders(Place from, Place to, double balance) {
|
||||
Collection<Order> res = new ArrayList<>();
|
||||
Graph<Place> graph = new Graph<>(from, market.get(), tank, maxDistance, true, jumps, Path::new);
|
||||
if (!graph.isAccessible(to)){
|
||||
LOG.trace("Is inaccessible buyer");
|
||||
return res;
|
||||
}
|
||||
for (Vendor seller : from.get()) {
|
||||
private Collection<Order> getOrders(Collection<Vendor> sellers, Collection<Vendor> buyers, double balance, double lowProfit) {
|
||||
List<Order> res = new ArrayList<>();
|
||||
for (Vendor seller : sellers) {
|
||||
for (Offer sell : seller.getAllSellOffers()) {
|
||||
if (sell.getCount() == 0) continue;
|
||||
long count = Order.getMaxCount(sell, balance, cargo);
|
||||
LOG.trace("Sell offer {}, count = {}", sell, count);
|
||||
if (count == 0) continue;
|
||||
for (Vendor buyer : to.get()) {
|
||||
for (Vendor buyer : buyers) {
|
||||
Offer buy = buyer.getBuy(sell.getItem());
|
||||
if (buy != null){
|
||||
Order order = new Order(sell, buy, count);
|
||||
LOG.trace("Buy offer {} profit = {}", buy, order.getProfit());
|
||||
if (order.getProfit() < lowProfit) {
|
||||
LOG.trace("Is low profit, skip");
|
||||
continue;
|
||||
}
|
||||
res.add(order);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.sort(orderComparator);
|
||||
return res;
|
||||
}
|
||||
|
||||
public Collection<Order> getOrders(Vendor from, Vendor to, double balance) {
|
||||
Collection<Order> res = new ArrayList<>();
|
||||
Graph<Place> graph = new Graph<>(from.getPlace(), market.get(), tank, maxDistance, true, jumps, Path::new);
|
||||
Graph<Place> graph = new Graph<Place>(from.getPlace(), market.get(), tank, maxDistance, true, jumps, Path::new);
|
||||
if (!graph.isAccessible(to.getPlace())){
|
||||
LOG.trace("Is inaccessible buyer");
|
||||
return res;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
for (Offer sell : from.getAllSellOffers()) {
|
||||
if (sell.getCount() == 0) continue;
|
||||
long count = Order.getMaxCount(sell, balance, cargo);
|
||||
LOG.trace("Sell offer {}, count = {}", sell, count);
|
||||
if (count == 0) continue;
|
||||
|
||||
Offer buy = to.getBuy(sell.getItem());
|
||||
if (buy != null){
|
||||
Order order = new Order(sell, buy, count);
|
||||
LOG.trace("Buy offer {} profit = {}", buy, order.getProfit());
|
||||
res.add(order);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
return getOrders(Collections.singleton(from), Collections.singleton(to), balance, 0);
|
||||
}
|
||||
|
||||
public Collection<Order> getOrders(Place from, Place to, double balance) {
|
||||
Graph<Place> graph = new Graph<Place>(from, market.get(), tank, maxDistance, true, jumps, Path::new);
|
||||
if (!graph.isAccessible(to)){
|
||||
LOG.trace("Is inaccessible buyer");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getOrders(from.get(), to.get(), balance, 0);
|
||||
}
|
||||
|
||||
|
||||
public Collection<Order> getOrders(Vendor from, Place to, double balance) {
|
||||
Graph<Place> graph = new Graph<Place>(from.getPlace(), market.get(), tank, maxDistance, true, jumps, Path::new);
|
||||
if (!graph.isAccessible(to)){
|
||||
LOG.trace("Is inaccessible buyer");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getOrders(Collections.singleton(from), to.get(), balance, 0);
|
||||
}
|
||||
|
||||
public Collection<Order> getOrders(Place from, Vendor to, double balance) {
|
||||
Graph<Place> graph = new Graph<Place>(from, market.get(), tank, maxDistance, true, jumps, Path::new);
|
||||
if (!graph.isAccessible(to.getPlace())){
|
||||
LOG.trace("Is inaccessible buyer");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getOrders(from.get(), Collections.singleton(to), balance, 0);
|
||||
}
|
||||
|
||||
|
||||
public Collection<Path<Place>> getPaths(Place from, Place to){
|
||||
Graph<Place> graph = new Graph<>(from, market.get(), tank, maxDistance, true, jumps, Path::new);
|
||||
Graph<Place> graph = new Graph<Place>(from, market.get(), tank, maxDistance, true, jumps, Path::new);
|
||||
return graph.getPathsTo(to);
|
||||
}
|
||||
|
||||
public Path<Place> getPath(Place from, Place to){
|
||||
Graph<Place> graph = new Graph<>(from, market.get(), tank, maxDistance, true, jumps, Path::new);
|
||||
Graph<Place> graph = new Graph<Place>(from, market.get(), tank, maxDistance, true, jumps, Path::new);
|
||||
return graph.getFastPathTo(to);
|
||||
}
|
||||
|
||||
@@ -139,6 +163,12 @@ public class MarketAnalyzer {
|
||||
return (PathRoute)graph.getFastPathTo(to);
|
||||
}
|
||||
|
||||
public Collection<PathRoute> getPaths(Vendor from, double balance){
|
||||
RouteSearcher searcher = new RouteSearcher(maxDistance, tank, segmentSize);
|
||||
Collection<Vendor> vendors = market.getVendors();
|
||||
return searcher.getPaths(from, vendors, jumps, balance, cargo, limit);
|
||||
}
|
||||
|
||||
public Collection<PathRoute> getPaths(Place from, double balance){
|
||||
RouteSearcher searcher = new RouteSearcher(maxDistance, tank, segmentSize);
|
||||
Collection<Vendor> vendors = market.getVendors();
|
||||
@@ -149,7 +179,6 @@ public class MarketAnalyzer {
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
public Collection<PathRoute> getPaths(Vendor from, Vendor to, double balance){
|
||||
@@ -173,6 +202,31 @@ public class MarketAnalyzer {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public Collection<PathRoute> getPaths(Vendor from, Place to, double balance){
|
||||
List<PathRoute> top = new ArrayList<>(limit);
|
||||
RouteSearcher searcher = new RouteSearcher(maxDistance, tank, segmentSize);
|
||||
Collection<Vendor> vendors = market.getVendors();
|
||||
Collection<Vendor> toVendors = to.get();
|
||||
for (Vendor toVendor : toVendors) {
|
||||
Collection<PathRoute> paths = searcher.getPaths(from, toVendor, vendors, jumps, balance, cargo, limit);
|
||||
TopList.addAllToTop(top, paths, limit, RouteGraph.byProfitComparator);
|
||||
}
|
||||
return top;
|
||||
}
|
||||
|
||||
public Collection<PathRoute> getPaths(Place from, Vendor to, double balance){
|
||||
RouteSearcher searcher = new RouteSearcher(maxDistance, tank, segmentSize);
|
||||
Collection<Vendor> vendors = market.getVendors();
|
||||
Collection<Vendor> fVendors = from.get();
|
||||
for (Vendor fromVendor : fVendors) {
|
||||
Collection<PathRoute> paths = searcher.getPaths(fromVendor, to, vendors, jumps, balance, cargo, limit);
|
||||
if (paths.size()>0){
|
||||
return paths;
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public Collection<PathRoute> getTopPaths(double balance){
|
||||
List<PathRoute> top = new ArrayList<>(limit);
|
||||
RouteSearcher searcher = new RouteSearcher(maxDistance, tank, segmentSize);
|
||||
|
||||
Reference in New Issue
Block a user