forked from MagicBane/Server
Cleaned up bad logic in helper
This commit is contained in:
@@ -36,8 +36,8 @@ public class InviteToSubHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
PlayerCharacter source;
|
PlayerCharacter source;
|
||||||
PlayerCharacter target;
|
PlayerCharacter target;
|
||||||
Guild sourceGuild;
|
Guild nation;
|
||||||
Guild targetGuild;
|
Guild protectorate;
|
||||||
InviteToSubMsg msg = (InviteToSubMsg) baseMsg;
|
InviteToSubMsg msg = (InviteToSubMsg) baseMsg;
|
||||||
Dispatch dispatch;
|
Dispatch dispatch;
|
||||||
|
|
||||||
@@ -58,17 +58,17 @@ public class InviteToSubHandler extends AbstractClientMsgHandler {
|
|||||||
if (target.isIgnoringPlayer(source))
|
if (target.isIgnoringPlayer(source))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
sourceGuild = source.getGuild();
|
nation = source.getGuild();
|
||||||
targetGuild = target.getGuild();
|
protectorate = target.getGuild();
|
||||||
|
|
||||||
//source must be in guild
|
//source must be in guild
|
||||||
|
|
||||||
if (sourceGuild == null) {
|
if (nation == null) {
|
||||||
sendChat(source, "You must be in a guild to invite to sub.");
|
sendChat(source, "You must be in a guild to invite to sub.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceGuild.isEmptyGuild()) {
|
if (nation.isEmptyGuild()) {
|
||||||
sendChat(source, "You must be in a guild to invite to sub.");
|
sendChat(source, "You must be in a guild to invite to sub.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -80,15 +80,15 @@ public class InviteToSubHandler extends AbstractClientMsgHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceGuild.getNation().isEmptyGuild())
|
if (nation.getNation().isEmptyGuild())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//target must be in a guild
|
//target must be in a guild
|
||||||
|
|
||||||
if (targetGuild == null)
|
if (protectorate == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (sourceGuild.equals(targetGuild))
|
if (nation.equals(protectorate))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//target must be GL or IC
|
//target must be GL or IC
|
||||||
@@ -98,18 +98,21 @@ public class InviteToSubHandler extends AbstractClientMsgHandler {
|
|||||||
return true;
|
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
|
//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;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!sourceGuild.canSubAGuild(targetGuild)) {
|
if (!nation.canSubAGuild(protectorate)) {
|
||||||
sendChat(source, "This Guild can't be subbed.");
|
sendChat(source, "This Guild can't be subbed.");
|
||||||
return true;
|
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 (ConfigManager.MB_RULESET.getValue().equals("LORE")) {
|
||||||
if (source.guild.getGuildType().equals(target.guild.getGuildType()) == false) {
|
if (source.guild.getGuildType().equals(target.guild.getGuildType()) == false) {
|
||||||
sendChat(source, "You Must Be The Same Charter To Form A Nation.");
|
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.
|
//all tests passed, let's send invite.
|
||||||
|
|
||||||
if (target.getClientConnection() != null) {
|
if (target.getClientConnection() != null) {
|
||||||
msg.setGuildTag(sourceGuild.getGuildTag());
|
msg.setGuildTag(nation.getGuildTag());
|
||||||
msg.setGuildName(sourceGuild.getName());
|
msg.setGuildName(nation.getName());
|
||||||
msg.setGuildUUID(sourceGuild.getObjectUUID());
|
msg.setGuildUUID(nation.getObjectUUID());
|
||||||
msg.setUnknown02(1);
|
msg.setUnknown02(1);
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(target, msg);
|
dispatch = Dispatch.borrow(target, msg);
|
||||||
|
|||||||
@@ -629,34 +629,13 @@ public class Guild extends AbstractWorldObject {
|
|||||||
|
|
||||||
public boolean canSubAGuild(Guild toSub) {
|
public boolean canSubAGuild(Guild toSub) {
|
||||||
|
|
||||||
boolean canSub;
|
|
||||||
|
|
||||||
if (this.equals(toSub))
|
if (this.equals(toSub))
|
||||||
return false;
|
return false;
|
||||||
switch (this.guildState) {
|
|
||||||
case Nation:
|
|
||||||
case Sovereign:
|
|
||||||
canSub = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
canSub = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (toSub.guildState) {
|
boolean validNation = (this.guildState == GuildState.Nation || this.guildState == GuildState.Sovereign);
|
||||||
case Errant:
|
boolean validProtectorate = (toSub.guildState == GuildState.Errant || toSub.guildState == GuildState.Sovereign);
|
||||||
case Sovereign:
|
|
||||||
canSub = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
canSub = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
City nationCap = City.getCity(nation.cityUUID);
|
return validNation && validProtectorate;
|
||||||
|
|
||||||
if (nation.getSubGuildList().size() >= nationCap.getRank())
|
|
||||||
canSub = false;
|
|
||||||
|
|
||||||
return canSub;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRealmsOwnedFlag() {
|
public int getRealmsOwnedFlag() {
|
||||||
|
|||||||
Reference in New Issue
Block a user