Fix for allies bypassing ownership if Ally options allowed them to build/interact/use in allied territory

Also consolidated some Conf lookups into new functions for Relations, to simplify and de-uglify the code a bit
This commit is contained in:
Brettflan
2011-09-06 16:35:43 -05:00
parent 55c9067e34
commit c89db2c4d6
4 changed files with 104 additions and 66 deletions

View File

@ -25,19 +25,19 @@ public enum Relation {
}
public boolean isMember() {
return this == Relation.MEMBER;
return this.value == MEMBER.value;
}
public boolean isAlly() {
return this == Relation.ALLY;
return this.value == ALLY.value;
}
public boolean isNeutral() {
return this == Relation.NEUTRAL;
return this.value == NEUTRAL.value;
}
public boolean isEnemy() {
return this == Relation.ENEMY;
return this.value == ENEMY.value;
}
public boolean isAtLeast(Relation relation) {
@ -49,14 +49,79 @@ public enum Relation {
}
public ChatColor getColor() {
if (this == Relation.MEMBER) {
if (this.value == MEMBER.value) {
return Conf.colorMember;
} else if (this == Relation.ALLY) {
} else if (this.value == ALLY.value) {
return Conf.colorAlly;
} else if (this == Relation.NEUTRAL) {
} else if (this.value == NEUTRAL.value) {
return Conf.colorNeutral;
} else {
return Conf.colorEnemy;
}
}
// return appropriate Conf setting for DenyBuild based on this relation and their online status
public boolean confDenyBuild(boolean online) {
if (online) {
if (isEnemy()) {
return Conf.territoryEnemyDenyBuild;
}
else if (isAlly()) {
return Conf.territoryAllyDenyBuild;
}
else {
return Conf.territoryDenyBuild;
}
}
else {
if (isEnemy()) {
return Conf.territoryEnemyDenyBuildWhenOffline;
}
else if (isAlly()) {
return Conf.territoryAllyDenyBuildWhenOffline;
}
else {
return Conf.territoryDenyBuildWhenOffline;
}
}
}
// return appropriate Conf setting for PainBuild based on this relation and their online status
public boolean confPainBuild(boolean online) {
if (online) {
if (isEnemy()) {
return Conf.territoryEnemyPainBuild;
}
else if (isAlly()) {
return Conf.territoryAllyPainBuild;
}
else {
return Conf.territoryPainBuild;
}
}
else {
if (isEnemy()) {
return Conf.territoryEnemyPainBuildWhenOffline;
}
else if (isAlly()) {
return Conf.territoryAllyPainBuildWhenOffline;
}
else {
return Conf.territoryPainBuildWhenOffline;
}
}
}
// return appropriate Conf setting for DenyUseage based on this relation
public boolean confDenyUseage() {
if (isEnemy()) {
return Conf.territoryEnemyDenyUseage;
}
else if (isAlly()) {
return Conf.territoryAllyDenyUseage;
}
else {
return Conf.territoryDenyUseage;
}
}
}