added option "claimsMustBeConnected" (defaults to false) which requires all faction claims beyond the first to be connected to each other; support for "{FACTION_TITLE}" in chat messages

This commit is contained in:
Brettflan 2011-06-20 21:15:41 -05:00
parent 56cbf54c98
commit 8880d503e2
4 changed files with 22 additions and 2 deletions

View File

@ -76,6 +76,15 @@ public class Board {
FLocation d = flocation.getRelative(0, -1); FLocation d = flocation.getRelative(0, -1);
return faction != getFactionAt(a) || faction != getFactionAt(b) || faction != getFactionAt(c) || faction != getFactionAt(d); return faction != getFactionAt(a) || faction != getFactionAt(b) || faction != getFactionAt(c) || faction != getFactionAt(d);
} }
// Is this coord connected to any coord claimed by the specified faction?
public static boolean isConnectedLocation(FLocation flocation, Faction faction) {
FLocation a = flocation.getRelative(1, 0);
FLocation b = flocation.getRelative(-1, 0);
FLocation c = flocation.getRelative(0, 1);
FLocation d = flocation.getRelative(0, -1);
return faction == getFactionAt(a) || faction == getFactionAt(b) || faction == getFactionAt(c) || faction == getFactionAt(d);
}
//----------------------------------------------// //----------------------------------------------//

View File

@ -65,9 +65,11 @@ public class Conf {
public static boolean homesTeleportToOnDeath = true; public static boolean homesTeleportToOnDeath = true;
public static boolean homesTeleportAllowedFromEnemyTerritory = true; public static boolean homesTeleportAllowedFromEnemyTerritory = true;
public static double homesTeleportAllowedEnemyDistance = 32; public static double homesTeleportAllowedEnemyDistance = 32;
public static boolean disablePVPForFactionlessPlayers = false; public static boolean disablePVPForFactionlessPlayers = false;
public static boolean claimsMustBeConnected = false;
public static double territoryShieldFactor = 0.3; public static double territoryShieldFactor = 0.3;
public static boolean territoryDenyBuild = true; public static boolean territoryDenyBuild = true;
public static boolean territoryDenyBuildWhenOffline = true; public static boolean territoryDenyBuildWhenOffline = true;

View File

@ -487,6 +487,11 @@ public class FPlayer {
return false; return false;
} }
if (Conf.claimsMustBeConnected && !Board.isConnectedLocation(flocation, myFaction)) {
sendMessage("You can only claim additional land which is connected to your first claim!");
return false;
}
if (otherFaction.isNone()) { if (otherFaction.isNone()) {
myFaction.sendMessage(this.getNameAndRelevant(myFaction)+Conf.colorSystem+" claimed some new land :D"); myFaction.sendMessage(this.getNameAndRelevant(myFaction)+Conf.colorSystem+" claimed some new land :D");
} else { //if (otherFaction.isNormal()) { } else { //if (otherFaction.isNormal()) {

View File

@ -73,6 +73,10 @@ public class FactionsPlayerListener extends PlayerListener{
if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString)) { if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString)) {
// we're using the "replace" method of inserting the faction tags // we're using the "replace" method of inserting the faction tags
// if they stuck "{FACTION_TITLE}" in there, go ahead and do it too
if (eventFormat.contains("{FACTION_TITLE}")) {
eventFormat = eventFormat.replace("{FACTION_TITLE}", me.getTitle());
}
InsertIndex = eventFormat.indexOf(Conf.chatTagReplaceString); InsertIndex = eventFormat.indexOf(Conf.chatTagReplaceString);
eventFormat = eventFormat.replace(Conf.chatTagReplaceString, ""); eventFormat = eventFormat.replace(Conf.chatTagReplaceString, "");
Conf.chatTagPadAfter = false; Conf.chatTagPadAfter = false;