forked from MagicBane/Server
extra sanity checks for claiming an abandoned tree
This commit is contained in:
@@ -17,9 +17,8 @@ import engine.mbEnums.BuildingGroup;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClaimAssetMsg;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.objects.Blueprint;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
@@ -111,9 +110,9 @@ public class ClaimAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
// Can't claim a tree if your guild already owns one
|
||||
// *** Refactor : Send error to player here
|
||||
|
||||
if ((sourcePlayer.getGuild().isNation()) &&
|
||||
(blueprint.getBuildingGroup() == BuildingGroup.TOL))
|
||||
if(blueprint.getBuildingGroup() == BuildingGroup.TOL && !validateTreeClaim(sourcePlayer)){
|
||||
return true;
|
||||
}
|
||||
|
||||
// Process the transfer of the building(s)
|
||||
|
||||
@@ -135,4 +134,24 @@ public class ClaimAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean validateTreeClaim(PlayerCharacter sourcePlayer) {
|
||||
|
||||
if(sourcePlayer.guild.equals(Guild.getErrantGuild())) {
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Errant Players Cannot Claim Cities!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(sourcePlayer.guild.getOwnedCity() != null) {
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Your Guild Already Owns A City!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus())) {
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Only A Guild Leader Can Claim A Tree Of Life!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user