use ModelFabric class for unwrap models
This commit is contained in:
@@ -115,7 +115,7 @@ public class EDCE {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SystemModel sModel = world.get(system.getName());
|
SystemModel sModel = world.get(system.getName());
|
||||||
boolean found = sModel != ModelFabric.NONE_SYSTEM;
|
boolean found = !ModelFabric.isFake(sModel);
|
||||||
if (!found){
|
if (!found){
|
||||||
LOG.warn("Not found system {}", system.getName());
|
LOG.warn("Not found system {}", system.getName());
|
||||||
sModel = world.add(system.getName(), 0,0,0);
|
sModel = world.add(system.getName(), 0,0,0);
|
||||||
@@ -131,7 +131,7 @@ public class EDCE {
|
|||||||
}
|
}
|
||||||
SystemModel sModel = profile.getSystem();
|
SystemModel sModel = profile.getSystem();
|
||||||
StationModel station = sModel.get(starport.getName());
|
StationModel station = sModel.get(starport.getName());
|
||||||
boolean found = station != ModelFabric.NONE_STATION;
|
boolean found = !ModelFabric.isFake(station);
|
||||||
if (!found){
|
if (!found){
|
||||||
LOG.info("Not found station {}, adding", starport.getName());
|
LOG.info("Not found station {}, adding", starport.getName());
|
||||||
updater.create(sModel);
|
updater.create(sModel);
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ public class FilterController {
|
|||||||
private void save() {
|
private void save() {
|
||||||
SystemModel s = center.getValue();
|
SystemModel s = center.getValue();
|
||||||
LOG.trace("Old filter", filter);
|
LOG.trace("Old filter", filter);
|
||||||
filter.setCenter(ModelFabric.isFake(s) ? null : market.getModeler().get(s));
|
filter.setCenter(ModelFabric.isFake(s) ? null : ModelFabric.get(s));
|
||||||
filter.setRadius(radius.getValue().doubleValue());
|
filter.setRadius(radius.getValue().doubleValue());
|
||||||
filter.setDistance(distance.getValue().doubleValue());
|
filter.setDistance(distance.getValue().doubleValue());
|
||||||
if (cbMarket.isSelected()) filter.add(SERVICE_TYPE.MARKET); else filter.remove(SERVICE_TYPE.MARKET);
|
if (cbMarket.isSelected()) filter.add(SERVICE_TYPE.MARKET); else filter.remove(SERVICE_TYPE.MARKET);
|
||||||
@@ -146,7 +146,7 @@ public class FilterController {
|
|||||||
if (cbMediumLandpad.isSelected()) filter.add(SERVICE_TYPE.MEDIUM_LANDPAD); else filter.remove(SERVICE_TYPE.MEDIUM_LANDPAD);
|
if (cbMediumLandpad.isSelected()) filter.add(SERVICE_TYPE.MEDIUM_LANDPAD); else filter.remove(SERVICE_TYPE.MEDIUM_LANDPAD);
|
||||||
if (cbLargeLandpad.isSelected()) filter.add(SERVICE_TYPE.LARGE_LANDPAD); else filter.remove(SERVICE_TYPE.LARGE_LANDPAD);
|
if (cbLargeLandpad.isSelected()) filter.add(SERVICE_TYPE.LARGE_LANDPAD); else filter.remove(SERVICE_TYPE.LARGE_LANDPAD);
|
||||||
filter.clearExcludes();
|
filter.clearExcludes();
|
||||||
excludes.getItems().forEach(st -> filter.addExclude(market.getModeler().get(st)));
|
excludes.getItems().forEach(st -> filter.addExclude(ModelFabric.get(st)));
|
||||||
LOG.trace("New filter", filter);
|
LOG.trace("New filter", filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class MainController {
|
|||||||
private final static Logger LOG = LoggerFactory.getLogger(MainController.class);
|
private final static Logger LOG = LoggerFactory.getLogger(MainController.class);
|
||||||
|
|
||||||
private static MarketModel world = new MarketModel(World.getMarket());
|
private static MarketModel world = new MarketModel(World.getMarket());
|
||||||
private static ProfileModel profile = new ProfileModel(Main.SETTINGS.getProfile(), world);
|
private static ProfileModel profile = world.getModeler().get(Main.SETTINGS.getProfile());
|
||||||
private static MarketModel market = world;
|
private static MarketModel market = world;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public class OffersController {
|
|||||||
cbShipyard.setSelected(false);
|
cbShipyard.setSelected(false);
|
||||||
cbMediumLandpad.setSelected(false);
|
cbMediumLandpad.setSelected(false);
|
||||||
cbLargeLandpad.setSelected(false);
|
cbLargeLandpad.setSelected(false);
|
||||||
if (station != ModelFabric.NONE_STATION){
|
if (!ModelFabric.isFake(station)){
|
||||||
faction.setText(FactionStringConverter.toLocalizationString(station.getFaction()));
|
faction.setText(FactionStringConverter.toLocalizationString(station.getFaction()));
|
||||||
government.setText(GovernmentStringConverter.toLocalizationString(station.getGovernment()));
|
government.setText(GovernmentStringConverter.toLocalizationString(station.getGovernment()));
|
||||||
distance.setText(String.valueOf(station.getDistance()));
|
distance.setText(String.valueOf(station.getDistance()));
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public class SearchController {
|
|||||||
if (cbMediumLandpad.isSelected()) filter.add(SERVICE_TYPE.MEDIUM_LANDPAD); else filter.remove(SERVICE_TYPE.MEDIUM_LANDPAD);
|
if (cbMediumLandpad.isSelected()) filter.add(SERVICE_TYPE.MEDIUM_LANDPAD); else filter.remove(SERVICE_TYPE.MEDIUM_LANDPAD);
|
||||||
if (cbLargeLandpad.isSelected()) filter.add(SERVICE_TYPE.LARGE_LANDPAD); else filter.remove(SERVICE_TYPE.LARGE_LANDPAD);
|
if (cbLargeLandpad.isSelected()) filter.add(SERVICE_TYPE.LARGE_LANDPAD); else filter.remove(SERVICE_TYPE.LARGE_LANDPAD);
|
||||||
ItemModel item = items.getValue();
|
ItemModel item = items.getValue();
|
||||||
if (item == null || item == ModelFabric.NONE_ITEM){
|
if (ModelFabric.isFake(item)){
|
||||||
Collection<StationModel> stations = market.getStations(filter);
|
Collection<StationModel> stations = market.getStations(filter);
|
||||||
fill(stations);
|
fill(stations);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class ItemStatModel {
|
|||||||
private void refreshProp(ObjectProperty<OfferModel> prop, Offer offer){
|
private void refreshProp(ObjectProperty<OfferModel> prop, Offer offer){
|
||||||
if (prop!=null ){
|
if (prop!=null ){
|
||||||
OfferModel model = prop.getValue();
|
OfferModel model = prop.getValue();
|
||||||
if (model==null || !model.getOffer().equals(offer)){
|
if (model==null || !ModelFabric.get(model).equals(offer)){
|
||||||
prop.setValue(asModel(offer));
|
prop.setValue(asModel(offer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,12 +113,12 @@ public class MarketModel {
|
|||||||
LOG.info("Remove system {} from market {}", system, this);
|
LOG.info("Remove system {} from market {}", system, this);
|
||||||
notificator.sendRemove(system);
|
notificator.sendRemove(system);
|
||||||
stationNames.removeAll(system.getStationFullNames());
|
stationNames.removeAll(system.getStationFullNames());
|
||||||
market.remove(system.getSystem());
|
market.remove(ModelFabric.get(system));
|
||||||
systemNames.remove(system.getName());
|
systemNames.remove(system.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
StationModel addStation(SystemModel system, String name) {
|
StationModel addStation(SystemModel system, String name) {
|
||||||
StationModel station = modeler.get(system.getSystem().addVendor(name));
|
StationModel station = modeler.get(ModelFabric.get(system).addVendor(name));
|
||||||
LOG.info("Add station {} to system {}", station, system);
|
LOG.info("Add station {} to system {}", station, system);
|
||||||
stationNames.add(station.getFullName());
|
stationNames.add(station.getFullName());
|
||||||
notificator.sendAdd(station);
|
notificator.sendAdd(station);
|
||||||
@@ -129,7 +129,7 @@ public class MarketModel {
|
|||||||
LOG.info("Remove station {} from system {}", station, station.getSystem());
|
LOG.info("Remove station {} from system {}", station, station.getSystem());
|
||||||
notificator.sendRemove(station);
|
notificator.sendRemove(station);
|
||||||
stationNames.remove(station.getFullName());
|
stationNames.remove(station.getFullName());
|
||||||
station.getSystem().getSystem().remove(station.getStation());
|
ModelFabric.get(station.getSystem()).remove(ModelFabric.get(station));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReadOnlyListProperty<GroupModel> getGroups(){
|
public ReadOnlyListProperty<GroupModel> getGroups(){
|
||||||
@@ -152,7 +152,7 @@ public class MarketModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemModel add(String name, GroupModel group) {
|
public ItemModel add(String name, GroupModel group) {
|
||||||
ItemModel item = modeler.get(market.addItem(name, group.getGroup()));
|
ItemModel item = modeler.get(market.addItem(name, ModelFabric.get(group)));
|
||||||
LOG.info("Add item {} to market {}", item, this);
|
LOG.info("Add item {} to market {}", item, this);
|
||||||
notificator.sendAdd(item);
|
notificator.sendAdd(item);
|
||||||
items.add(item);
|
items.add(item);
|
||||||
@@ -164,7 +164,7 @@ public class MarketModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ObservableList<OfferModel> getOffers(OFFER_TYPE offerType, ItemModel item, MarketFilter filter){
|
public ObservableList<OfferModel> getOffers(OFFER_TYPE offerType, ItemModel item, MarketFilter filter){
|
||||||
return BindingsHelper.observableList(analyzer.getOffers(offerType, item.getItem(), filter), modeler::get);
|
return BindingsHelper.observableList(analyzer.getOffers(offerType, ModelFabric.get(item), filter), modeler::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableList<StationModel> getStations(MarketFilter filter){
|
public ObservableList<StationModel> getStations(MarketFilter filter){
|
||||||
@@ -185,13 +185,10 @@ public class MarketModel {
|
|||||||
|
|
||||||
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, double balance, 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 = MainController.getProfile().getProfile().copy();
|
Profile profile = ModelFabric.get(MainController.getProfile()).copy();
|
||||||
profile.setBalance(balance);
|
profile.setBalance(balance);
|
||||||
OrdersSearchTask task = new OrdersSearchTask(this,
|
OrdersSearchTask task = new OrdersSearchTask(this,
|
||||||
from == null || from == ModelFabric.NONE_SYSTEM ? null : from.getSystem(),
|
ModelFabric.get(from), ModelFabric.get(stationFrom), ModelFabric.get(to), ModelFabric.get(stationTo),
|
||||||
stationFrom == null || stationFrom == ModelFabric.NONE_STATION ? null : stationFrom.getStation(),
|
|
||||||
to == null || to == ModelFabric.NONE_SYSTEM ? null : to.getSystem(),
|
|
||||||
stationTo == null || stationTo == ModelFabric.NONE_STATION ? null : stationTo.getStation(),
|
|
||||||
profile
|
profile
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -211,15 +208,11 @@ public class MarketModel {
|
|||||||
|
|
||||||
public void getRoutes(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo, double balance, CrawlerSpecificator specificator, Consumer<ObservableList<RouteModel>> result) {
|
public void getRoutes(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo, double balance, CrawlerSpecificator specificator, Consumer<ObservableList<RouteModel>> result) {
|
||||||
ProgressController progress = new ProgressController(Screeners.getMainScreen(), Localization.getString("analyzer.routes.title"));
|
ProgressController progress = new ProgressController(Screeners.getMainScreen(), Localization.getString("analyzer.routes.title"));
|
||||||
Profile profile = MainController.getProfile().getProfile().copy();
|
Profile profile = ModelFabric.get(MainController.getProfile()).copy();
|
||||||
profile.setBalance(balance);
|
profile.setBalance(balance);
|
||||||
RoutesSearchTask task = new RoutesSearchTask(this,
|
RoutesSearchTask task = new RoutesSearchTask(this,
|
||||||
from == null || from == ModelFabric.NONE_SYSTEM ? null : from.getSystem(),
|
ModelFabric.get(from), ModelFabric.get(stationFrom), ModelFabric.get(to), ModelFabric.get(stationTo),
|
||||||
stationFrom == null || stationFrom == ModelFabric.NONE_STATION ? null : stationFrom.getStation(),
|
profile, specificator
|
||||||
to == null || to == ModelFabric.NONE_SYSTEM ? null : to.getSystem(),
|
|
||||||
stationTo == null || stationTo == ModelFabric.NONE_STATION ? null : stationTo.getStation(),
|
|
||||||
profile,
|
|
||||||
specificator
|
|
||||||
);
|
);
|
||||||
|
|
||||||
progress.run(task, route -> {
|
progress.run(task, route -> {
|
||||||
@@ -237,13 +230,13 @@ public class MarketModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RouteModel getRoute(RouteModel path) {
|
public RouteModel getRoute(RouteModel path) {
|
||||||
Route r = analyzer.getRoute(path.getRoute().getVendors());
|
Route r = analyzer.getRoute(ModelFabric.get(path).getVendors());
|
||||||
if (r == null) return null;
|
if (r == null) return null;
|
||||||
return modeler.get(r);
|
return modeler.get(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
Route _getPath(OrderModel order) {
|
Route _getPath(OrderModel order) {
|
||||||
return analyzer.getPath(order.getOrder());
|
return analyzer.getPath(ModelFabric.get(order));
|
||||||
}
|
}
|
||||||
|
|
||||||
private RouteModel getPath(Vendor from, Vendor to) {
|
private RouteModel getPath(Vendor from, Vendor to) {
|
||||||
@@ -252,19 +245,19 @@ public class MarketModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RouteModel getPath(StationModel from, StationModel to) {
|
public RouteModel getPath(StationModel from, StationModel to) {
|
||||||
return getPath(from.getStation(), to.getStation());
|
return getPath(ModelFabric.get(from), ModelFabric.get(to));
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteModel getPath(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo){
|
public RouteModel getPath(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo){
|
||||||
if (ModelFabric.isFake(stationFrom)){
|
if (ModelFabric.isFake(stationFrom)){
|
||||||
return getPath(from.getSystem().asTransit(), ModelFabric.isFake(stationTo) ? to.getSystem().asTransit() : stationTo.getStation());
|
return getPath(ModelFabric.get(from).asTransit(), ModelFabric.isFake(stationTo) ? ModelFabric.get(to).asTransit() : ModelFabric.get(stationTo));
|
||||||
} else {
|
} else {
|
||||||
return getPath(stationFrom.getStation(), ModelFabric.isFake(stationTo) ? to.getSystem().asTransit() : stationTo.getStation());
|
return getPath(ModelFabric.get(stationFrom), ModelFabric.isFake(stationTo) ? ModelFabric.get(to).asTransit() : ModelFabric.get(stationTo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteModel getPath(OrderModel order) {
|
public RouteModel getPath(OrderModel order) {
|
||||||
Route p = analyzer.getPath(order.getOrder());
|
Route p = analyzer.getPath(ModelFabric.get(order));
|
||||||
return modeler.get(p);
|
return modeler.get(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class MissionModel {
|
|||||||
this.count = count;
|
this.count = count;
|
||||||
this.profit = profit;
|
this.profit = profit;
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
offer = SimpleOffer.fakeBuy(target.getStation(), item.getItem(), profit / count, count);
|
offer = SimpleOffer.fakeBuy(ModelFabric.get(target), ModelFabric.get(item), profit / count, count);
|
||||||
need = count;
|
need = count;
|
||||||
} else {
|
} else {
|
||||||
need = 0;
|
need = 0;
|
||||||
@@ -92,7 +92,7 @@ public class MissionModel {
|
|||||||
specificator.buy(offer);
|
specificator.buy(offer);
|
||||||
} else
|
} else
|
||||||
if (isCourier() || isDelivery()){
|
if (isCourier() || isDelivery()){
|
||||||
specificator.add(target.getStation(), true);
|
specificator.add(ModelFabric.get(target), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ public class MissionModel {
|
|||||||
for (OrderModel order : orders) {
|
for (OrderModel order : orders) {
|
||||||
if (item.equals(order.getOffer().getItem()) && target.equals(order.getBuyer())){
|
if (item.equals(order.getOffer().getItem()) && target.equals(order.getBuyer())){
|
||||||
for (RouteReserve reserve : reserves) {
|
for (RouteReserve reserve : reserves) {
|
||||||
if (order.getOffer().getOffer().equals(reserve.getOrder().getSell())){
|
if (ModelFabric.get(order.getOffer()).equals(reserve.getOrder().getSell())){
|
||||||
need -= order.getCount();
|
need -= order.getCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,18 @@ public class ModelFabric {
|
|||||||
return new OrderModel(get(order.getSell()), get(order.getBuy()), order.getCount());
|
return new OrderModel(get(order.getSell()), get(order.getBuy()), order.getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Order get(OrderModel order){
|
||||||
|
return order.getOrder();
|
||||||
|
}
|
||||||
|
|
||||||
public RouteModel get(Route route) {
|
public RouteModel get(Route route) {
|
||||||
return new RouteModel(route, market);
|
return new RouteModel(route, market);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Route get(RouteModel route){
|
||||||
|
return route.getRoute();
|
||||||
|
}
|
||||||
|
|
||||||
public SystemModel get(Place system){
|
public SystemModel get(Place system){
|
||||||
if (system == null) return NONE_SYSTEM;
|
if (system == null) return NONE_SYSTEM;
|
||||||
SystemModel res=null;
|
SystemModel res=null;
|
||||||
@@ -48,7 +56,8 @@ public class ModelFabric {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Place get(SystemModel model){
|
public static Place get(SystemModel model){
|
||||||
|
if (isFake(model)) return null;
|
||||||
return model.getSystem();
|
return model.getSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +75,8 @@ public class ModelFabric {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vendor get(StationModel model){
|
public static Vendor get(StationModel model){
|
||||||
|
if (isFake(model)) return null;
|
||||||
return model.getStation();
|
return model.getStation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +85,10 @@ public class ModelFabric {
|
|||||||
return new GroupModel(group);
|
return new GroupModel(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Group get(GroupModel group){
|
||||||
|
return group.getGroup();
|
||||||
|
}
|
||||||
|
|
||||||
public ItemModel get(Item item){
|
public ItemModel get(Item item){
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
ItemModel res=null;
|
ItemModel res=null;
|
||||||
@@ -89,6 +103,11 @@ public class ModelFabric {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Item get(ItemModel item){
|
||||||
|
if (isFake(item)) return null;
|
||||||
|
return item.getItem();
|
||||||
|
}
|
||||||
|
|
||||||
public OfferModel get(Offer offer){
|
public OfferModel get(Offer offer){
|
||||||
if (offer == null) return null;
|
if (offer == null) return null;
|
||||||
OfferModel res = null;
|
OfferModel res = null;
|
||||||
@@ -103,6 +122,10 @@ public class ModelFabric {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Offer get(OfferModel offer){
|
||||||
|
return offer.getOffer();
|
||||||
|
}
|
||||||
|
|
||||||
public OfferModel get(Offer offer, ItemModel item){
|
public OfferModel get(Offer offer, ItemModel item){
|
||||||
if (offer == null) return null;
|
if (offer == null) return null;
|
||||||
//always create new offer model
|
//always create new offer model
|
||||||
@@ -111,6 +134,14 @@ public class ModelFabric {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProfileModel get(Profile profile){
|
||||||
|
return new ProfileModel(profile, market);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Profile get(ProfileModel profile){
|
||||||
|
return profile.getProfile();
|
||||||
|
}
|
||||||
|
|
||||||
public void clear(){
|
public void clear(){
|
||||||
items.clear();
|
items.clear();
|
||||||
systems.clear();
|
systems.clear();
|
||||||
@@ -130,6 +161,10 @@ public class ModelFabric {
|
|||||||
return system == null || system instanceof FAKE_SYSTEM_MODEL;
|
return system == null || system instanceof FAKE_SYSTEM_MODEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isFake(ItemModel item) {
|
||||||
|
return item == null || item instanceof FAKE_ITEM_MODEL;
|
||||||
|
}
|
||||||
|
|
||||||
private static class FAKE_SYSTEM_MODEL extends SystemModel {
|
private static class FAKE_SYSTEM_MODEL extends SystemModel {
|
||||||
FAKE_SYSTEM_MODEL() {
|
FAKE_SYSTEM_MODEL() {
|
||||||
super();
|
super();
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ public class OrderModel {
|
|||||||
|
|
||||||
public OrderModel(OfferModel offer, double balance, long limit) {
|
public OrderModel(OfferModel offer, double balance, long limit) {
|
||||||
this(offer);
|
this(offer);
|
||||||
this.max.setValue(Order.getMaxCount(offer.getOffer(), balance, limit));
|
this.max.setValue(Order.getMaxCount(ModelFabric.get(offer), balance, limit));
|
||||||
}
|
}
|
||||||
|
|
||||||
Order getOrder(){
|
Order getOrder(){
|
||||||
return new Order(getOffer().getOffer(), getBuyOffer().getOffer(), getCount());
|
return new Order(ModelFabric.get(getOffer()), ModelFabric.get(getBuyOffer()), getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
public OfferModel getOffer() {
|
public OfferModel getOffer() {
|
||||||
@@ -127,7 +127,7 @@ public class OrderModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ObservableValue<Number> getProfit(OfferModel buyer) {
|
public ObservableValue<Number> getProfit(OfferModel buyer) {
|
||||||
return Bindings.createDoubleBinding(() -> offer.getPrice() * Order.getMaxCount(offer.getOffer(), buyer.getOffer(), max.get()),
|
return Bindings.createDoubleBinding(() -> offer.getPrice() * Order.getMaxCount(ModelFabric.get(offer), ModelFabric.get(buyer), max.get()),
|
||||||
buyer.priceProperty(), offer.priceProperty(), max, buyer.countProperty());
|
buyer.priceProperty(), offer.priceProperty(), max, buyer.countProperty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSystem(SystemModel system) {
|
public void setSystem(SystemModel system) {
|
||||||
profile.setSystem(ModelFabric.isFake(system) ? null : system.getSystem());
|
profile.setSystem(ModelFabric.get(system));
|
||||||
this.system.set(system);
|
this.system.set(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ public class ProfileModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setStation(StationModel station) {
|
public void setStation(StationModel station) {
|
||||||
profile.setStation(ModelFabric.isFake(station) ? null : station.getStation());
|
profile.setStation(ModelFabric.get(station));
|
||||||
this.station.set(station);
|
this.station.set(station);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ public class RouteModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Route getRoute() {
|
||||||
|
return _route;
|
||||||
|
}
|
||||||
|
|
||||||
private RouteModel getCopy(){
|
private RouteModel getCopy(){
|
||||||
RouteModel res = new RouteModel(_route, market);
|
RouteModel res = new RouteModel(_route, market);
|
||||||
res.setCurrentEntry(getCurrentEntry());
|
res.setCurrentEntry(getCurrentEntry());
|
||||||
@@ -95,10 +99,6 @@ public class RouteModel {
|
|||||||
return _route.getTime();
|
return _route.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Route getRoute() {
|
|
||||||
return _route;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLoop(){
|
public boolean isLoop(){
|
||||||
return _route.isLoop();
|
return _route.isLoop();
|
||||||
}
|
}
|
||||||
@@ -156,12 +156,12 @@ public class RouteModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RouteModel add(RouteModel route){
|
public RouteModel add(RouteModel route){
|
||||||
_route.join(route.getRoute());
|
_route.join(ModelFabric.get(route));
|
||||||
return getCopy();
|
return getCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteModel remove(OrderModel order) {
|
public RouteModel remove(OrderModel order) {
|
||||||
_route.dropTo(order.getStation().getStation());
|
_route.dropTo(ModelFabric.get(order.getStation()));
|
||||||
return getCopy();
|
return getCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ public class RouteModel {
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (mission.isDelivery()){
|
if (mission.isDelivery()){
|
||||||
RouteReserve reserve = RouteFiller.getReserves(_route, offset, mission.getTarget().getStation(), mission.getCount());
|
RouteReserve reserve = RouteFiller.getReserves(_route, offset, ModelFabric.get(mission.getTarget()), mission.getCount());
|
||||||
if (reserve != null) {
|
if (reserve != null) {
|
||||||
_route.reserve(reserve);
|
_route.reserve(reserve);
|
||||||
mission.setReserves(Collections.singleton(reserve));
|
mission.setReserves(Collections.singleton(reserve));
|
||||||
@@ -194,7 +194,7 @@ public class RouteModel {
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (mission.isCourier()){
|
if (mission.isCourier()){
|
||||||
completeIndex = _route.find(mission.getTarget().getStation(), offset+1);
|
completeIndex = _route.find(ModelFabric.get(mission.getTarget()), offset+1);
|
||||||
}
|
}
|
||||||
if (completeIndex != -1){
|
if (completeIndex != -1){
|
||||||
entries.get(completeIndex).add(mission);
|
entries.get(completeIndex).add(mission);
|
||||||
@@ -215,7 +215,7 @@ public class RouteModel {
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (mission.isDelivery()){
|
if (mission.isDelivery()){
|
||||||
RouteReserve reserve = RouteFiller.getReserves(_route, offset, mission.getTarget().getStation(), mission.getCount());
|
RouteReserve reserve = RouteFiller.getReserves(_route, offset, ModelFabric.get(mission.getTarget()), mission.getCount());
|
||||||
if (reserve != null) {
|
if (reserve != null) {
|
||||||
_route.reserve(reserve);
|
_route.reserve(reserve);
|
||||||
mission.setReserves(Collections.singleton(reserve));
|
mission.setReserves(Collections.singleton(reserve));
|
||||||
@@ -223,7 +223,7 @@ public class RouteModel {
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (mission.isCourier()){
|
if (mission.isCourier()){
|
||||||
completeIndex = _route.find(mission.getTarget().getStation(), offset+1);
|
completeIndex = _route.find(ModelFabric.get(mission.getTarget()), offset+1);
|
||||||
}
|
}
|
||||||
if (completeIndex != -1){
|
if (completeIndex != -1){
|
||||||
if (completeIndex == 0 && _route.isLoop()) completeIndex = _route.getJumps()-1;
|
if (completeIndex == 0 && _route.isLoop()) completeIndex = _route.getJumps()-1;
|
||||||
@@ -240,7 +240,7 @@ public class RouteModel {
|
|||||||
entries.subList(startIndex, entries.size()).stream()
|
entries.subList(startIndex, entries.size()).stream()
|
||||||
.filter(e -> !e.isTransit())
|
.filter(e -> !e.isTransit())
|
||||||
.map(RouteEntryModel::getStation)
|
.map(RouteEntryModel::getStation)
|
||||||
.filter(station -> station != ModelFabric.NONE_STATION)
|
.filter(station -> !ModelFabric.isFake(station))
|
||||||
.forEach(res::add);
|
.forEach(res::add);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -380,12 +380,12 @@ public class RouteModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static RouteModel asRoute(SystemModel system){
|
public static RouteModel asRoute(SystemModel system){
|
||||||
Route route = Route.singletone(system.getSystem().asTransit());
|
Route route = Route.singletone(ModelFabric.get(system).asTransit());
|
||||||
return new RouteModel(route, system.getMarket());
|
return new RouteModel(route, system.getMarket());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RouteModel asRoute(StationModel station){
|
public static RouteModel asRoute(StationModel station){
|
||||||
Route route = Route.singletone(station.getStation());
|
Route route = Route.singletone(ModelFabric.get(station));
|
||||||
return new RouteModel(route, station.getMarket());
|
return new RouteModel(route, station.getMarket());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class StationModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OfferModel add(OFFER_TYPE type, ItemModel item, double price, long count){
|
public OfferModel add(OFFER_TYPE type, ItemModel item, double price, long count){
|
||||||
OfferModel offer = asModel(station.addOffer(type, item.getItem(), price, count), item);
|
OfferModel offer = asModel(station.addOffer(type, ModelFabric.get(item), price, count), item);
|
||||||
LOG.info("Add offer {} to station {}", offer, station);
|
LOG.info("Add offer {} to station {}", offer, station);
|
||||||
offer.refresh();
|
offer.refresh();
|
||||||
market.getNotificator().sendAdd(offer);
|
market.getNotificator().sendAdd(offer);
|
||||||
@@ -121,17 +121,17 @@ public class StationModel {
|
|||||||
|
|
||||||
public void remove(OfferModel offer) {
|
public void remove(OfferModel offer) {
|
||||||
LOG.info("Remove offer {} from station {}", offer, station);
|
LOG.info("Remove offer {} from station {}", offer, station);
|
||||||
station.remove(offer.getOffer());
|
station.remove(ModelFabric.get(offer));
|
||||||
offer.refresh();
|
offer.refresh();
|
||||||
market.getNotificator().sendRemove(offer);
|
market.getNotificator().sendRemove(offer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSell(ItemModel item) {
|
public boolean hasSell(ItemModel item) {
|
||||||
return station.hasSell(item.getItem());
|
return station.hasSell(ModelFabric.get(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBuy(ItemModel item) {
|
public boolean hasBuy(ItemModel item) {
|
||||||
return station.hasBuy(item.getItem());
|
return station.hasBuy(ModelFabric.get(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDistance(StationModel other){
|
public double getDistance(StationModel other){
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class SystemModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double getDistance(SystemModel other){
|
public double getDistance(SystemModel other){
|
||||||
return system.getDistance(other.getSystem());
|
return system.getDistance(ModelFabric.get(other));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDistance(double x, double y, double z){
|
public double getDistance(double x, double y, double z){
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.controlsfx.glyphfont.Glyph;
|
|||||||
import ru.trader.analysis.Route;
|
import ru.trader.analysis.Route;
|
||||||
import ru.trader.analysis.RouteEntry;
|
import ru.trader.analysis.RouteEntry;
|
||||||
import ru.trader.core.Vendor;
|
import ru.trader.core.Vendor;
|
||||||
|
import ru.trader.model.ModelFabric;
|
||||||
import ru.trader.model.RouteModel;
|
import ru.trader.model.RouteModel;
|
||||||
|
|
||||||
public class RouteNode {
|
public class RouteNode {
|
||||||
@@ -25,7 +26,7 @@ public class RouteNode {
|
|||||||
private final HBox node = new HBox();
|
private final HBox node = new HBox();
|
||||||
|
|
||||||
public RouteNode(RouteModel route) {
|
public RouteNode(RouteModel route) {
|
||||||
this.route = route.getRoute();
|
this.route = ModelFabric.get(route);
|
||||||
node.getStyleClass().add(CSS_PATH);
|
node.getStyleClass().add(CSS_PATH);
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user