Archived
0

use current free cargo value on add order to track

This commit is contained in:
iMoHax
2016-04-14 14:18:44 +03:00
parent 24a0f6d165
commit 36cc178c29
6 changed files with 25 additions and 18 deletions

View File

@@ -121,7 +121,7 @@ public class Settings {
profile.getShip().setCargo(cargo);
}
public int getCargo(){
public long getCargo(){
return profile.getShip().getCargo();
}

View File

@@ -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()));

View File

@@ -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) {

View File

@@ -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));

View File

@@ -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();
}

View File

@@ -7,7 +7,7 @@ import java.util.regex.Pattern;
public class Ship {
private final static int REFILL_FUEL_STEP = 10;
private int cargo;
private long cargo;
private Engine engine;
private double tank;
private double mass;
@@ -32,11 +32,11 @@ public class Ship {
return ship != null ? new Ship(ship) : ship;
}
public int getCargo() {
public long getCargo() {
return cargo;
}
public void setCargo(int cargo) {
public void setCargo(long cargo) {
this.cargo = cargo;
clearCache();
}