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);
|
profile.getShip().setCargo(cargo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCargo(){
|
public long getCargo(){
|
||||||
return profile.getShip().getCargo();
|
return profile.getShip().getCargo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ package ru.trader.controllers;
|
|||||||
import javafx.beans.InvalidationListener;
|
import javafx.beans.InvalidationListener;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import ru.trader.Main;
|
import ru.trader.Main;
|
||||||
import ru.trader.analysis.CrawlerSpecificator;
|
import ru.trader.analysis.CrawlerSpecificator;
|
||||||
|
import ru.trader.core.Profile;
|
||||||
import ru.trader.model.*;
|
import ru.trader.model.*;
|
||||||
import ru.trader.model.support.BindingsHelper;
|
|
||||||
import ru.trader.view.support.Track;
|
import ru.trader.view.support.Track;
|
||||||
import ru.trader.view.support.ViewUtils;
|
import ru.trader.view.support.ViewUtils;
|
||||||
import ru.trader.view.support.autocomplete.AutoCompletion;
|
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.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class RouteTrackController {
|
public class RouteTrackController {
|
||||||
|
|
||||||
@@ -306,16 +304,19 @@ public class RouteTrackController {
|
|||||||
if (entry.isTransit()) return;
|
if (entry.isTransit()) return;
|
||||||
StationModel seller = entry.getStation();
|
StationModel seller = entry.getStation();
|
||||||
if (ModelFabric.isFake(seller)) return;
|
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()){
|
if (startIndex != route.getJumps()){
|
||||||
Collection<StationModel> buyers = route.getStations(startIndex);
|
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);
|
Optional<OrderModel> order = Screeners.showOrders(orders);
|
||||||
if (order.isPresent()){
|
if (order.isPresent()){
|
||||||
route.add(startIndex, order.get());
|
route.add(startIndex, order.get());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
route.getMarket().getOrders(seller, route.getBalance(startIndex), orders -> {
|
route.getMarket().getOrders(seller, profile, orders -> {
|
||||||
Optional<OrderModel> order = Screeners.showOrders(orders);
|
Optional<OrderModel> order = Screeners.showOrders(orders);
|
||||||
if (order.isPresent()){
|
if (order.isPresent()){
|
||||||
updateRoute(route.add(order.get()));
|
updateRoute(route.add(order.get()));
|
||||||
|
|||||||
@@ -193,14 +193,12 @@ public class MarketModel {
|
|||||||
return BindingsHelper.observableList(analyzer.getSystems(filter), modeler::get);
|
return BindingsHelper.observableList(analyzer.getSystems(filter), modeler::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getOrders(StationModel from, double balance, Consumer<ObservableList<OrderModel>> result) {
|
public void getOrders(StationModel from, Profile profile, Consumer<ObservableList<OrderModel>> result) {
|
||||||
getOrders(ModelFabric.NONE_SYSTEM, from, ModelFabric.NONE_SYSTEM, ModelFabric.NONE_STATION, balance, 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"));
|
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,
|
OrdersSearchTask task = new OrdersSearchTask(this,
|
||||||
ModelFabric.get(from), ModelFabric.get(stationFrom), ModelFabric.get(to), ModelFabric.get(stationTo),
|
ModelFabric.get(from), ModelFabric.get(stationFrom), ModelFabric.get(to), ModelFabric.get(stationTo),
|
||||||
profile
|
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"));
|
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());
|
List<Vendor> vendors = buyers.stream().map(ModelFabric::get).collect(Collectors.toList());
|
||||||
OrdersSearchTask task = new OrdersSearchTask(this, ModelFabric.get(seller), vendors, profile);
|
OrdersSearchTask task = new OrdersSearchTask(this, ModelFabric.get(seller), vendors, profile);
|
||||||
progress.run(task, order -> {
|
progress.run(task, order -> {
|
||||||
@@ -233,7 +229,9 @@ public class MarketModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getTop(double balance, Consumer<ObservableList<OrderModel>> result){
|
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) {
|
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);
|
return new FilteredList<>(missions, MissionModel::isCompleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getCargo() {
|
||||||
|
return entry.getCargo();
|
||||||
|
}
|
||||||
|
|
||||||
void refresh(MarketModel market){
|
void refresh(MarketModel market){
|
||||||
orders.clear();
|
orders.clear();
|
||||||
orders.addAll(BindingsHelper.observableList(entry.getOrders(), market.getModeler()::get));
|
orders.addAll(BindingsHelper.observableList(entry.getOrders(), market.getModeler()::get));
|
||||||
|
|||||||
@@ -365,6 +365,10 @@ public class RouteModel {
|
|||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getCargo(int index){
|
||||||
|
return _route.getCargo() - entries.get(index).getCargo();
|
||||||
|
}
|
||||||
|
|
||||||
public int getCurrentEntry() {
|
public int getCurrentEntry() {
|
||||||
return currentEntry.get();
|
return currentEntry.get();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.util.regex.Pattern;
|
|||||||
public class Ship {
|
public class Ship {
|
||||||
private final static int REFILL_FUEL_STEP = 10;
|
private final static int REFILL_FUEL_STEP = 10;
|
||||||
|
|
||||||
private int cargo;
|
private long cargo;
|
||||||
private Engine engine;
|
private Engine engine;
|
||||||
private double tank;
|
private double tank;
|
||||||
private double mass;
|
private double mass;
|
||||||
@@ -32,11 +32,11 @@ public class Ship {
|
|||||||
return ship != null ? new Ship(ship) : ship;
|
return ship != null ? new Ship(ship) : ship;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCargo() {
|
public long getCargo() {
|
||||||
return cargo;
|
return cargo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCargo(int cargo) {
|
public void setCargo(long cargo) {
|
||||||
this.cargo = cargo;
|
this.cargo = cargo;
|
||||||
clearCache();
|
clearCache();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user