New conf.json settings "showNeutralFactionsOnMap" and "showEnemyFactionsOnMap" (both default to true) which, if disabled, will hide neutral and enemy factions on the faction map. However, if a player is standing inside territory claimed by a neutral or enemy faction, all of that faction's nearby claims will be shown on the faction map regardless.

This commit is contained in:
Brettflan 2011-08-01 19:59:48 -05:00
parent ad2bb5f4d0
commit f38651ca94
3 changed files with 24 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.AsciiCompass; import com.massivecraft.factions.util.AsciiCompass;
import com.massivecraft.factions.util.DiscUtil; import com.massivecraft.factions.util.DiscUtil;
import com.massivecraft.factions.util.TextUtil; import com.massivecraft.factions.util.TextUtil;
@ -161,7 +162,8 @@ public class Board {
*/ */
public static ArrayList<String> getMap(Faction faction, FLocation flocation, double inDegrees) { public static ArrayList<String> getMap(Faction faction, FLocation flocation, double inDegrees) {
ArrayList<String> ret = new ArrayList<String>(); ArrayList<String> ret = new ArrayList<String>();
ret.add(TextUtil.titleize("("+flocation.getCoordString()+") "+getFactionAt(flocation).getTag(faction))); Faction factionLoc = getFactionAt(flocation);
ret.add(TextUtil.titleize("("+flocation.getCoordString()+") "+factionLoc.getTag(faction)));
int halfWidth = Conf.mapWidth / 2; int halfWidth = Conf.mapWidth / 2;
int halfHeight = Conf.mapHeight / 2; int halfHeight = Conf.mapHeight / 2;
@ -186,17 +188,26 @@ public class Board {
} else { } else {
FLocation flocationHere = topLeft.getRelative(dx, dz); FLocation flocationHere = topLeft.getRelative(dx, dz);
Faction factionHere = getFactionAt(flocationHere); Faction factionHere = getFactionAt(flocationHere);
Relation relation = faction.getRelation(factionHere);
if (factionHere.isNone()) { if (factionHere.isNone()) {
row += ChatColor.GRAY+"-"; row += ChatColor.GRAY+"-";
} else if (factionHere.isSafeZone()) { } else if (factionHere.isSafeZone()) {
row += ChatColor.GOLD+"+"; row += ChatColor.GOLD+"+";
} else if (factionHere.isWarZone()) { } else if (factionHere.isWarZone()) {
row += ChatColor.DARK_RED+"+"; row += ChatColor.DARK_RED+"+";
} else { } else if (
factionHere == faction
|| factionHere == factionLoc
|| relation.isAtLeast(Relation.ALLY)
|| (Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL))
|| (Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY))
) {
if (!fList.containsKey(factionHere.getTag())) if (!fList.containsKey(factionHere.getTag()))
fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]); fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]);
char tag = fList.get(factionHere.getTag()); char tag = fList.get(factionHere.getTag());
row += factionHere.getRelation(faction).getColor() + "" + tag; row += factionHere.getRelation(faction).getColor() + "" + tag;
} else {
row += ChatColor.GRAY+"-";
} }
} }
} }

View File

@ -40,6 +40,8 @@ public class Conf {
public static boolean newFactionsDefaultOpen = true; public static boolean newFactionsDefaultOpen = true;
public static boolean showMapFactionKey = true; public static boolean showMapFactionKey = true;
public static boolean showNeutralFactionsOnMap = true;
public static boolean showEnemyFactionsOnMap = true;
// Disallow joining/leaving/kicking while power is negative // Disallow joining/leaving/kicking while power is negative
public static boolean CanLeaveWithNegativePower = true; public static boolean CanLeaveWithNegativePower = true;

View File

@ -40,6 +40,14 @@ public enum Relation {
return this == Relation.ENEMY; return this == Relation.ENEMY;
} }
public boolean isAtLeast(Relation relation) {
return this.value >= relation.value;
}
public boolean isAtMost(Relation relation) {
return this.value <= relation.value;
}
public ChatColor getColor() { public ChatColor getColor() {
if (this == Relation.MEMBER) { if (this == Relation.MEMBER) {
return Conf.colorMember; return Conf.colorMember;
@ -47,7 +55,7 @@ public enum Relation {
return Conf.colorAlly; return Conf.colorAlly;
} else if (this == Relation.NEUTRAL) { } else if (this == Relation.NEUTRAL) {
return Conf.colorNeutral; return Conf.colorNeutral;
} else { //if (relation == FactionRelation.ENEMY) { } else {
return Conf.colorEnemy; return Conf.colorEnemy;
} }
} }