add faction and government fields
This commit is contained in:
@@ -17,6 +17,8 @@ import ru.trader.model.StationModel;
|
||||
import ru.trader.model.SystemModel;
|
||||
import ru.trader.model.support.BindingsHelper;
|
||||
import ru.trader.model.support.ChangeMarketListener;
|
||||
import ru.trader.view.support.FactionStringConverter;
|
||||
import ru.trader.view.support.GovernmentStringConverter;
|
||||
import ru.trader.view.support.ViewUtils;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,6 +41,10 @@ public class OffersController {
|
||||
@FXML
|
||||
private TableView<OfferModel> tblBuy;
|
||||
@FXML
|
||||
private Label faction;
|
||||
@FXML
|
||||
private Label government;
|
||||
@FXML
|
||||
private Label distance;
|
||||
@FXML
|
||||
private CheckBox cbMarket;
|
||||
@@ -137,6 +143,8 @@ public class OffersController {
|
||||
sells.clear();
|
||||
buys.clear();
|
||||
distance.setText("");
|
||||
government.setText("");
|
||||
faction.setText("");
|
||||
cbMarket.setSelected(false);
|
||||
cbBlackMarket.setSelected(false);
|
||||
cbMunition.setSelected(false);
|
||||
@@ -146,6 +154,8 @@ public class OffersController {
|
||||
cbMediumLandpad.setSelected(false);
|
||||
cbLargeLandpad.setSelected(false);
|
||||
if (station != null){
|
||||
faction.setText(FactionStringConverter.toLocalizationString(station.getFaction()));
|
||||
government.setText(GovernmentStringConverter.toLocalizationString(station.getGovernment()));
|
||||
distance.setText(String.valueOf(station.getDistance()));
|
||||
cbMarket.setSelected(station.hasService(SERVICE_TYPE.MARKET));
|
||||
cbBlackMarket.setSelected(station.hasService(SERVICE_TYPE.BLACK_MARKET));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.trader.controllers;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.*;
|
||||
@@ -7,15 +8,14 @@ import javafx.util.converter.LongStringConverter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.EMDNUpdater;
|
||||
import ru.trader.core.FACTION;
|
||||
import ru.trader.core.GOVERNMENT;
|
||||
import ru.trader.core.SERVICE_TYPE;
|
||||
import ru.trader.model.ItemModel;
|
||||
import ru.trader.model.StationModel;
|
||||
import ru.trader.model.SystemModel;
|
||||
import ru.trader.model.support.StationUpdater;
|
||||
import ru.trader.view.support.Localization;
|
||||
import ru.trader.view.support.NumberField;
|
||||
import ru.trader.view.support.PriceStringConverter;
|
||||
import ru.trader.view.support.ViewUtils;
|
||||
import ru.trader.view.support.*;
|
||||
import ru.trader.view.support.cells.EditOfferCell;
|
||||
import ru.trader.view.support.cells.TextFieldCell;
|
||||
|
||||
@@ -28,6 +28,12 @@ public class StationEditorController {
|
||||
@FXML
|
||||
private TextField name;
|
||||
|
||||
@FXML
|
||||
private ComboBox<FACTION> faction;
|
||||
|
||||
@FXML
|
||||
private ComboBox<GOVERNMENT> government;
|
||||
|
||||
@FXML
|
||||
private TableView<StationUpdater.FakeOffer> items;
|
||||
@FXML
|
||||
@@ -64,6 +70,10 @@ public class StationEditorController {
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
faction.setItems(FXCollections.observableArrayList(FACTION.values()));
|
||||
faction.setConverter(new FactionStringConverter());
|
||||
government.setItems(FXCollections.observableArrayList(GOVERNMENT.values()));
|
||||
government.setConverter(new GovernmentStringConverter());
|
||||
items.getSelectionModel().setCellSelectionEnabled(true);
|
||||
buy.setCellFactory(EditOfferCell.forTable(new PriceStringConverter(), false));
|
||||
sell.setCellFactory(EditOfferCell.forTable(new PriceStringConverter(), true));
|
||||
@@ -80,10 +90,14 @@ public class StationEditorController {
|
||||
void init(){
|
||||
if (updater != null){
|
||||
name.textProperty().unbindBidirectional(updater.nameProperty());
|
||||
faction.valueProperty().unbindBidirectional(updater.factionProperty());
|
||||
government.valueProperty().unbindBidirectional(updater.governmentProperty());
|
||||
distance.numberProperty().unbindBidirectional(updater.distanceProperty());
|
||||
}
|
||||
updater = new StationUpdater(MainController.getMarket());
|
||||
name.textProperty().bindBidirectional(updater.nameProperty());
|
||||
faction.valueProperty().bindBidirectional(updater.factionProperty());
|
||||
government.valueProperty().bindBidirectional(updater.governmentProperty());
|
||||
distance.numberProperty().bindBidirectional(updater.distanceProperty());
|
||||
cbMarket.selectedProperty().bindBidirectional(updater.serviceProperty(SERVICE_TYPE.MARKET));
|
||||
cbBlackMarket.selectedProperty().bindBidirectional(updater.serviceProperty(SERVICE_TYPE.BLACK_MARKET));
|
||||
|
||||
@@ -4,7 +4,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.core.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class StationModel {
|
||||
@@ -42,6 +43,24 @@ public class StationModel {
|
||||
station.setName(value);
|
||||
}
|
||||
|
||||
public FACTION getFaction() {return station.getFaction();}
|
||||
|
||||
public void setFaction(FACTION faction) {
|
||||
FACTION oldFaction = getFaction();
|
||||
if (oldFaction != null && oldFaction.equals(faction) || faction == null) return;
|
||||
LOG.info("Change faction station {} to {}", station, faction);
|
||||
station.setFaction(faction);
|
||||
}
|
||||
|
||||
public GOVERNMENT getGovernment() {return station.getGovernment();}
|
||||
|
||||
public void setGovernment(GOVERNMENT government) {
|
||||
GOVERNMENT oldGovernment = getGovernment();
|
||||
if (oldGovernment != null && oldGovernment.equals(government) || government == null) return;
|
||||
LOG.info("Change government station {} to {}", station, government);
|
||||
station.setGovernment(government);
|
||||
}
|
||||
|
||||
public double getDistance(){
|
||||
return station.getDistance();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package ru.trader.model;
|
||||
|
||||
import javafx.beans.property.*;
|
||||
import javafx.beans.property.ReadOnlyStringProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.core.Place;
|
||||
import ru.trader.core.SERVICE_TYPE;
|
||||
import ru.trader.core.Vendor;
|
||||
import ru.trader.core.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -52,6 +52,24 @@ public class SystemModel {
|
||||
return name;
|
||||
}
|
||||
|
||||
public FACTION getFaction() {return system.getFaction();}
|
||||
|
||||
public void setFaction(FACTION faction) {
|
||||
FACTION oldFaction = getFaction();
|
||||
if (oldFaction != null && oldFaction.equals(faction) || faction == null) return;
|
||||
LOG.info("Change faction station {} to {}", system, faction);
|
||||
system.setFaction(faction);
|
||||
}
|
||||
|
||||
public GOVERNMENT getGovernment() {return system.getGovernment();}
|
||||
|
||||
public void setGovernment(GOVERNMENT government) {
|
||||
GOVERNMENT oldGovernment = getGovernment();
|
||||
if (oldGovernment != null && oldGovernment.equals(government) || government == null) return;
|
||||
LOG.info("Change government station {} to {}", system, government);
|
||||
system.setGovernment(government);
|
||||
}
|
||||
|
||||
public double getX(){
|
||||
return system.getX();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import javafx.collections.ObservableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.controllers.MainController;
|
||||
import ru.trader.core.FACTION;
|
||||
import ru.trader.core.GOVERNMENT;
|
||||
import ru.trader.core.OFFER_TYPE;
|
||||
import ru.trader.core.SERVICE_TYPE;
|
||||
import ru.trader.model.*;
|
||||
@@ -17,6 +19,8 @@ public class StationUpdater {
|
||||
private final static SERVICE_TYPE[] SERVICE_TYPES = SERVICE_TYPE.values();
|
||||
private final ObservableList<FakeOffer> offers;
|
||||
private final StringProperty name;
|
||||
private final ObjectProperty<FACTION> faction;
|
||||
private final ObjectProperty<GOVERNMENT> government;
|
||||
private final DoubleProperty distance;
|
||||
private final BooleanProperty[] services;
|
||||
private final MarketModel market;
|
||||
@@ -30,6 +34,8 @@ public class StationUpdater {
|
||||
this.offers = BindingsHelper.observableList(MainController.getMarket().itemsProperty(), FakeOffer::new);
|
||||
this.name = new SimpleStringProperty();
|
||||
this.distance = new SimpleDoubleProperty(0);
|
||||
this.faction = new SimpleObjectProperty<>(FACTION.NONE);
|
||||
this.government = new SimpleObjectProperty<>(GOVERNMENT.NONE);
|
||||
this.services = new BooleanProperty[SERVICE_TYPES.length];
|
||||
for (int i = 0; i < services.length; i++) {
|
||||
services[i] = new SimpleBooleanProperty();
|
||||
@@ -54,6 +60,8 @@ public class StationUpdater {
|
||||
}
|
||||
if (station != null){
|
||||
name.setValue(station.getName());
|
||||
faction.setValue(station.getFaction());
|
||||
government.setValue(station.getGovernment());
|
||||
distance.setValue(station.getDistance());
|
||||
for (SERVICE_TYPE service : station.getServices()) {
|
||||
serviceProperty(service).set(true);
|
||||
@@ -62,6 +70,8 @@ public class StationUpdater {
|
||||
station.getBuys().forEach(this::fillOffer);
|
||||
} else {
|
||||
name.setValue("");
|
||||
faction.setValue(FACTION.NONE);
|
||||
government.setValue(GOVERNMENT.NONE);
|
||||
distance.setValue(0);
|
||||
}
|
||||
}
|
||||
@@ -106,6 +116,30 @@ public class StationUpdater {
|
||||
this.name.set(name);
|
||||
}
|
||||
|
||||
public FACTION getFaction() {
|
||||
return faction.get();
|
||||
}
|
||||
|
||||
public ObjectProperty<FACTION> factionProperty() {
|
||||
return faction;
|
||||
}
|
||||
|
||||
public void setFaction(FACTION faction) {
|
||||
this.faction.set(faction);
|
||||
}
|
||||
|
||||
public GOVERNMENT getGovernment() {
|
||||
return government.get();
|
||||
}
|
||||
|
||||
public ObjectProperty<GOVERNMENT> governmentProperty() {
|
||||
return government;
|
||||
}
|
||||
|
||||
public void setGovernment(GOVERNMENT government) {
|
||||
this.government.set(government);
|
||||
}
|
||||
|
||||
public double getDistance() {
|
||||
return distance.get();
|
||||
}
|
||||
@@ -132,6 +166,8 @@ public class StationUpdater {
|
||||
Notificator notificator = market.getNotificator();
|
||||
notificator.setAlert(false);
|
||||
station = system.add(name.get());
|
||||
station.setFaction(faction.get());
|
||||
station.setGovernment(government.get());
|
||||
station.setDistance(distance.get());
|
||||
for (int i = 0; i < services.length; i++) {
|
||||
if (services[i].get()){
|
||||
@@ -143,6 +179,8 @@ public class StationUpdater {
|
||||
notificator.sendAdd(station);
|
||||
} else {
|
||||
station.setName(name.get());
|
||||
station.setFaction(faction.get());
|
||||
station.setGovernment(government.get());
|
||||
station.setDistance(distance.get());
|
||||
for (int i = 0; i < services.length; i++) {
|
||||
if (services[i].get()){
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package ru.trader.view.support;
|
||||
|
||||
|
||||
import javafx.util.StringConverter;
|
||||
import ru.trader.core.FACTION;
|
||||
|
||||
|
||||
public class FactionStringConverter extends StringConverter<FACTION> {
|
||||
|
||||
@Override
|
||||
public String toString(FACTION faction) {
|
||||
return toLocalizationString(faction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FACTION fromString(String faction) {
|
||||
return FACTION.valueOf(faction);
|
||||
}
|
||||
|
||||
public static String toLocalizationString(FACTION faction){
|
||||
if (faction == null) return null;
|
||||
return Localization.getString("faction." + faction.toString(), faction.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package ru.trader.view.support;
|
||||
|
||||
|
||||
import javafx.util.StringConverter;
|
||||
import ru.trader.core.GOVERNMENT;
|
||||
|
||||
|
||||
public class GovernmentStringConverter extends StringConverter<GOVERNMENT> {
|
||||
|
||||
@Override
|
||||
public String toString(GOVERNMENT government) {
|
||||
return toLocalizationString(government);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GOVERNMENT fromString(String government) {
|
||||
return GOVERNMENT.valueOf(government);
|
||||
}
|
||||
|
||||
public static String toLocalizationString(GOVERNMENT government){
|
||||
if (government == null) return null;
|
||||
return Localization.getString("government." + government.toString(), government.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,24 @@
|
||||
faction.FEDERATION=Federation
|
||||
faction.EMPIRE=Empire
|
||||
faction.ALLIANCE=Alliance
|
||||
faction.INDEPENDENT=Independent
|
||||
faction.NONE=None
|
||||
|
||||
government.ANARCHY=Anarchy
|
||||
government.COLONY=Colony
|
||||
government.COMMUNISM=Communism
|
||||
government.CONFEDERACY=Confederacy
|
||||
government.COOPERATIVE=Cooperative
|
||||
government.CORPORATE=Corporate
|
||||
government.DEMOCRACY=Democracy
|
||||
government.DICTATORSHIP=Dictatorship
|
||||
government.FEUDAL=Feudal
|
||||
government.IMPERIAL=Imperial
|
||||
government.PATRONAGE=Patronage
|
||||
government.PRISON_COLONY=Prison colony
|
||||
government.THEOCRACY=Theocracy
|
||||
government.NONE=None
|
||||
|
||||
services.MARKET=Commodities
|
||||
services.BLACK_MARKET=Black Market
|
||||
services.REPAIR=Repair
|
||||
@@ -6,6 +27,7 @@ services.OUTFIT=Outfit
|
||||
services.SHIPYARD=Shipyard
|
||||
services.MEDIUM_LANDPAD=Medium Pad
|
||||
services.LARGE_LANDPAD=Large Pad
|
||||
|
||||
item.group.chemicals=Chemicals
|
||||
item.explosives=Explosives
|
||||
item.hydrogenfuel=Hydrogen Fuel
|
||||
|
||||
@@ -8,6 +8,8 @@ market.offers=Offers
|
||||
market.item.name=Commodity
|
||||
market.system.name=System
|
||||
market.station.name=Station
|
||||
market.allegiance=Allegiance
|
||||
market.government=Government
|
||||
|
||||
# Offer
|
||||
market.offer.buy=Buy
|
||||
|
||||
@@ -8,6 +8,8 @@ market.offers=\u0417\u0430\u043A\u0430\u0437\u044B
|
||||
market.item.name=\u0422\u043E\u0432\u0430\u0440
|
||||
market.system.name=\u0421\u0438\u0441\u0442\u0435\u043C\u0430
|
||||
market.station.name=\u0421\u0442\u0430\u043D\u0446\u0438\u044F
|
||||
market.allegiance=\u041F\u0440\u0438\u043D\u0430\u0434\u043B\u0435\u0436\u043D\u043E\u0441\u0442\u044C
|
||||
market.government=\u0424\u043E\u0440\u043C\u0430 \u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u044F
|
||||
|
||||
# Offer
|
||||
market.offer.buy=\u041F\u043E\u043A\u0443\u043F\u043A\u0430
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
main.menu.settings.language.item=\u0420\u0443\u0441\u0441\u043A\u0438\u0439
|
||||
|
||||
faction.FEDERATION=\u0424\u0435\u0434\u0435\u0440\u0430\u0446\u0438\u044F
|
||||
faction.EMPIRE=\u0418\u043C\u043F\u0435\u0440\u0438\u044F
|
||||
faction.ALLIANCE=\u0410\u043B\u044C\u044F\u043D\u0441
|
||||
faction.INDEPENDENT=\u041D\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u044B\u0435
|
||||
faction.NONE=\u041D\u0435\u0442
|
||||
|
||||
government.ANARCHY=\u0410\u043D\u0430\u0440\u0445\u0438\u044F
|
||||
government.COLONY=\u041A\u043E\u043B\u043E\u043D\u0438\u044F
|
||||
government.COMMUNISM=\u041A\u043E\u043C\u043C\u0443\u043D\u0438\u0437\u043C
|
||||
government.CONFEDERACY=\u041A\u043E\u043D\u0444\u0435\u0434\u0435\u0440\u0430\u0446\u0438\u044F
|
||||
government.COOPERATIVE=\u041A\u043E\u043E\u043F\u0435\u0440\u0430\u0446\u0438\u044F
|
||||
government.CORPORATE=\u041A\u043E\u0440\u043F\u043E\u0440\u0430\u0442\u0438\u0432\u043D\u0430\u044F
|
||||
government.DEMOCRACY=\u0414\u0435\u043C\u043E\u043A\u0440\u0430\u0442\u0438\u044F
|
||||
government.DICTATORSHIP=\u0414\u0438\u043A\u0442\u0430\u0442\u0443\u0440\u0430
|
||||
government.FEUDAL=\u0424\u0435\u043E\u0434\u0430\u043B\u044C\u043D\u0430\u044F
|
||||
government.IMPERIAL=\u0418\u043C\u043F\u0435\u0440\u0441\u043A\u0430\u044F
|
||||
government.PATRONAGE=\u041F\u043E\u043F\u0435\u0447\u0438\u0442\u0435\u043B\u044C\u0441\u0442\u0432\u043E
|
||||
government.PRISON_COLONY=\u0422\u044E\u0440\u0435\u043C\u043D\u0430\u044F \u043A\u043E\u043B\u043E\u043D\u0438\u044F
|
||||
government.THEOCRACY=\u0422\u0435\u043E\u043A\u0440\u0430\u0442\u0438\u044F
|
||||
government.NONE=\u041D\u0435\u0442
|
||||
|
||||
services.MARKET=\u0420\u044B\u043D\u043E\u043A
|
||||
services.BLACK_MARKET=\u0427\u0435\u0440\u043D\u044B\u0439 \u0440\u044B\u043D\u043E\u043A
|
||||
services.REPAIR=\u0420\u0435\u043C\u043E\u043D\u0442
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.control.cell.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<?import javafx.scene.control.cell.PropertyValueFactory?>
|
||||
<?import ru.trader.view.support.cells.PriceCellImpl?>
|
||||
<?import ru.trader.view.support.cells.OfferCellValueImpl?>
|
||||
|
||||
<?import ru.trader.view.support.cells.DoubleCell?>
|
||||
<?import org.controlsfx.glyphfont.Glyph?>
|
||||
<?import org.controlsfx.control.SegmentedButton?>
|
||||
<?import ru.trader.view.support.cells.*?>
|
||||
<GridPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="ru.trader.controllers.OffersController">
|
||||
|
||||
@@ -39,9 +34,16 @@
|
||||
<SegmentedButton fx:id="stationsBar" />
|
||||
</TitledPane>
|
||||
<TitledPane GridPane.rowIndex="1" GridPane.columnIndex="1" text="" maxHeight="60" collapsible="false">
|
||||
<HBox spacing="4">
|
||||
<Label text="%offers.text.distance"/>
|
||||
<Label fx:id="distance" minWidth="60"/>
|
||||
<VBox>
|
||||
<HBox spacing="4">
|
||||
<Label text="%offers.text.distance"/>
|
||||
<Label fx:id="distance" minWidth="60"/>
|
||||
<Label text="%market.allegiance"/>
|
||||
<Label fx:id="faction" minWidth="60"/>
|
||||
<Label text="%market.government"/>
|
||||
<Label fx:id="government" minWidth="60"/>
|
||||
</HBox>
|
||||
<HBox spacing="4">
|
||||
<Label text="%offers.text.services"/>
|
||||
<HBox spacing="15">
|
||||
<CheckBox fx:id="cbMarket" text="%services.MARKET"/>
|
||||
@@ -54,6 +56,7 @@
|
||||
<CheckBox fx:id="cbLargeLandpad" text="%services.LARGE_LANDPAD"/>
|
||||
</HBox>
|
||||
</HBox>
|
||||
</VBox>
|
||||
|
||||
</TitledPane>
|
||||
<Accordion GridPane.rowIndex="2" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.control.cell.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<?import javafx.scene.control.cell.PropertyValueFactory?>
|
||||
|
||||
|
||||
<?import org.controlsfx.glyphfont.Glyph?>
|
||||
<?import ru.trader.view.support.NumberField?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8"
|
||||
fx:controller="ru.trader.controllers.StationEditorController" styleClass="dialog"
|
||||
vgap="10" hgap="4">
|
||||
<fx:define><Insets fx:id="hbox_margin" left="10" /></fx:define>
|
||||
<TextField fx:id="name" GridPane.columnSpan="2" alignment="CENTER" />
|
||||
<HBox GridPane.rowIndex="1" GridPane.columnIndex="1" spacing="4">
|
||||
<HBox GridPane.rowIndex="1" GridPane.columnSpan="2" spacing="10" alignment="CENTER">
|
||||
<VBox prefWidth="200" alignment="CENTER">
|
||||
<Label text="%market.allegiance"/>
|
||||
<ComboBox fx:id="faction" maxWidth="200" />
|
||||
</VBox>
|
||||
<VBox prefWidth="200" alignment="CENTER">
|
||||
<Label text="%market.government"/>
|
||||
<ComboBox fx:id="government" maxWidth="200" />
|
||||
</VBox>
|
||||
</HBox>
|
||||
<HBox GridPane.rowIndex="2" GridPane.columnIndex="1" spacing="4">
|
||||
<VBox prefWidth="200" alignment="CENTER">
|
||||
<Label text="%vEditor.text.distance"/>
|
||||
<NumberField fx:id="distance" maxWidth="60" />
|
||||
@@ -33,13 +41,13 @@
|
||||
</TilePane>
|
||||
</VBox>
|
||||
</HBox>
|
||||
<VBox GridPane.rowIndex="2" alignment="CENTER" spacing="10">
|
||||
<VBox GridPane.rowIndex="3" alignment="CENTER" spacing="10">
|
||||
<Button prefWidth="30" onAction="#up"><graphic><Glyph text="FontAwesome|ARROW_UP"/></graphic></Button>
|
||||
<Button prefWidth="30" onAction="#down"><graphic><Glyph text="FontAwesome|ARROW_DOWN"/></graphic></Button>
|
||||
<Button prefWidth="30" onAction="#add"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button>
|
||||
<Button prefWidth="30" onAction="#updateFromEMDN"><graphic><Glyph text="FontAwesome|REFRESH"/></graphic></Button>
|
||||
</VBox>
|
||||
<TableView fx:id="items" prefWidth="575" editable="true" GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||
<TableView fx:id="items" prefWidth="575" editable="true" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||
<columns>
|
||||
<TableColumn minWidth="200.0" text="%market.item.name" editable="false">
|
||||
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
||||
|
||||
@@ -75,6 +75,26 @@ public abstract class AbstractItemStat implements ItemStat {
|
||||
throw new UnsupportedOperationException("Is fake place, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FACTION getFaction() {
|
||||
return FACTION.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFaction(FACTION faction) {
|
||||
throw new UnsupportedOperationException("Is fake place, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GOVERNMENT getGovernment() {
|
||||
return GOVERNMENT.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGovernment(GOVERNMENT government) {
|
||||
throw new UnsupportedOperationException("Is fake place, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return 0;
|
||||
@@ -132,6 +152,26 @@ public abstract class AbstractItemStat implements ItemStat {
|
||||
throw new UnsupportedOperationException("Is fake vendor, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FACTION getFaction() {
|
||||
return FACTION.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFaction(FACTION faction) {
|
||||
throw new UnsupportedOperationException("Is fake vendor, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GOVERNMENT getGovernment() {
|
||||
return GOVERNMENT.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGovernment(GOVERNMENT government) {
|
||||
throw new UnsupportedOperationException("Is fake vendor, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Place getPlace() {
|
||||
return FAKE_PLACE;
|
||||
|
||||
@@ -110,6 +110,14 @@ public abstract class AbstractMarket implements Market {
|
||||
place.updateName(name);
|
||||
}
|
||||
|
||||
protected void updateFaction(AbstractPlace place, FACTION faction){
|
||||
place.updateFaction(faction);
|
||||
}
|
||||
|
||||
protected void updateGovernment(AbstractPlace place, GOVERNMENT government){
|
||||
place.updateGovernment(government);
|
||||
}
|
||||
|
||||
protected void updatePosition(AbstractPlace place, double x, double y, double z){
|
||||
place.updatePosition(x, y, z);
|
||||
}
|
||||
@@ -118,6 +126,14 @@ public abstract class AbstractMarket implements Market {
|
||||
vendor.updateName(name);
|
||||
}
|
||||
|
||||
protected void updateFaction(AbstractVendor vendor, FACTION faction){
|
||||
vendor.updateFaction(faction);
|
||||
}
|
||||
|
||||
protected void updateGovernment(AbstractVendor vendor, GOVERNMENT government){
|
||||
vendor.updateGovernment(government);
|
||||
}
|
||||
|
||||
protected void updatePrice(AbstractOffer offer, double price){
|
||||
ItemStat itemStat = getStat(offer);
|
||||
if (itemStat instanceof AbstractItemStat){
|
||||
|
||||
@@ -13,6 +13,8 @@ public abstract class AbstractPlace implements Place {
|
||||
|
||||
protected abstract Vendor createVendor(String name);
|
||||
protected abstract void updateName(String name);
|
||||
protected abstract void updateFaction(FACTION faction);
|
||||
protected abstract void updateGovernment(GOVERNMENT government);
|
||||
protected abstract void updatePosition(double x, double y, double z);
|
||||
protected abstract void addVendor(Vendor vendor);
|
||||
protected abstract void removeVendor(Vendor vendor);
|
||||
@@ -48,6 +50,29 @@ public abstract class AbstractPlace implements Place {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setFaction(FACTION faction){
|
||||
if (market != null){
|
||||
LOG.debug("Change faction of place {} to {}", this, faction);
|
||||
market.updateFaction(this, faction);
|
||||
market.setChange(true);
|
||||
} else {
|
||||
updateFaction(faction);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setGovernment(GOVERNMENT government){
|
||||
if (market != null){
|
||||
LOG.debug("Change government of place {} to {}", this, government);
|
||||
market.updateGovernment(this, government);
|
||||
market.setChange(true);
|
||||
} else {
|
||||
updateGovernment(government);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void add(Vendor vendor) {
|
||||
if (market != null){
|
||||
|
||||
@@ -12,6 +12,8 @@ public abstract class AbstractVendor implements Vendor {
|
||||
|
||||
protected abstract Offer createOffer(OFFER_TYPE type, Item item, double price, long count);
|
||||
protected abstract void updateName(String name);
|
||||
protected abstract void updateFaction(FACTION faction);
|
||||
protected abstract void updateGovernment(GOVERNMENT government);
|
||||
protected abstract void updateDistance(double distance);
|
||||
protected abstract void addService(SERVICE_TYPE service);
|
||||
protected abstract void removeService(SERVICE_TYPE service);
|
||||
@@ -38,6 +40,30 @@ public abstract class AbstractVendor implements Vendor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setFaction(FACTION faction){
|
||||
AbstractMarket market = getMarket();
|
||||
if (market != null){
|
||||
LOG.debug("Change faction of vendor {} to {}", this, faction);
|
||||
market.updateFaction(this, faction);
|
||||
market.setChange(true);
|
||||
} else {
|
||||
updateFaction(faction);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setGovernment(GOVERNMENT government){
|
||||
AbstractMarket market = getMarket();
|
||||
if (market != null){
|
||||
LOG.debug("Change government of vendor {} to {}", this, government);
|
||||
market.updateGovernment(this, government);
|
||||
market.setChange(true);
|
||||
} else {
|
||||
updateGovernment(government);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setDistance(double distance) {
|
||||
AbstractMarket market = getMarket();
|
||||
|
||||
5
core/src/main/java/ru/trader/core/FACTION.java
Normal file
5
core/src/main/java/ru/trader/core/FACTION.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package ru.trader.core;
|
||||
|
||||
public enum FACTION {
|
||||
FEDERATION, EMPIRE, ALLIANCE, INDEPENDENT, NONE
|
||||
}
|
||||
7
core/src/main/java/ru/trader/core/GOVERNMENT.java
Normal file
7
core/src/main/java/ru/trader/core/GOVERNMENT.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package ru.trader.core;
|
||||
|
||||
public enum GOVERNMENT {
|
||||
ANARCHY, COLONY, COMMUNISM, CONFEDERACY, COOPERATIVE, CORPORATE,
|
||||
DEMOCRACY, DICTATORSHIP, FEUDAL, IMPERIAL, PATRONAGE, PRISON_COLONY,
|
||||
THEOCRACY, NONE
|
||||
}
|
||||
@@ -90,6 +90,8 @@ public interface Market {
|
||||
} else {
|
||||
nPlace.setPosition(place.getX(), place.getY(), place.getZ());
|
||||
}
|
||||
nPlace.setFaction(place.getFaction());
|
||||
nPlace.setGovernment(place.getGovernment());
|
||||
for (Vendor vendor : place.get()) {
|
||||
Vendor nVendor = nPlace.get(vendor.getName());
|
||||
if (nVendor == null){
|
||||
@@ -102,6 +104,8 @@ public interface Market {
|
||||
if (vendor.getDistance() > 0){
|
||||
nVendor.setDistance(vendor.getDistance());
|
||||
}
|
||||
nVendor.setFaction(vendor.getFaction());
|
||||
nVendor.setGovernment(vendor.getGovernment());
|
||||
// add offers
|
||||
for (Offer offer : vendor.getAllBuyOffers()) {
|
||||
Offer nOffer = nVendor.get(offer.getType(), mapItems.get(offer.getItem()));
|
||||
|
||||
@@ -16,6 +16,12 @@ public interface Place extends Connectable<Place> {
|
||||
double getZ();
|
||||
void setPosition(double x, double y, double z);
|
||||
|
||||
FACTION getFaction();
|
||||
void setFaction(FACTION faction);
|
||||
|
||||
GOVERNMENT getGovernment();
|
||||
void setGovernment(GOVERNMENT government);
|
||||
|
||||
Collection<Vendor> get();
|
||||
default Collection<Vendor> get(boolean withTransit){
|
||||
if (withTransit){
|
||||
|
||||
@@ -22,6 +22,26 @@ public class TransitVendor implements Vendor {
|
||||
throw new UnsupportedOperationException("Is fake vendor, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FACTION getFaction() {
|
||||
return FACTION.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFaction(FACTION faction) {
|
||||
throw new UnsupportedOperationException("Is fake vendor, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GOVERNMENT getGovernment() {
|
||||
return GOVERNMENT.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGovernment(GOVERNMENT government) {
|
||||
throw new UnsupportedOperationException("Is fake vendor, change unsupported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Place getPlace() {
|
||||
return place;
|
||||
|
||||
@@ -15,6 +15,12 @@ public interface Vendor extends Connectable<Vendor> {
|
||||
double getDistance();
|
||||
void setDistance(double distance);
|
||||
|
||||
FACTION getFaction();
|
||||
void setFaction(FACTION faction);
|
||||
|
||||
GOVERNMENT getGovernment();
|
||||
void setGovernment(GOVERNMENT government);
|
||||
|
||||
void add(SERVICE_TYPE service);
|
||||
void remove(SERVICE_TYPE service);
|
||||
boolean has(SERVICE_TYPE service);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package ru.trader.store.berkeley;
|
||||
|
||||
import ru.trader.core.AbstractPlace;
|
||||
import ru.trader.core.FACTION;
|
||||
import ru.trader.core.GOVERNMENT;
|
||||
import ru.trader.core.Vendor;
|
||||
import ru.trader.store.berkeley.entities.BDBPlace;
|
||||
import ru.trader.store.berkeley.entities.BDBVendor;
|
||||
@@ -45,6 +47,18 @@ public class PlaceProxy extends AbstractPlace {
|
||||
store.getPlaceAccessor().update(place);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateFaction(FACTION faction) {
|
||||
place.setFaction(faction);
|
||||
store.getPlaceAccessor().update(place);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGovernment(GOVERNMENT government) {
|
||||
place.setGovernment(government);
|
||||
store.getPlaceAccessor().update(place);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updatePosition(double x, double y, double z) {
|
||||
place.setPosition(x, y, z);
|
||||
@@ -80,6 +94,16 @@ public class PlaceProxy extends AbstractPlace {
|
||||
return place.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FACTION getFaction() {
|
||||
return place.getFaction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GOVERNMENT getGovernment() {
|
||||
return place.getGovernment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return place.getX();
|
||||
|
||||
@@ -86,6 +86,18 @@ public class VendorProxy extends AbstractVendor {
|
||||
store.getVendorAccessor().update(vendor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateFaction(FACTION faction) {
|
||||
vendor.setFaction(faction);
|
||||
store.getVendorAccessor().update(vendor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGovernment(GOVERNMENT government) {
|
||||
vendor.setGovernment(government);
|
||||
store.getVendorAccessor().update(vendor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateDistance(double distance) {
|
||||
vendor.setDistance(distance);
|
||||
@@ -130,6 +142,16 @@ public class VendorProxy extends AbstractVendor {
|
||||
return vendor.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FACTION getFaction() {
|
||||
return vendor.getFaction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GOVERNMENT getGovernment() {
|
||||
return vendor.getGovernment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Place getPlace() {
|
||||
if (place == null){
|
||||
|
||||
@@ -4,8 +4,10 @@ import com.sleepycat.persist.model.Entity;
|
||||
import com.sleepycat.persist.model.PrimaryKey;
|
||||
import com.sleepycat.persist.model.Relationship;
|
||||
import com.sleepycat.persist.model.SecondaryKey;
|
||||
import ru.trader.core.FACTION;
|
||||
import ru.trader.core.GOVERNMENT;
|
||||
|
||||
@Entity(version = 2)
|
||||
@Entity(version = 3)
|
||||
public class BDBPlace {
|
||||
|
||||
@PrimaryKey(sequence = "P_ID")
|
||||
@@ -20,6 +22,8 @@ public class BDBPlace {
|
||||
private double y;
|
||||
private double z;
|
||||
|
||||
private FACTION faction;
|
||||
private GOVERNMENT government;
|
||||
|
||||
private BDBPlace() {
|
||||
}
|
||||
@@ -41,6 +45,22 @@ public class BDBPlace {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public FACTION getFaction() {
|
||||
return faction;
|
||||
}
|
||||
|
||||
public void setFaction(FACTION faction) {
|
||||
this.faction = faction;
|
||||
}
|
||||
|
||||
public GOVERNMENT getGovernment() {
|
||||
return government;
|
||||
}
|
||||
|
||||
public void setGovernment(GOVERNMENT government) {
|
||||
this.government = government;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package ru.trader.store.berkeley.entities;
|
||||
|
||||
import com.sleepycat.persist.model.*;
|
||||
import ru.trader.core.FACTION;
|
||||
import ru.trader.core.GOVERNMENT;
|
||||
import ru.trader.core.SERVICE_TYPE;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
@Entity(version = 1)
|
||||
@Entity(version = 2)
|
||||
public class BDBVendor {
|
||||
|
||||
@PrimaryKey(sequence = "V_ID")
|
||||
@@ -16,6 +18,8 @@ public class BDBVendor {
|
||||
relatedEntity = BDBPlace.class, onRelatedEntityDelete = DeleteAction.CASCADE)
|
||||
private long placeId;
|
||||
private String name;
|
||||
private FACTION faction;
|
||||
private GOVERNMENT government;
|
||||
private double distance;
|
||||
|
||||
@SecondaryKey(relate=Relationship.MANY_TO_MANY)
|
||||
@@ -41,6 +45,22 @@ public class BDBVendor {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public FACTION getFaction() {
|
||||
return faction;
|
||||
}
|
||||
|
||||
public void setFaction(FACTION faction) {
|
||||
this.faction = faction;
|
||||
}
|
||||
|
||||
public GOVERNMENT getGovernment() {
|
||||
return government;
|
||||
}
|
||||
|
||||
public void setGovernment(GOVERNMENT government) {
|
||||
this.government = government;
|
||||
}
|
||||
|
||||
public long getPlaceId() {
|
||||
return placeId;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ public class MarketDocHandler extends DefaultHandler {
|
||||
protected final static String X_ATTR = "x";
|
||||
protected final static String Y_ATTR = "y";
|
||||
protected final static String Z_ATTR = "z";
|
||||
protected final static String FACTION_ATTR = "faction";
|
||||
protected final static String GOVERNMENT_ATTR = "government";
|
||||
|
||||
protected SimpleMarket world;
|
||||
protected Vendor curVendor;
|
||||
@@ -86,15 +88,22 @@ public class MarketDocHandler extends DefaultHandler {
|
||||
String x = attributes.getValue(X_ATTR);
|
||||
String y = attributes.getValue(Y_ATTR);
|
||||
String z = attributes.getValue(Z_ATTR);
|
||||
LOG.debug("parse place {} position ({};{};{})", name, x, y, z);
|
||||
onPlace(name, x != null ? Double.valueOf(x) : 0, y != null ? Double.valueOf(y) : 0, z != null ? Double.valueOf(z) : 0);
|
||||
String faction = attributes.getValue(FACTION_ATTR);
|
||||
String government = attributes.getValue(GOVERNMENT_ATTR);
|
||||
LOG.debug("parse place {} position ({};{};{}), faction {}, government {}", name, x, y, z, faction, government);
|
||||
onPlace(name, x != null ? Double.valueOf(x) : 0, y != null ? Double.valueOf(y) : 0, z != null ? Double.valueOf(z) : 0,
|
||||
faction != null ? FACTION.valueOf(faction) : null, government != null ? GOVERNMENT.valueOf(government) : null
|
||||
);
|
||||
}
|
||||
|
||||
protected void parseVendor(Attributes attributes) throws SAXException {
|
||||
String name = attributes.getValue(NAME_ATTR);
|
||||
String distance = attributes.getValue(DISTANCE_ATTR);
|
||||
LOG.debug("parse vendor {}, distance {}", name, distance);
|
||||
onVendor(name, distance != null ? Double.valueOf(distance) : 0);
|
||||
String faction = attributes.getValue(FACTION_ATTR);
|
||||
String government = attributes.getValue(GOVERNMENT_ATTR);
|
||||
LOG.debug("parse vendor {}, distance {}, faction {}, government {}", name, distance, faction, government);
|
||||
onVendor(name, distance != null ? Double.valueOf(distance) : 0,
|
||||
faction != null ? FACTION.valueOf(faction) : null, government != null ? GOVERNMENT.valueOf(government) : null);
|
||||
}
|
||||
|
||||
protected void parseService(Attributes attributes) throws SAXException {
|
||||
@@ -133,13 +142,17 @@ public class MarketDocHandler extends DefaultHandler {
|
||||
curVendor.addOffer(offerType, item, price, count);
|
||||
}
|
||||
|
||||
protected void onPlace(String name, double x, double y, double z){
|
||||
protected void onPlace(String name, double x, double y, double z, FACTION faction, GOVERNMENT government){
|
||||
curPlace = world.addPlace(name, x, y, z);
|
||||
curPlace.setFaction(faction);
|
||||
curPlace.setGovernment(government);
|
||||
}
|
||||
|
||||
protected void onVendor(String name, double distance){
|
||||
protected void onVendor(String name, double distance, FACTION faction, GOVERNMENT government){
|
||||
curVendor = curPlace.addVendor(name);
|
||||
curVendor.setDistance(distance);
|
||||
curVendor.setFaction(faction);
|
||||
curVendor.setGovernment(government);
|
||||
}
|
||||
|
||||
protected void onService(SERVICE_TYPE type){
|
||||
|
||||
@@ -79,6 +79,12 @@ public class MarketStreamWriter {
|
||||
protected void writePlace(Place place) throws XMLStreamException {
|
||||
out.writeStartElement(MarketDocHandler.PLACE);
|
||||
out.writeAttribute(MarketDocHandler.NAME_ATTR, place.getName());
|
||||
if (place.getFaction() != null) {
|
||||
out.writeAttribute(MarketDocHandler.FACTION_ATTR, String.valueOf(place.getFaction()));
|
||||
}
|
||||
if (place.getGovernment() != null) {
|
||||
out.writeAttribute(MarketDocHandler.GOVERNMENT_ATTR, String.valueOf(place.getGovernment()));
|
||||
}
|
||||
out.writeAttribute(MarketDocHandler.X_ATTR, String.valueOf(place.getX()));
|
||||
out.writeAttribute(MarketDocHandler.Y_ATTR, String.valueOf(place.getY()));
|
||||
out.writeAttribute(MarketDocHandler.Z_ATTR, String.valueOf(place.getZ()));
|
||||
@@ -91,6 +97,12 @@ public class MarketStreamWriter {
|
||||
protected void writeVendor(Vendor vendor) throws XMLStreamException {
|
||||
out.writeStartElement(MarketDocHandler.VENDOR);
|
||||
out.writeAttribute(MarketDocHandler.NAME_ATTR, vendor.getName());
|
||||
if (vendor.getFaction() != null) {
|
||||
out.writeAttribute(MarketDocHandler.FACTION_ATTR, String.valueOf(vendor.getFaction()));
|
||||
}
|
||||
if (vendor.getGovernment() != null) {
|
||||
out.writeAttribute(MarketDocHandler.GOVERNMENT_ATTR, String.valueOf(vendor.getGovernment()));
|
||||
}
|
||||
out.writeAttribute(MarketDocHandler.DISTANCE_ATTR, String.valueOf(vendor.getDistance()));
|
||||
out.writeStartElement(MarketDocHandler.SERVICES_LIST);
|
||||
for (SERVICE_TYPE service_type : vendor.getServices()) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package ru.trader.store.simple;
|
||||
|
||||
import ru.trader.core.AbstractPlace;
|
||||
import ru.trader.core.FACTION;
|
||||
import ru.trader.core.GOVERNMENT;
|
||||
import ru.trader.core.Vendor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -15,6 +17,9 @@ public class SimplePlace extends AbstractPlace {
|
||||
private double y;
|
||||
private double z;
|
||||
|
||||
private FACTION faction;
|
||||
private GOVERNMENT government;
|
||||
|
||||
public SimplePlace(String name) {
|
||||
this.name = name;
|
||||
this.vendors = new CopyOnWriteArrayList<>();
|
||||
@@ -40,6 +45,16 @@ public class SimplePlace extends AbstractPlace {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FACTION getFaction() {
|
||||
return faction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GOVERNMENT getGovernment() {
|
||||
return government;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return x;
|
||||
@@ -65,6 +80,16 @@ public class SimplePlace extends AbstractPlace {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateFaction(FACTION faction) {
|
||||
this.faction = faction;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGovernment(GOVERNMENT government) {
|
||||
this.government = government;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updatePosition(double x, double y, double z) {
|
||||
this.x = x;
|
||||
|
||||
@@ -2,7 +2,9 @@ package ru.trader.store.simple;
|
||||
|
||||
import ru.trader.core.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SimpleVendor extends AbstractVendor {
|
||||
@@ -10,6 +12,8 @@ public class SimpleVendor extends AbstractVendor {
|
||||
private Place place;
|
||||
private double distance;
|
||||
private EnumSet<SERVICE_TYPE> services = EnumSet.noneOf(SERVICE_TYPE.class);
|
||||
private FACTION faction;
|
||||
private GOVERNMENT government;
|
||||
|
||||
protected Map<Item, Offer> sell;
|
||||
protected Map<Item, Offer> buy;
|
||||
@@ -48,6 +52,27 @@ public class SimpleVendor extends AbstractVendor {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FACTION getFaction() {
|
||||
return faction;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateFaction(FACTION faction) {
|
||||
this.faction = faction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GOVERNMENT getGovernment() {
|
||||
return government;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGovernment(GOVERNMENT government) {
|
||||
this.government = government;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Place getPlace() {
|
||||
return place;
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
<xs:element name="vendor" type="vendorType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="xs:string" use="required"/>
|
||||
<xs:attribute name="faction" type="FACTION" use="optional"/>
|
||||
<xs:attribute name="government" type="GOVERNMENT" use="optional"/>
|
||||
<xs:attribute name="x" type="xs:double" use="optional"/>
|
||||
<xs:attribute name="y" type="xs:double" use="optional"/>
|
||||
<xs:attribute name="z" type="xs:double" use="optional"/>
|
||||
@@ -66,6 +68,8 @@
|
||||
<xs:element name="offer" type="offerType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="xs:string" use="required"/>
|
||||
<xs:attribute name="faction" type="FACTION" use="optional"/>
|
||||
<xs:attribute name="government" type="GOVERNMENT" use="optional"/>
|
||||
<xs:attribute name="distance" type="xs:double"/>
|
||||
</xs:complexType>
|
||||
|
||||
@@ -99,4 +103,33 @@
|
||||
<xs:enumeration value="BUY"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="FACTION">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="FEDERATION"/>
|
||||
<xs:enumeration value="EMPIRE"/>
|
||||
<xs:enumeration value="ALLIANCE"/>
|
||||
<xs:enumeration value="INDEPENDENT"/>
|
||||
<xs:enumeration value="NONE"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="GOVERNMENT">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="ANARCHY"/>
|
||||
<xs:enumeration value="COLONY"/>
|
||||
<xs:enumeration value="COMMUNISM"/>
|
||||
<xs:enumeration value="CONFEDERACY"/>
|
||||
<xs:enumeration value="COOPERATIVE"/>
|
||||
<xs:enumeration value="CORPORATE"/>
|
||||
<xs:enumeration value="DEMOCRACY"/>
|
||||
<xs:enumeration value="DICTATORSHIP"/>
|
||||
<xs:enumeration value="FEUDAL"/>
|
||||
<xs:enumeration value="IMPERIAL"/>
|
||||
<xs:enumeration value="PATRONAGE"/>
|
||||
<xs:enumeration value="PRISON_COLONY"/>
|
||||
<xs:enumeration value="THEOCRACY"/>
|
||||
<xs:enumeration value="NONE"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:schema>
|
||||
@@ -5,7 +5,6 @@ import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.xml.sax.SAXException;
|
||||
import ru.trader.TestUtil;
|
||||
import ru.trader.core.*;
|
||||
import ru.trader.store.simple.SimpleMarket;
|
||||
import ru.trader.store.simple.Store;
|
||||
@@ -46,11 +45,15 @@ public class LoadTest extends Assert {
|
||||
assertEquals(place1.getX(), place2.getX(), 0.00001);
|
||||
assertEquals(place1.getY(), place2.getY(), 0.00001);
|
||||
assertEquals(place1.getZ(), place2.getZ(), 0.00001);
|
||||
assertEquals(place1.getFaction(), place2.getFaction());
|
||||
assertEquals(place1.getGovernment(), place2.getGovernment());
|
||||
}
|
||||
|
||||
private void assertVendor(Vendor vendor1, Vendor vendor2){
|
||||
assertEquals(vendor1.getName(), vendor2.getName());
|
||||
assertEquals(vendor1.getDistance(), vendor2.getDistance(), 0.00001);
|
||||
assertEquals(vendor1.getFaction(), vendor2.getFaction());
|
||||
assertEquals(vendor1.getGovernment(), vendor2.getGovernment());
|
||||
}
|
||||
|
||||
private void assertOffer(Offer offer1, Offer offer2){
|
||||
@@ -74,12 +77,16 @@ public class LoadTest extends Assert {
|
||||
Item item4 = market.addItem("Item 4", group2);
|
||||
Item item5 = market.addItem("Item 5", group3);
|
||||
Place place1 = market.addPlace("Place 1", 0, 1, 3);
|
||||
place1.setFaction(FACTION.ALLIANCE);
|
||||
place1.setGovernment(GOVERNMENT.PRISON_COLONY);
|
||||
Place place2 = market.addPlace("Place 2",4,0,5);
|
||||
Place place3 = market.addPlace("Place 3",0,0,0);
|
||||
Vendor vendor1 = place1.addVendor("Vendor 1");
|
||||
Vendor vendor2 = place1.addVendor("Vendor 2");
|
||||
Vendor vendor3 = place2.addVendor("Vendor 3");
|
||||
vendor1.setDistance(10);
|
||||
vendor1.setFaction(FACTION.ALLIANCE);
|
||||
vendor1.setGovernment(GOVERNMENT.ANARCHY);
|
||||
vendor1.add(SERVICE_TYPE.MARKET);
|
||||
vendor1.add(SERVICE_TYPE.OUTFIT);
|
||||
Offer offer1 = vendor1.addOffer(OFFER_TYPE.SELL, item1, 10,43);
|
||||
@@ -89,6 +96,7 @@ public class LoadTest extends Assert {
|
||||
Offer offer5 = vendor1.addOffer(OFFER_TYPE.SELL, item4, 1112,12);
|
||||
Offer offer6 = vendor1.addOffer(OFFER_TYPE.BUY, item5, 11,10);
|
||||
vendor2.setDistance(100.4);
|
||||
vendor2.setGovernment(GOVERNMENT.NONE);
|
||||
vendor3.setDistance(200000.4);
|
||||
vendor3.add(SERVICE_TYPE.OUTFIT);
|
||||
|
||||
|
||||
@@ -2,10 +2,7 @@ package ru.trader.maddavo;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import ru.trader.core.Market;
|
||||
import ru.trader.core.Place;
|
||||
import ru.trader.core.SERVICE_TYPE;
|
||||
import ru.trader.core.Vendor;
|
||||
import ru.trader.core.*;
|
||||
import ru.trader.store.simple.SimpleMarket;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -42,20 +39,27 @@ public class StationImportTest extends Assert {
|
||||
private Market createMarket(){
|
||||
Market market = new SimpleMarket();
|
||||
market.addPlace("1 Hydrae",0,0,0);
|
||||
market.addPlace("1 Kappa Cygni",0,0,0);
|
||||
market.addPlace("1 Kappa Cygni", 0, 0, 0);
|
||||
Place system = market.addPlace("10 CANUM VENATICORUM", 0, 0, 0);
|
||||
system.setFaction(FACTION.FEDERATION);
|
||||
system.setGovernment(GOVERNMENT.PRISON_COLONY);
|
||||
|
||||
Vendor station = system.addVendor("Trevithick Hub");
|
||||
station.setDistance(2000);
|
||||
station.add(SERVICE_TYPE.MARKET);
|
||||
station.add(SERVICE_TYPE.BLACK_MARKET);
|
||||
station.add(SERVICE_TYPE.OUTFIT);
|
||||
station.add(SERVICE_TYPE.MEDIUM_LANDPAD);
|
||||
station.setFaction(FACTION.ALLIANCE);
|
||||
station.setGovernment(GOVERNMENT.COMMUNISM);
|
||||
|
||||
station = system.addVendor("Litke Port");
|
||||
station.setDistance(2000);
|
||||
station.add(SERVICE_TYPE.BLACK_MARKET);
|
||||
station.add(SERVICE_TYPE.OUTFIT);
|
||||
station.add(SERVICE_TYPE.SHIPYARD);
|
||||
station.setFaction(FACTION.EMPIRE);
|
||||
station.setGovernment(GOVERNMENT.CONFEDERACY);
|
||||
|
||||
|
||||
system = market.addPlace("Test sys", 0, 0, 0);
|
||||
@@ -88,6 +92,8 @@ public class StationImportTest extends Assert {
|
||||
|
||||
station = market.get("1 Hydrae").get("Voss Hub");
|
||||
assertNotNull(station);
|
||||
assertNull(station.getFaction());
|
||||
assertNull(station.getGovernment());
|
||||
assertEquals(823, station.getDistance(), 0.00001);
|
||||
assertTrue(station.has(SERVICE_TYPE.BLACK_MARKET));
|
||||
assertTrue(station.has(SERVICE_TYPE.MEDIUM_LANDPAD));
|
||||
@@ -108,8 +114,15 @@ public class StationImportTest extends Assert {
|
||||
assertFalse(station.has(SERVICE_TYPE.OUTFIT));
|
||||
assertFalse(station.has(SERVICE_TYPE.MUNITION));
|
||||
|
||||
station = market.get("10 CANUM VENATICORUM").get("Trevithick Hub");
|
||||
Place place = market.get("10 CANUM VENATICORUM");
|
||||
assertNotNull(place);
|
||||
assertEquals(FACTION.FEDERATION, place.getFaction());
|
||||
assertEquals(GOVERNMENT.PRISON_COLONY, place.getGovernment());
|
||||
|
||||
station = place.get("Trevithick Hub");
|
||||
assertNotNull(station);
|
||||
assertEquals(FACTION.ALLIANCE, station.getFaction());
|
||||
assertEquals(GOVERNMENT.COMMUNISM, station.getGovernment());
|
||||
assertEquals(957, station.getDistance(), 0.00001);
|
||||
assertFalse(station.has(SERVICE_TYPE.BLACK_MARKET));
|
||||
assertTrue(station.has(SERVICE_TYPE.MEDIUM_LANDPAD));
|
||||
@@ -121,6 +134,8 @@ public class StationImportTest extends Assert {
|
||||
|
||||
station = market.get("10 CANUM VENATICORUM").get("Litke Port");
|
||||
assertNotNull(station);
|
||||
assertEquals(FACTION.EMPIRE, station.getFaction());
|
||||
assertEquals(GOVERNMENT.CONFEDERACY, station.getGovernment());
|
||||
assertEquals(2000, station.getDistance(), 0.00001);
|
||||
assertTrue(station.has(SERVICE_TYPE.BLACK_MARKET));
|
||||
assertTrue(station.has(SERVICE_TYPE.MEDIUM_LANDPAD));
|
||||
|
||||
Reference in New Issue
Block a user