Repair the war claiming if statement. Fixes #708. Fixes #711.

This commit is contained in:
Olof Larsson 2014-12-04 10:49:43 +01:00
parent e5d7749255
commit d23ac9de09

View File

@ -590,40 +590,53 @@ public class EngineMain extends EngineAbstract
} }
// For each of the old factions ... // For each of the old factions ...
for (Faction oldFaction : currentFactions) for (Entry<Faction, Set<PS>> entry : currentFactionChunks.entrySet())
{ {
Faction oldFaction = entry.getKey();
Set<PS> oldChunks = entry.getValue();
// ... that is an actual faction ... // ... that is an actual faction ...
if (oldFaction.isNone()) continue; if (oldFaction.isNone()) continue;
// ... for which the msender lacks permission ... // ... for which the msender lacks permission ...
if (MPerm.getPermTerritory().has(msender, oldFaction, false)) continue; if (MPerm.getPermTerritory().has(msender, oldFaction, false)) continue;
// ... print the error message of choice ... // ... consider all reasons to forbid "overclaiming/warclaiming" ...
if (msender.hasFaction() && msender.getFaction() == oldFaction)
{ // ... claiming from others may be forbidden ...
msender.sendMessage(MPerm.getPermTerritory().createDeniedMessage(msender, oldFaction)); if ( ! MConf.get().claimingFromOthersAllowed)
}
else if ( ! MConf.get().claimingFromOthersAllowed)
{ {
msender.msg("<b>You may not claim land from others."); msender.msg("<b>You may not claim land from others.");
}
else if (oldFaction.getRelationTo(newFaction).isAtLeast(Rel.TRUCE))
{
msender.msg("<b>You can't claim this land due to your relation with the current owner.");
}
else if ( ! oldFaction.hasLandInflation())
{
msender.msg("%s<i> owns this land and is strong enough to keep it.", oldFaction.getName(msender));
}
else if ( ! BoardColl.get().isAnyBorderPs(chunks))
{
msender.msg("<b>You must start claiming land at the border of the territory.");
}
// ... and cancel.
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
// ... the relation may forbid ...
if (oldFaction.getRelationTo(newFaction).isAtLeast(Rel.TRUCE))
{
msender.msg("<b>You can't claim this land due to your relation with the current owner.");
event.setCancelled(true);
return;
}
// ... the old faction might not be inflated enough ...
if (oldFaction.getPowerRounded() > oldFaction.getLandCount() - oldChunks.size())
{
msender.msg("%s<i> owns this land and is strong enough to keep it.", oldFaction.getName(msender));
event.setCancelled(true);
return;
}
// ... and you might be trying to claim without starting at the border ...
if ( ! BoardColl.get().isAnyBorderPs(chunks))
{
msender.msg("<b>You must start claiming land at the border of the territory.");
event.setCancelled(true);
return;
}
// ... otherwise you may claim from this old faction even though you lack explicit permission from them.
}
} }
// -------------------------------------------- // // -------------------------------------------- //