apply power effects on illegal items
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package ru.trader.controllers;
|
package ru.trader.controllers;
|
||||||
|
|
||||||
import javafx.beans.InvalidationListener;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
@@ -253,7 +252,7 @@ public class StationEditorController {
|
|||||||
if (entry != null){
|
if (entry != null){
|
||||||
GOVERNMENT g = government.getValue();
|
GOVERNMENT g = government.getValue();
|
||||||
FACTION f = faction.getValue();
|
FACTION f = faction.getValue();
|
||||||
if (entry.getItem().isIllegal(f, g)){
|
if (entry.getItem().isIllegal(updater.getSystem(), f, g)){
|
||||||
styles.add(ViewUtils.ILLEGAL_ITEM_STYLE);
|
styles.add(ViewUtils.ILLEGAL_ITEM_STYLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,8 +148,8 @@ public class ItemModel implements Comparable<ItemModel> {
|
|||||||
item.setLegal(government, legal);
|
item.setLegal(government, legal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIllegal(FACTION faction, GOVERNMENT government){
|
public boolean isIllegal(SystemModel system, FACTION faction, GOVERNMENT government){
|
||||||
return item.isIllegal(faction, government);
|
return item.isIllegal(ModelFabric.get(system), faction, government);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh(){
|
public void refresh(){
|
||||||
|
|||||||
@@ -109,6 +109,10 @@ public class StationUpdater {
|
|||||||
return offers.stream().filter(o -> o.hasItem(item)).findAny();
|
return offers.stream().filter(o -> o.hasItem(item)).findAny();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SystemModel getSystem() {
|
||||||
|
return system;
|
||||||
|
}
|
||||||
|
|
||||||
public StationModel getStation() {
|
public StationModel getStation() {
|
||||||
return station;
|
return station;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,17 @@ public interface Item extends Comparable<Item> {
|
|||||||
default boolean isIllegal(Vendor vendor){
|
default boolean isIllegal(Vendor vendor){
|
||||||
FACTION faction = vendor.getFaction();
|
FACTION faction = vendor.getFaction();
|
||||||
GOVERNMENT government = vendor.getGovernment();
|
GOVERNMENT government = vendor.getGovernment();
|
||||||
return isIllegal(faction, government);
|
return isIllegal(vendor.getPlace(), faction, government);
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean isIllegal(FACTION faction, GOVERNMENT government){
|
default boolean isIllegal(Place place, FACTION faction, GOVERNMENT government){
|
||||||
|
if (place != null){
|
||||||
|
POWER power = place.getPower();
|
||||||
|
if (power != null){
|
||||||
|
if (power.isLegal(faction, this, place.getPowerState())) return false;
|
||||||
|
if (power.isIllegal(faction, this, place.getPowerState())) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (faction != null && getLegalFactions().contains(faction)) return false;
|
if (faction != null && getLegalFactions().contains(faction)) return false;
|
||||||
if (government != null && getLegalGovernments().contains(government)) return false;
|
if (government != null && getLegalGovernments().contains(government)) return false;
|
||||||
return faction != null && getIllegalFactions().contains(faction) ||
|
return faction != null && getIllegalFactions().contains(faction) ||
|
||||||
|
|||||||
@@ -1,15 +1,112 @@
|
|||||||
package ru.trader.core;
|
package ru.trader.core;
|
||||||
|
|
||||||
public enum POWER {
|
public enum POWER {
|
||||||
DUVAL,
|
DUVAL {
|
||||||
DELAINE,
|
// Exploited Systems: Imperial Slaves banned
|
||||||
|
// Control Systems: Imperial Slaves banned
|
||||||
|
@Override
|
||||||
|
public boolean isIllegal(FACTION faction, Item item, POWER_STATE state) {
|
||||||
|
if (state == POWER_STATE.CONTROL || state == POWER_STATE.EXPLOITED){
|
||||||
|
String itemId = item.getName();
|
||||||
|
return itemId != null && IMPERIAL_SLAVES.equals(itemId);
|
||||||
|
}
|
||||||
|
return super.isIllegal(faction, item, state);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
DELAINE {
|
||||||
|
// Control Systems: All weapons/slaves/narcotics legalised
|
||||||
|
@Override
|
||||||
|
public boolean isLegal(FACTION faction, Item item, POWER_STATE state) {
|
||||||
|
if (state == POWER_STATE.CONTROL){
|
||||||
|
String groupId = item.getGroup() != null ? item.getGroup().getName() : null;
|
||||||
|
return groupId != null && (WEAPONS_GRP.equals(groupId) || SLAVES_GRP.equals(groupId) || NARCOTICS_GRP.equals(groupId));
|
||||||
|
}
|
||||||
|
return super.isLegal(faction, item, state);
|
||||||
|
}
|
||||||
|
},
|
||||||
LAVIGNY_DUVAL,
|
LAVIGNY_DUVAL,
|
||||||
PATREUS,
|
PATREUS {
|
||||||
|
// Control Systems: Imperial Slaves legalised
|
||||||
|
@Override
|
||||||
|
public boolean isLegal(FACTION faction, Item item, POWER_STATE state) {
|
||||||
|
if (state == POWER_STATE.CONTROL){
|
||||||
|
String itemId = item.getName();
|
||||||
|
return itemId != null && IMPERIAL_SLAVES.equals(itemId);
|
||||||
|
}
|
||||||
|
return super.isLegal(faction, item, state);
|
||||||
|
}
|
||||||
|
},
|
||||||
MAHON,
|
MAHON,
|
||||||
WINTERS,
|
WINTERS {
|
||||||
|
// Exploited Federal systems: Imperial Slaves banned
|
||||||
|
// Exploited Alliance/Ind systems: Imperial Slaves banned
|
||||||
|
// Control Systems: Imperial Slaves banned
|
||||||
|
@Override
|
||||||
|
public boolean isIllegal(FACTION faction, Item item, POWER_STATE state) {
|
||||||
|
if (state == POWER_STATE.CONTROL){
|
||||||
|
String itemId = item.getName();
|
||||||
|
return itemId != null && IMPERIAL_SLAVES.equals(itemId);
|
||||||
|
} else
|
||||||
|
if (state == POWER_STATE.EXPLOITED){
|
||||||
|
String itemId = item.getName();
|
||||||
|
return itemId != null && IMPERIAL_SLAVES.equals(itemId) && (faction != null && faction != FACTION.EMPIRE);
|
||||||
|
}
|
||||||
|
return super.isIllegal(faction, item, state);
|
||||||
|
}
|
||||||
|
},
|
||||||
YONG_RUI,
|
YONG_RUI,
|
||||||
ANTAL,
|
ANTAL {
|
||||||
HUDSON,
|
// Exploited Systems: All Slaves, Narcotics and non-basic medicines banned
|
||||||
TORVAL,
|
// Control Systems: All Slaves, Narcotics and non-basic medicines banned
|
||||||
NONE
|
@Override
|
||||||
|
public boolean isIllegal(FACTION faction, Item item, POWER_STATE state) {
|
||||||
|
if (state == POWER_STATE.CONTROL || state == POWER_STATE.EXPLOITED){
|
||||||
|
String groupId = item.getGroup() != null ? item.getGroup().getName() : null;
|
||||||
|
String itemId = item.getName();
|
||||||
|
return groupId != null && (SLAVES_GRP.equals(groupId) || NARCOTICS_GRP.equals(groupId)
|
||||||
|
|| MEDICINE_GRP.equals(groupId) && !BASIC_MEDICINES.equals(itemId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return super.isIllegal(faction, item, state);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
HUDSON {
|
||||||
|
// Control Systems: Imperial Slaves banned
|
||||||
|
@Override
|
||||||
|
public boolean isIllegal(FACTION faction, Item item, POWER_STATE state) {
|
||||||
|
if (state == POWER_STATE.CONTROL){
|
||||||
|
String itemId = item.getName();
|
||||||
|
return itemId != null && IMPERIAL_SLAVES.equals(itemId);
|
||||||
|
}
|
||||||
|
return super.isIllegal(faction, item, state);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
TORVAL {
|
||||||
|
// Control Systems: Imperial Slaves legalised
|
||||||
|
@Override
|
||||||
|
public boolean isLegal(FACTION faction, Item item, POWER_STATE state) {
|
||||||
|
if (state == POWER_STATE.CONTROL){
|
||||||
|
String itemId = item.getName();
|
||||||
|
return itemId != null && IMPERIAL_SLAVES.equals(itemId);
|
||||||
|
}
|
||||||
|
return super.isLegal(faction, item, state);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
NONE;
|
||||||
|
|
||||||
|
private final static String WEAPONS_GRP="weapons";
|
||||||
|
private final static String NARCOTICS_GRP="drugs";
|
||||||
|
private final static String SLAVES_GRP="slaves";
|
||||||
|
private final static String MEDICINE_GRP="medicines";
|
||||||
|
private final static String IMPERIAL_SLAVES="imperialslaves";
|
||||||
|
private final static String BASIC_MEDICINES="basicmedicines";
|
||||||
|
|
||||||
|
public boolean isLegal(FACTION faction, Item item, POWER_STATE state){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIllegal(FACTION faction, Item item, POWER_STATE state){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user