From c80b9013d26ef04906614182ba4b2fd6abcc7d84 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 15 Feb 2024 19:46:41 -0600 Subject: [PATCH] Lore Rules --- src/engine/gameManager/GuildManager.java | 10 ++++- src/engine/gameManager/PowersManager.java | 21 ++++++++++- .../client/handlers/GroupInviteHandler.java | 11 ++++++ .../client/handlers/InviteToGuildHandler.java | 8 +++- .../client/handlers/InviteToSubHandler.java | 11 ++++-- .../client/handlers/LeaveGuildHandler.java | 13 +++---- src/engine/objects/City.java | 37 ++++++++++++++++--- 7 files changed, 91 insertions(+), 20 deletions(-) diff --git a/src/engine/gameManager/GuildManager.java b/src/engine/gameManager/GuildManager.java index e6b285ae..d5eef974 100644 --- a/src/engine/gameManager/GuildManager.java +++ b/src/engine/gameManager/GuildManager.java @@ -200,5 +200,13 @@ public enum GuildManager { } } - + public static Boolean meetsLoreRequirements(Guild guild, PlayerCharacter player){ + Enum.GuildCharterType charter = guild.getGuildType(); + if(charter.requiredClasses.contains(player.absPromotionClass)) + if(charter.requiredRaces.contains(player.absRace)) + if(charter.sexRequired.contains(player.absGender)) + return true; + + return false; + } } diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 1875a898..00c26948 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -170,6 +170,19 @@ public enum PowersManager { public static void usePower(final PerformActionMsg msg, ClientConnection origin, boolean sendCastToSelf) { + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID()); + PlayerCharacter caster = origin.getPlayerCharacter(); + PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID()); + if(pb != null && pb.isHarmful == false) { + if (caster.guild.equals(Guild.getErrantGuild())) + return; + + if (target != null && caster.guild.getGuildType().equals(target.guild.getGuildType()) == false) + return; + } + } + if (usePowerA(msg, origin, sendCastToSelf)) { // Cast failed for some reason, reset timer @@ -1258,7 +1271,13 @@ public enum PowersManager { return; } - + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if (pc.guild.getGuildType().equals(target.guild.getGuildType()) == false) { + ChatManager.chatInfoError(pc, + "Cannot summon player outside your charter."); + return; + } + } PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(), msg .getTrains(), msg.getSourceType(), msg.getSourceID(), target .getObjectType().ordinal(), target.getObjectUUID(), 0f, 0f, 0f, 1, 0); diff --git a/src/engine/net/client/handlers/GroupInviteHandler.java b/src/engine/net/client/handlers/GroupInviteHandler.java index bef9a198..5bba9132 100644 --- a/src/engine/net/client/handlers/GroupInviteHandler.java +++ b/src/engine/net/client/handlers/GroupInviteHandler.java @@ -12,7 +12,9 @@ package engine.net.client.handlers; import engine.Enum; import engine.Enum.GameObjectType; import engine.exception.MsgSendException; +import engine.gameManager.ConfigManager; import engine.gameManager.GroupManager; +import engine.gameManager.GuildManager; import engine.gameManager.SessionManager; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -21,6 +23,7 @@ import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.group.GroupInviteMsg; import engine.net.client.msg.group.GroupUpdateMsg; import engine.objects.Group; +import engine.objects.Guild; import engine.objects.PlayerCharacter; public class GroupInviteHandler extends AbstractClientMsgHandler { @@ -103,7 +106,15 @@ public class GroupInviteHandler extends AbstractClientMsgHandler { if (target.isIgnoringPlayer(source)) return false; + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(source.guild.equals(Guild.getErrantGuild())) + return false; + if (source.guild.getGuildType() != null) { + if (source.guild.getGuildType().equals(target.guild.getGuildType()) == false) + return false; + } + } // dont block invites to people already in a group and // dont check for pending invites, the client does it // Send invite message to target diff --git a/src/engine/net/client/handlers/InviteToGuildHandler.java b/src/engine/net/client/handlers/InviteToGuildHandler.java index 34d63d7a..0c533798 100644 --- a/src/engine/net/client/handlers/InviteToGuildHandler.java +++ b/src/engine/net/client/handlers/InviteToGuildHandler.java @@ -14,6 +14,7 @@ import engine.Enum; import engine.Enum.GameObjectType; import engine.exception.MsgSendException; import engine.gameManager.ChatManager; +import engine.gameManager.ConfigManager; import engine.gameManager.GuildManager; import engine.gameManager.SessionManager; import engine.net.Dispatch; @@ -124,7 +125,12 @@ public class InviteToGuildHandler extends AbstractClientMsgHandler { ErrorPopupMsg.sendErrorPopup(sourcePlayer, 135);// you do not meet the level required for this SWORN guild return true; } - + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if (GuildManager.meetsLoreRequirements(sourcePlayer.guild, targetPlayer) == false) { + ChatManager.chatGuildError(sourcePlayer,targetPlayer.getFirstName() + " does not meet charter requirements!"); + return true; + } + } targetPlayer.setLastGuildToInvite(sourcePlayer.getGuild().getObjectUUID()); // setup guild invite message to send to targetPlayer diff --git a/src/engine/net/client/handlers/InviteToSubHandler.java b/src/engine/net/client/handlers/InviteToSubHandler.java index bab06111..6492a231 100644 --- a/src/engine/net/client/handlers/InviteToSubHandler.java +++ b/src/engine/net/client/handlers/InviteToSubHandler.java @@ -12,9 +12,7 @@ package engine.net.client.handlers; import engine.Enum; import engine.Enum.GameObjectType; import engine.exception.MsgSendException; -import engine.gameManager.ChatManager; -import engine.gameManager.DbManager; -import engine.gameManager.SessionManager; +import engine.gameManager.*; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; @@ -111,7 +109,12 @@ public class InviteToSubHandler extends AbstractClientMsgHandler { sendChat(source, "This Guild can't be subbed."); return true; } - + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if (source.guild.getGuildType().equals(target.guild.getGuildType()) == false){ + sendChat(source, "You Must Be The Same Charter To Form A Nation."); + return true; + } + } //all tests passed, let's send invite. if (target.getClientConnection() != null) { diff --git a/src/engine/net/client/handlers/LeaveGuildHandler.java b/src/engine/net/client/handlers/LeaveGuildHandler.java index 0483469e..1dbc7306 100644 --- a/src/engine/net/client/handlers/LeaveGuildHandler.java +++ b/src/engine/net/client/handlers/LeaveGuildHandler.java @@ -11,17 +11,13 @@ package engine.net.client.handlers; import engine.Enum.GuildHistoryType; import engine.exception.MsgSendException; -import engine.gameManager.ChatManager; -import engine.gameManager.SessionManager; +import engine.gameManager.*; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.guild.LeaveGuildMsg; -import engine.objects.Guild; -import engine.objects.GuildStatusController; -import engine.objects.Mine; -import engine.objects.PlayerCharacter; +import engine.objects.*; public class LeaveGuildHandler extends AbstractClientMsgHandler { @@ -65,7 +61,10 @@ public class LeaveGuildHandler extends AbstractClientMsgHandler { ChatManager.chatGuildInfo(oldGuild, playerCharacter.getFirstName() + " has left the guild."); oldGuild.removePlayer(playerCharacter, GuildHistoryType.LEAVE); - + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(GroupManager.getGroup(playerCharacter) != null) + GroupManager.getGroup(playerCharacter).removeGroupMember(playerCharacter); + } // Send message back to client msg.setMessage("You have left the guild."); dispatch = Dispatch.borrow(playerCharacter, msg); diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index d8c45c4d..d51c176f 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -325,8 +325,15 @@ public class City extends AbstractWorldObject { if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) { - if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc)) - cities.add(city); //verify nation or guild is same + if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc)) { + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(city.getGuild().getGuildType().equals(pc.guild.getGuildType())){ + cities.add(city); + } + }else { + cities.add(city); //verify nation or guild is same + } + } } else if (Guild.sameNationExcludeErrant(city.getGuild(), pcG)) cities.add(city); @@ -345,7 +352,13 @@ public class City extends AbstractWorldObject { cities.add(city); } else if (pc.getLevel() >= g.getTeleportMin() && pc.getLevel() <= g.getTeleportMax()) - cities.add(city); + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(city.getGuild().getGuildType().equals(pc.guild.getGuildType())){ + cities.add(city); + } + }else { + cities.add(city); //verify nation or guild is same + } } } @@ -398,12 +411,24 @@ public class City extends AbstractWorldObject { if (city.isNpc == 1) if (city.isNoobIsle == 1) { if (playerCharacter.getLevel() < 21) - cities.add(city); + cities.add(city); //verify nation or guild is same } else if (playerCharacter.getLevel() > 9) - cities.add(city); + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(city.getGuild().getGuildType().equals(playerCharacter.guild.getGuildType())){ + cities.add(city); + } + }else { + cities.add(city); //verify nation or guild is same + } } else if (playerCharacter.getLevel() >= guild.getRepledgeMin() && playerCharacter.getLevel() <= guild.getRepledgeMax()) { - cities.add(city); + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(city.getGuild().getGuildType().equals(playerCharacter.guild.getGuildType())){ + cities.add(city); + } + }else { + cities.add(city); //verify nation or guild is same + } } } }