diff --git a/src/engine/net/client/handlers/InviteToSubHandler.java b/src/engine/net/client/handlers/InviteToSubHandler.java index a6a49cd9..777eb88b 100644 --- a/src/engine/net/client/handlers/InviteToSubHandler.java +++ b/src/engine/net/client/handlers/InviteToSubHandler.java @@ -36,8 +36,8 @@ public class InviteToSubHandler extends AbstractClientMsgHandler { PlayerCharacter source; PlayerCharacter target; - Guild sourceGuild; - Guild targetGuild; + Guild nation; + Guild protectorate; InviteToSubMsg msg = (InviteToSubMsg) baseMsg; Dispatch dispatch; @@ -58,17 +58,17 @@ public class InviteToSubHandler extends AbstractClientMsgHandler { if (target.isIgnoringPlayer(source)) return true; - sourceGuild = source.getGuild(); - targetGuild = target.getGuild(); + nation = source.getGuild(); + protectorate = target.getGuild(); //source must be in guild - if (sourceGuild == null) { + if (nation == null) { sendChat(source, "You must be in a guild to invite to sub."); return true; } - if (sourceGuild.isEmptyGuild()) { + if (nation.isEmptyGuild()) { sendChat(source, "You must be in a guild to invite to sub."); return true; } @@ -80,15 +80,15 @@ public class InviteToSubHandler extends AbstractClientMsgHandler { return true; } - if (sourceGuild.getNation().isEmptyGuild()) + if (nation.getNation().isEmptyGuild()) return true; //target must be in a guild - if (targetGuild == null) + if (protectorate == null) return true; - if (sourceGuild.equals(targetGuild)) + if (nation.equals(protectorate)) return true; //target must be GL or IC @@ -98,18 +98,21 @@ public class InviteToSubHandler extends AbstractClientMsgHandler { return true; } - //Can't already be same nation or errant - //source guild is limited to 7 subs - //TODO this should be based on TOL rank - //cannot be subbed into a nation if you already have your own sub guilds - if(targetGuild.getSubGuildList() != null && targetGuild.getSubGuildList().size() > 0) + if (protectorate.getSubGuildList() != null && protectorate.getSubGuildList().size() > 0) { + sendChat(source, "This Guild is already a nation!"); return true; + } - if (!sourceGuild.canSubAGuild(targetGuild)) { + if (!nation.canSubAGuild(protectorate)) { sendChat(source, "This Guild can't be subbed."); return true; } + + if (nation.getSubGuildList().size() >= nation.getOwnedCity().getRank()) { + sendChat(source, "Your TOL cannot support another subguild!"); + return true; + } if (ConfigManager.MB_RULESET.getValue().equals("LORE")) { if (source.guild.getGuildType().equals(target.guild.getGuildType()) == false) { sendChat(source, "You Must Be The Same Charter To Form A Nation."); @@ -119,9 +122,9 @@ public class InviteToSubHandler extends AbstractClientMsgHandler { //all tests passed, let's send invite. if (target.getClientConnection() != null) { - msg.setGuildTag(sourceGuild.getGuildTag()); - msg.setGuildName(sourceGuild.getName()); - msg.setGuildUUID(sourceGuild.getObjectUUID()); + msg.setGuildTag(nation.getGuildTag()); + msg.setGuildName(nation.getName()); + msg.setGuildUUID(nation.getObjectUUID()); msg.setUnknown02(1); dispatch = Dispatch.borrow(target, msg); diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index aac79970..d37efa76 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -629,34 +629,13 @@ public class Guild extends AbstractWorldObject { public boolean canSubAGuild(Guild toSub) { - boolean canSub; - if (this.equals(toSub)) return false; - switch (this.guildState) { - case Nation: - case Sovereign: - canSub = true; - break; - default: - canSub = false; - } - switch (toSub.guildState) { - case Errant: - case Sovereign: - canSub = true; - break; - default: - canSub = false; - } + boolean validNation = (this.guildState == GuildState.Nation || this.guildState == GuildState.Sovereign); + boolean validProtectorate = (toSub.guildState == GuildState.Errant || toSub.guildState == GuildState.Sovereign); - City nationCap = City.getCity(nation.cityUUID); - - if (nation.getSubGuildList().size() >= nationCap.getRank()) - canSub = false; - - return canSub; + return validNation && validProtectorate; } public int getRealmsOwnedFlag() {