add faction and government fields
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user