use current free cargo value on add order to track
This commit is contained in:
@@ -121,7 +121,7 @@ public class Settings {
|
||||
profile.getShip().setCargo(cargo);
|
||||
}
|
||||
|
||||
public int getCargo(){
|
||||
public long getCargo(){
|
||||
return profile.getShip().getCargo();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,14 @@ package ru.trader.controllers;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.Pane;
|
||||
import ru.trader.Main;
|
||||
import ru.trader.analysis.CrawlerSpecificator;
|
||||
import ru.trader.core.Profile;
|
||||
import ru.trader.model.*;
|
||||
import ru.trader.model.support.BindingsHelper;
|
||||
import ru.trader.view.support.Track;
|
||||
import ru.trader.view.support.ViewUtils;
|
||||
import ru.trader.view.support.autocomplete.AutoCompletion;
|
||||
@@ -23,7 +22,6 @@ import ru.trader.view.support.cells.OrderListCell;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RouteTrackController {
|
||||
|
||||
@@ -306,16 +304,19 @@ public class RouteTrackController {
|
||||
if (entry.isTransit()) return;
|
||||
StationModel seller = entry.getStation();
|
||||
if (ModelFabric.isFake(seller)) return;
|
||||
Profile profile = Profile.clone(ModelFabric.get(MainController.getProfile()));
|
||||
profile.setBalance(route.getBalance(startIndex));
|
||||
profile.getShip().setCargo(route.getCargo(startIndex));
|
||||
if (startIndex != route.getJumps()){
|
||||
Collection<StationModel> buyers = route.getStations(startIndex);
|
||||
route.getMarket().getOrders(seller, buyers, route.getBalance(startIndex), orders -> {
|
||||
route.getMarket().getOrders(seller, buyers, profile, orders -> {
|
||||
Optional<OrderModel> order = Screeners.showOrders(orders);
|
||||
if (order.isPresent()){
|
||||
route.add(startIndex, order.get());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
route.getMarket().getOrders(seller, route.getBalance(startIndex), orders -> {
|
||||
route.getMarket().getOrders(seller, profile, orders -> {
|
||||
Optional<OrderModel> order = Screeners.showOrders(orders);
|
||||
if (order.isPresent()){
|
||||
updateRoute(route.add(order.get()));
|
||||
|
||||
@@ -193,14 +193,12 @@ public class MarketModel {
|
||||
return BindingsHelper.observableList(analyzer.getSystems(filter), modeler::get);
|
||||
}
|
||||
|
||||
public void getOrders(StationModel from, double balance, Consumer<ObservableList<OrderModel>> result) {
|
||||
getOrders(ModelFabric.NONE_SYSTEM, from, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, balance, result);
|
||||
public void getOrders(StationModel from, Profile profile, Consumer<ObservableList<OrderModel>> result) {
|
||||
getOrders(ModelFabric.NONE_SYSTEM, from, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, profile, result);
|
||||
}
|
||||
|
||||
public void getOrders(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo, double balance, Consumer<ObservableList<OrderModel>> result) {
|
||||
public void getOrders(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo, Profile profile, Consumer<ObservableList<OrderModel>> result) {
|
||||
ProgressController progress = new ProgressController(Screeners.getMainScreen(), Localization.getString("analyzer.orders.title"));
|
||||
Profile profile = Profile.clone(ModelFabric.get(MainController.getProfile()));
|
||||
profile.setBalance(balance);
|
||||
OrdersSearchTask task = new OrdersSearchTask(this,
|
||||
ModelFabric.get(from), ModelFabric.get(stationFrom), ModelFabric.get(to), ModelFabric.get(stationTo),
|
||||
profile
|
||||
@@ -216,10 +214,8 @@ public class MarketModel {
|
||||
});
|
||||
}
|
||||
|
||||
public void getOrders(StationModel seller, Collection<StationModel> buyers, double balance, Consumer<ObservableList<OrderModel>> result) {
|
||||
public void getOrders(StationModel seller, Collection<StationModel> buyers, Profile profile, Consumer<ObservableList<OrderModel>> result) {
|
||||
ProgressController progress = new ProgressController(Screeners.getMainScreen(), Localization.getString("analyzer.orders.title"));
|
||||
Profile profile = Profile.clone(ModelFabric.get(MainController.getProfile()));
|
||||
profile.setBalance(balance);
|
||||
List<Vendor> vendors = buyers.stream().map(ModelFabric::get).collect(Collectors.toList());
|
||||
OrdersSearchTask task = new OrdersSearchTask(this, ModelFabric.get(seller), vendors, profile);
|
||||
progress.run(task, order -> {
|
||||
@@ -233,7 +229,9 @@ public class MarketModel {
|
||||
}
|
||||
|
||||
public void getTop(double balance, Consumer<ObservableList<OrderModel>> result){
|
||||
getOrders(ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, balance, result);
|
||||
Profile profile = Profile.clone(ModelFabric.get(MainController.getProfile()));
|
||||
profile.setBalance(balance);
|
||||
getOrders(ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, profile, result);
|
||||
}
|
||||
|
||||
public void getRoutes(StationModel stationFrom, StationModel stationTo, double balance, CrawlerSpecificator specificator, Consumer<ObservableList<RouteModel>> result) {
|
||||
|
||||
@@ -130,6 +130,10 @@ public class RouteEntryModel {
|
||||
return new FilteredList<>(missions, MissionModel::isCompleted);
|
||||
}
|
||||
|
||||
public long getCargo() {
|
||||
return entry.getCargo();
|
||||
}
|
||||
|
||||
void refresh(MarketModel market){
|
||||
orders.clear();
|
||||
orders.addAll(BindingsHelper.observableList(entry.getOrders(), market.getModeler()::get));
|
||||
|
||||
@@ -365,6 +365,10 @@ public class RouteModel {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public long getCargo(int index){
|
||||
return _route.getCargo() - entries.get(index).getCargo();
|
||||
}
|
||||
|
||||
public int getCurrentEntry() {
|
||||
return currentEntry.get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user