Archived
0

Add missing power states

This commit is contained in:
Mo
2016-04-03 13:35:10 +03:00
parent 156171b679
commit b13a14842e
4 changed files with 22 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ public enum POWER {
// 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){
if (state != null && (state.isControl() || state.isExploited())){
String itemId = item.getName();
return itemId != null && IMPERIAL_SLAVES.equals(itemId);
}
@@ -17,7 +17,7 @@ public enum POWER {
// Control Systems: All weapons/slaves/narcotics/medicals legalised
@Override
public boolean isLegal(FACTION faction, Item item, POWER_STATE state) {
if (state == POWER_STATE.CONTROL){
if (state != null && state.isControl()){
String groupId = item.getGroup() != null ? item.getGroup().getName() : null;
return groupId != null && (WEAPONS_GRP.equals(groupId) || SLAVES_GRP.equals(groupId) || NARCOTICS_GRP.equals(groupId) || MEDICINE_GRP.equals(groupId));
}
@@ -29,7 +29,7 @@ public enum POWER {
// Control Systems: Imperial Slaves legalised
@Override
public boolean isLegal(FACTION faction, Item item, POWER_STATE state) {
if (state == POWER_STATE.CONTROL){
if (state != null && state.isControl()){
String itemId = item.getName();
return itemId != null && IMPERIAL_SLAVES.equals(itemId);
}
@@ -43,11 +43,11 @@ public enum POWER {
// Control Systems: Imperial Slaves banned
@Override
public boolean isIllegal(FACTION faction, Item item, POWER_STATE state) {
if (state == POWER_STATE.CONTROL){
if (state != null && state.isControl()){
String itemId = item.getName();
return itemId != null && IMPERIAL_SLAVES.equals(itemId);
} else
if (state == POWER_STATE.EXPLOITED){
if (state != null && state.isExploited()){
String itemId = item.getName();
return itemId != null && IMPERIAL_SLAVES.equals(itemId) && (faction != null && faction != FACTION.EMPIRE);
}
@@ -60,7 +60,7 @@ public enum POWER {
// Control Systems: All Slaves, Narcotics and non-basic/agri medicines banned
@Override
public boolean isIllegal(FACTION faction, Item item, POWER_STATE state) {
if (state == POWER_STATE.CONTROL || state == POWER_STATE.EXPLOITED){
if (state != null && (state.isControl() || state.isExploited())){
String groupId = item.getGroup() != null ? item.getGroup().getName() : null;
String itemId = item.getName();
return groupId != null && (SLAVES_GRP.equals(groupId) || NARCOTICS_GRP.equals(groupId)
@@ -74,7 +74,7 @@ public enum POWER {
// Control Systems: Imperial Slaves banned
@Override
public boolean isIllegal(FACTION faction, Item item, POWER_STATE state) {
if (state == POWER_STATE.CONTROL){
if (state != null && state.isControl()){
String itemId = item.getName();
return itemId != null && IMPERIAL_SLAVES.equals(itemId);
}
@@ -85,7 +85,7 @@ public enum POWER {
// Control Systems: Imperial Slaves legalised
@Override
public boolean isLegal(FACTION faction, Item item, POWER_STATE state) {
if (state == POWER_STATE.CONTROL){
if (state != null && state.isControl()){
String itemId = item.getName();
return itemId != null && IMPERIAL_SLAVES.equals(itemId);
}

View File

@@ -1,5 +1,13 @@
package ru.trader.core;
public enum POWER_STATE {
CONTROL, EXPLOITED, EXPANSION, NONE
CONTROL, EXPLOITED, EXPANSION, NONE, CONTESTED, HEADQUARTERS;
boolean isControl(){
return this == CONTROL || this == HEADQUARTERS;
}
boolean isExploited(){
return this == EXPLOITED;
}
}