From d3e05ec2477f1c7ee87a58474eded8899e1ee3a1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 1 Jan 2023 15:48:17 -0600 Subject: [PATCH 1/2] subs limited to cap rank --- .../client/handlers/AcceptSubInviteHandler.java | 2 +- .../net/client/handlers/InviteToSubHandler.java | 2 +- src/engine/objects/Guild.java | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/engine/net/client/handlers/AcceptSubInviteHandler.java b/src/engine/net/client/handlers/AcceptSubInviteHandler.java index 38fbb3ef..cf7a0507 100644 --- a/src/engine/net/client/handlers/AcceptSubInviteHandler.java +++ b/src/engine/net/client/handlers/AcceptSubInviteHandler.java @@ -75,7 +75,7 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler { //source guild is limited to 7 subs //TODO this should be based on TOL rank - if (!targetGuild.canSubAGuild(sourceGuild)) { + if (!targetGuild.canSubAGuild(sourceGuild,targetGuild)) { ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild return true; } diff --git a/src/engine/net/client/handlers/InviteToSubHandler.java b/src/engine/net/client/handlers/InviteToSubHandler.java index 9c16ce90..992799eb 100644 --- a/src/engine/net/client/handlers/InviteToSubHandler.java +++ b/src/engine/net/client/handlers/InviteToSubHandler.java @@ -103,7 +103,7 @@ public class InviteToSubHandler extends AbstractClientMsgHandler { //TODO this should be based on TOL rank - if (!sourceGuild.canSubAGuild(targetGuild)) { + if (!sourceGuild.canSubAGuild(targetGuild, null)) { sendChat(source, "This Guild can't be subbed."); return true; } diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index e28009af..8bf11f6b 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -559,17 +559,21 @@ public class Guild extends AbstractWorldObject { } - public boolean canSubAGuild(Guild toSub){ + public boolean canSubAGuild(Guild toSub, Guild nation){ boolean canSub; if (this.equals(toSub)) return false; - - switch(this.guildState){ - case Nation: - case Sovereign: - canSub = true; + City nationCap = City.getCity(nation.cityUUID); + if (nation.getSubGuildList().size() >= nationCap.getRank()) { + canSub = false; + return canSub; + } + switch(this.guildState) { + case Nation: + case Sovereign: + canSub = true; break; default: canSub = false; From 5f0803eec421069a2bbe363740c93b2a732aaaeb Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 1 Jan 2023 21:56:49 -0600 Subject: [PATCH 2/2] nation sub limits added --- .../net/client/handlers/AcceptSubInviteHandler.java | 2 +- .../net/client/handlers/InviteToSubHandler.java | 2 +- src/engine/objects/Guild.java | 12 +++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/engine/net/client/handlers/AcceptSubInviteHandler.java b/src/engine/net/client/handlers/AcceptSubInviteHandler.java index cf7a0507..38fbb3ef 100644 --- a/src/engine/net/client/handlers/AcceptSubInviteHandler.java +++ b/src/engine/net/client/handlers/AcceptSubInviteHandler.java @@ -75,7 +75,7 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler { //source guild is limited to 7 subs //TODO this should be based on TOL rank - if (!targetGuild.canSubAGuild(sourceGuild,targetGuild)) { + if (!targetGuild.canSubAGuild(sourceGuild)) { ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild return true; } diff --git a/src/engine/net/client/handlers/InviteToSubHandler.java b/src/engine/net/client/handlers/InviteToSubHandler.java index 992799eb..9c16ce90 100644 --- a/src/engine/net/client/handlers/InviteToSubHandler.java +++ b/src/engine/net/client/handlers/InviteToSubHandler.java @@ -103,7 +103,7 @@ public class InviteToSubHandler extends AbstractClientMsgHandler { //TODO this should be based on TOL rank - if (!sourceGuild.canSubAGuild(targetGuild, null)) { + if (!sourceGuild.canSubAGuild(targetGuild)) { sendChat(source, "This Guild can't be subbed."); return true; } diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index 8bf11f6b..81249142 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -559,17 +559,12 @@ public class Guild extends AbstractWorldObject { } - public boolean canSubAGuild(Guild toSub, Guild nation){ + public boolean canSubAGuild(Guild toSub){ boolean canSub; if (this.equals(toSub)) return false; - City nationCap = City.getCity(nation.cityUUID); - if (nation.getSubGuildList().size() >= nationCap.getRank()) { - canSub = false; - return canSub; - } switch(this.guildState) { case Nation: case Sovereign: @@ -587,7 +582,10 @@ public class Guild extends AbstractWorldObject { default: canSub = false; } - + City nationCap = City.getCity(nation.cityUUID); + if (nation.getSubGuildList().size() >= nationCap.getRank()) { + canSub = false; + } return canSub; }