Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 258bef5cb3 | |||
| 3f91ef7409 | |||
| 57ab356a3a | |||
| f7249ba656 | |||
| 24eb9608c3 | |||
| e4096bebbd | |||
| 547060b7a6 | |||
| ba6738d27a | |||
| 06c6468013 | |||
| 548796994f | |||
| 580452d68b | |||
| a570d127be | |||
| a949a08e30 | |||
| 412f7f956f | |||
| aea6869ca0 | |||
| 950523ddcc | |||
| 631989e626 | |||
| 12f6d7574d | |||
| 85dcad1c2a | |||
| defa0d8bb8 | |||
| 85872b66da | |||
| 09c9dfbc06 | |||
| d014aafe45 | |||
| d331093acd | |||
| 75ea9de4e5 | |||
| 13207c16f6 | |||
| b625ea2707 | |||
| 6f752935ab | |||
| 49005c6647 |
@@ -312,7 +312,7 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
if (targetPC.getGuild() != null) {
|
||||
output += "Name: " + targetPC.getGuild().getName();
|
||||
output += newline;
|
||||
output += "State: " + targetPC.getGuild().getGuildState();
|
||||
output += "State: " + targetPC.getGuild().guildState;
|
||||
output += newline;
|
||||
output += "Realms Owned:" + targetPC.getGuild().getRealmsOwned();
|
||||
output += newline;
|
||||
@@ -320,7 +320,7 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += newline;
|
||||
output += "Nation Name: " + targetPC.getGuild().getNation().getName();
|
||||
output += newline;
|
||||
output += "Nation State: " + targetPC.getGuild().getNation().getGuildState();
|
||||
output += "Nation State: " + targetPC.getGuild().getNation().guildState;
|
||||
output += newline;
|
||||
output += "Realms Owned:" + targetPC.getGuild().getNation().getRealmsOwned();
|
||||
output += newline;
|
||||
|
||||
@@ -181,6 +181,19 @@ public enum GuildManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static mbEnums.GuildState calcuateGuildState(Guild guild) {
|
||||
|
||||
if (guild.getNation() == guild)
|
||||
return guild.getSubGuildList().isEmpty() ? mbEnums.GuildState.Sovereign : mbEnums.GuildState.Nation;
|
||||
|
||||
if (guild.getOwnedCity() == null)
|
||||
return guild.getNation().isEmptyGuild() ? mbEnums.GuildState.Errant : mbEnums.GuildState.Sworn;
|
||||
|
||||
return (guild.getOwnedCity().getTOL().getRank() == 8)
|
||||
? mbEnums.GuildState.Province
|
||||
: mbEnums.GuildState.Protectorate;
|
||||
}
|
||||
|
||||
//This updates tags for all online players in a guild.
|
||||
public static void updateAllGuildTags(Guild guild) {
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ public class AbandonAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
|
||||
sourceGuild.setCityUUID(0);
|
||||
sourceGuild.setGuildState(GuildState.Errant);
|
||||
sourceGuild.guildState = GuildState.Errant;
|
||||
sourceGuild.setNation(null);
|
||||
|
||||
// Transfer the city assets
|
||||
|
||||
@@ -38,8 +38,8 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
||||
|
||||
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
|
||||
PlayerCharacter sourcePlayer;
|
||||
Guild sourceGuild;
|
||||
Guild targetGuild;
|
||||
Guild swornGuild;
|
||||
Guild nation;
|
||||
Dispatch dispatch;
|
||||
|
||||
// get PlayerCharacter of person sending sub invite
|
||||
@@ -49,21 +49,21 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
|
||||
sourceGuild = sourcePlayer.getGuild();
|
||||
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
||||
swornGuild = sourcePlayer.getGuild();
|
||||
nation = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
||||
|
||||
//must be source guild to sub to
|
||||
|
||||
if (targetGuild == null) {
|
||||
if (nation == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
if (sourceGuild == null) {
|
||||
if (swornGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sourceGuild.equals(targetGuild))
|
||||
if (swornGuild.equals(nation))
|
||||
return true;
|
||||
|
||||
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false) {
|
||||
@@ -74,7 +74,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 (!nation.canSubAGuild(swornGuild)) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
@@ -82,24 +82,20 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
||||
//all tests passed, let's Handle code
|
||||
//Update Target Guild State.
|
||||
|
||||
sourceGuild.upgradeGuildState(false);
|
||||
swornGuild.guildState = GuildState.Petitioner;
|
||||
|
||||
//Add sub so GuildMaster can Swear in.
|
||||
|
||||
ArrayList<Guild> subs = targetGuild.getSubGuildList();
|
||||
subs.add(sourceGuild);
|
||||
|
||||
targetGuild.setGuildState(GuildState.Nation);
|
||||
|
||||
ArrayList<Guild> subGuildList = nation.getSubGuildList();
|
||||
subGuildList.add(swornGuild);
|
||||
|
||||
//Let's send the message back.
|
||||
|
||||
ChatManager.chatGuildInfo(sourcePlayer, "Your guild is now a " + swornGuild.guildState.name() + '.');
|
||||
msg.setUnknown02(1);
|
||||
msg.setResponse("Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
msg.setResponse("Your guild is now a " + swornGuild.guildState.name() + '.');
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
|
||||
|
||||
ChatManager.chatSystemInfo(sourcePlayer, "Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ public class BreakFealtyHandler extends AbstractClientMsgHandler {
|
||||
|
||||
BreakFealtyMsg bfm;
|
||||
PlayerCharacter player;
|
||||
Guild toBreak;
|
||||
Guild guild;
|
||||
Guild nation;
|
||||
Guild protectorate;
|
||||
Dispatch dispatch;
|
||||
|
||||
bfm = (BreakFealtyMsg) baseMsg;
|
||||
@@ -49,113 +49,100 @@ public class BreakFealtyHandler extends AbstractClientMsgHandler {
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
toBreak = (Guild) DbManager.getObject(GameObjectType.Guild, bfm.getGuildUUID());
|
||||
nation = (Guild) DbManager.getObject(GameObjectType.Guild, bfm.getGuildUUID());
|
||||
|
||||
if (toBreak == null) {
|
||||
if (nation == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild = player.getGuild();
|
||||
protectorate = player.getGuild();
|
||||
|
||||
if (guild == null) {
|
||||
if (protectorate == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You do not belong to a guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (toBreak.isNPCGuild()) {
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) {
|
||||
if (nation.isNPCGuild()) {
|
||||
if (!GuildStatusController.isGuildLeader(player.getGuildStatus())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Only guild leader can break fealty!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(guild.getObjectUUID(), WorldServer.worldUUID)) {
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(protectorate.getObjectUUID(), WorldServer.worldUUID)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (guild.getGuildState()) {
|
||||
switch (protectorate.guildState) {
|
||||
case Sworn:
|
||||
guild.setNation(null);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, null);
|
||||
protectorate.setNation(Guild.getErrantNation());
|
||||
GuildManager.updateAllGuildTags(protectorate);
|
||||
GuildManager.updateAllGuildBinds(protectorate, null);
|
||||
protectorate.guildState = mbEnums.GuildState.Errant;
|
||||
break;
|
||||
case Province:
|
||||
guild.setNation(guild);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, guild.getOwnedCity());
|
||||
case Protectorate:
|
||||
protectorate.setNation(protectorate);
|
||||
GuildManager.updateAllGuildTags(protectorate);
|
||||
GuildManager.updateAllGuildBinds(protectorate, protectorate.getOwnedCity());
|
||||
protectorate.guildState = mbEnums.GuildState.Sovereign;
|
||||
break;
|
||||
}
|
||||
|
||||
guild.downgradeGuildState();
|
||||
|
||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(player);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
|
||||
|
||||
//Update Map.
|
||||
|
||||
final Session s = SessionManager.getSession(player);
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
ArrayList<PlayerCharacter> guildMembers = SessionManager.getActivePCsInGuildID(protectorate.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : guildMembers)
|
||||
ChatManager.chatGuildInfo(member, protectorate.getName() + " has broke fealty from " + nation.getName() + '!');
|
||||
|
||||
ArrayList<PlayerCharacter> guildMembers = SessionManager.getActivePCsInGuildID(guild.getObjectUUID());
|
||||
ArrayList<PlayerCharacter> breakFealtyMembers = SessionManager.getActivePCsInGuildID(nation.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : guildMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broke fealty from " + toBreak.getName() + '!');
|
||||
}
|
||||
|
||||
ArrayList<PlayerCharacter> breakFealtyMembers = SessionManager.getActivePCsInGuildID(toBreak.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : breakFealtyMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broken fealty from " + toBreak.getName() + '!');
|
||||
}
|
||||
for (PlayerCharacter member : breakFealtyMembers)
|
||||
ChatManager.chatGuildInfo(member, protectorate.getName() + " has broken fealty from " + nation.getName() + '!');
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!toBreak.getSubGuildList().contains(guild)) {
|
||||
if (!nation.getSubGuildList().contains(protectorate)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Failure to break fealty!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) {
|
||||
if (!GuildStatusController.isGuildLeader(player.getGuildStatus())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Only guild leader can break fealty!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Bane.getBaneByAttackerGuild(guild) != null) {
|
||||
if (Bane.getBaneByAttackerGuild(protectorate) != null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You may break fealty with active bane!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(guild.getObjectUUID(), WorldServer.worldUUID)) {
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(protectorate.getObjectUUID(), WorldServer.worldUUID)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (guild.getGuildState()) {
|
||||
switch (protectorate.guildState) {
|
||||
case Sworn:
|
||||
guild.setNation(null);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, null);
|
||||
protectorate.setNation(Guild.getErrantNation());
|
||||
GuildManager.updateAllGuildTags(protectorate);
|
||||
GuildManager.updateAllGuildBinds(protectorate, null);
|
||||
break;
|
||||
case Province:
|
||||
guild.setNation(guild);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, guild.getOwnedCity());
|
||||
protectorate.setNation(protectorate);
|
||||
GuildManager.updateAllGuildTags(protectorate);
|
||||
GuildManager.updateAllGuildBinds(protectorate, protectorate.getOwnedCity());
|
||||
break;
|
||||
}
|
||||
|
||||
guild.downgradeGuildState();
|
||||
toBreak.getSubGuildList().remove(guild);
|
||||
|
||||
if (toBreak.getSubGuildList().isEmpty())
|
||||
toBreak.downgradeGuildState();
|
||||
nation.getSubGuildList().remove(protectorate);
|
||||
|
||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(player);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
@@ -167,17 +154,16 @@ public class BreakFealtyHandler extends AbstractClientMsgHandler {
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
|
||||
|
||||
ArrayList<PlayerCharacter> guildMembers = SessionManager.getActivePCsInGuildID(guild.getObjectUUID());
|
||||
ArrayList<PlayerCharacter> guildMembers = SessionManager.getActivePCsInGuildID(protectorate.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : guildMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broke fealty from " + toBreak.getName() + '!');
|
||||
ChatManager.chatGuildInfo(member, protectorate.getName() + " has broke fealty from " + nation.getName() + '!');
|
||||
}
|
||||
|
||||
ArrayList<PlayerCharacter> breakFealtyMembers = SessionManager.getActivePCsInGuildID(toBreak.getObjectUUID());
|
||||
ArrayList<PlayerCharacter> breakFealtyMembers = SessionManager.getActivePCsInGuildID(nation.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : breakFealtyMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broken fealty from " + toBreak.getName() + '!');
|
||||
ChatManager.chatGuildInfo(member, protectorate.getName() + " has broken fealty from " + nation.getName() + '!');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ChannelMuteMsgHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
|
||||
sourceGuild.setCityUUID(0);
|
||||
sourceGuild.setGuildState(GuildState.Errant);
|
||||
sourceGuild.guildState = GuildState.Errant;
|
||||
sourceGuild.setNation(null);
|
||||
|
||||
// Transfer the city assets
|
||||
|
||||
@@ -99,7 +99,7 @@ public class DisbandGuildHandler extends AbstractClientMsgHandler {
|
||||
player.setGuildLeader(false);
|
||||
player.setInnerCouncil(false);
|
||||
guild.setGuildLeaderUUID(0);
|
||||
guild.setNation(null);
|
||||
guild.setNation(Guild.getErrantNation());
|
||||
|
||||
DbManager.GuildQueries.DELETE_GUILD(guild);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public class DismissGuildHandler extends AbstractClientMsgHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (toDismiss.getGuildState()) {
|
||||
switch (toDismiss.guildState) {
|
||||
case Sworn:
|
||||
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(toDismiss.getObjectUUID(), WorldServer.worldUUID)) {
|
||||
@@ -85,35 +85,37 @@ public class DismissGuildHandler extends AbstractClientMsgHandler {
|
||||
return true;
|
||||
}
|
||||
nation.getSubGuildList().remove(toDismiss);
|
||||
toDismiss.downgradeGuildState();
|
||||
toDismiss.setNation(null);
|
||||
toDismiss.guildState = mbEnums.GuildState.Errant;
|
||||
toDismiss.setNation(Guild.getErrantNation());
|
||||
GuildManager.updateAllGuildBinds(toDismiss, null);
|
||||
|
||||
break;
|
||||
case Petitioner:
|
||||
|
||||
nation.getSubGuildList().remove(toDismiss);
|
||||
|
||||
if (toDismiss.getNation().isEmptyGuild())
|
||||
toDismiss.guildState = mbEnums.GuildState.Errant;
|
||||
else
|
||||
toDismiss.guildState = mbEnums.GuildState.Sovereign;
|
||||
|
||||
break;
|
||||
case Protectorate:
|
||||
case Province:
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(toDismiss.getObjectUUID(), WorldServer.worldUUID)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
nation.getSubGuildList().remove(toDismiss);
|
||||
toDismiss.downgradeGuildState();
|
||||
toDismiss.guildState = mbEnums.GuildState.Sovereign;
|
||||
toDismiss.setNation(toDismiss);
|
||||
|
||||
break;
|
||||
case Petitioner:
|
||||
nation.getSubGuildList().remove(toDismiss);
|
||||
toDismiss.downgradeGuildState();
|
||||
break;
|
||||
case Protectorate:
|
||||
nation.getSubGuildList().remove(toDismiss);
|
||||
toDismiss.downgradeGuildState();
|
||||
break;
|
||||
}
|
||||
|
||||
GuildManager.updateAllGuildTags(toDismiss);
|
||||
|
||||
if (nation.getSubGuildList().isEmpty())
|
||||
nation.downgradeGuildState();
|
||||
nation.guildState = mbEnums.GuildState.Sovereign;
|
||||
|
||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(player);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -79,18 +79,14 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
GuildManager.updateAllGuildBinds(player.getGuild(), npc.getGuild().getOwnedCity());
|
||||
|
||||
|
||||
//update Guild state.
|
||||
player.getGuild().setNation(npc.getGuild());
|
||||
GuildManager.updateAllGuildTags(player.getGuild());
|
||||
|
||||
//update state twice, errant to petitioner, to sworn.
|
||||
player.getGuild().upgradeGuildState(false);//to petitioner
|
||||
player.getGuild().upgradeGuildState(false);//to sworn
|
||||
|
||||
//update state
|
||||
player.getGuild().guildState = mbEnums.GuildState.Sworn;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -88,8 +88,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
// Validate that the player is the leader of a guild
|
||||
// that is not currently Sovereign *** BUG? Doesn't look right. isGuildLeader()?
|
||||
|
||||
if ((playerCharacter.getGuild().getGuildState() != GuildState.Sworn
|
||||
|| playerCharacter.getGuild().getGuildState() != GuildState.Errant) == false) {
|
||||
if ((playerCharacter.getGuild().guildState != GuildState.Sworn
|
||||
|| playerCharacter.getGuild().guildState != GuildState.Errant) == false) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 17, ""); // Your is not an errant or soverign guild
|
||||
return false;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// Errant guilds cannot place assets
|
||||
|
||||
if (player.getGuild().getGuildState() == GuildState.Errant) {
|
||||
if (player.getGuild().guildState == GuildState.Errant) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "Only sovereign or sworn guilds may place assets.");
|
||||
return false;
|
||||
}
|
||||
@@ -774,7 +774,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
playerCharacter.getGuild().setNation(playerCharacter.getGuild());
|
||||
playerNation = playerCharacter.getGuild();
|
||||
playerNation.setGuildState(GuildState.Sovereign);
|
||||
playerNation.guildState = GuildState.Sovereign;
|
||||
|
||||
// Update guild binds and tags
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) {
|
||||
PlayerCharacter player;
|
||||
SwearInGuildMsg swearInMsg;
|
||||
Guild targetGuild;
|
||||
Guild protectorate;
|
||||
Guild nation;
|
||||
Dispatch dispatch;
|
||||
|
||||
@@ -47,9 +47,9 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, swearInMsg.getGuildUUID());
|
||||
protectorate = (Guild) DbManager.getObject(GameObjectType.Guild, swearInMsg.getGuildUUID());
|
||||
|
||||
if (targetGuild == null) {
|
||||
if (protectorate == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
@@ -66,13 +66,14 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Your guild is not a nation!");
|
||||
return true;
|
||||
}
|
||||
if (!nation.getSubGuildList().contains(targetGuild)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Your do not have such authority!");
|
||||
|
||||
if (!nation.getSubGuildList().contains(protectorate)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Guild is not a petitioner!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Guild.canSwearIn(targetGuild)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, targetGuild.getGuildState().name() + "cannot be sworn in");
|
||||
if (protectorate.guildState.equals(GuildState.Petitioner) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Guild is not a petitioner!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -81,29 +82,27 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(targetGuild.getObjectUUID(), nation.getObjectUUID())) {
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(protectorate.getObjectUUID(), nation.getObjectUUID())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (targetGuild.getGuildState()) {
|
||||
case Petitioner:
|
||||
GuildManager.updateAllGuildBinds(targetGuild, nation.getOwnedCity());
|
||||
break;
|
||||
case Protectorate:
|
||||
break;
|
||||
default:
|
||||
//shouldn't get here.
|
||||
break;
|
||||
}
|
||||
// update Guild state.
|
||||
// R8 is a province
|
||||
|
||||
//update Guild state.
|
||||
targetGuild.setNation(nation);
|
||||
GuildManager.updateAllGuildTags(targetGuild);
|
||||
targetGuild.upgradeGuildState(false);
|
||||
if (protectorate.getNation().isEmptyGuild())
|
||||
protectorate.guildState = GuildState.Sworn;
|
||||
else
|
||||
protectorate.guildState = (protectorate.getOwnedCity().getTOL().getRank() == 8)
|
||||
? GuildState.Province
|
||||
: GuildState.Protectorate;
|
||||
|
||||
if (nation.getGuildState() == GuildState.Sovereign)
|
||||
nation.upgradeGuildState(true);
|
||||
protectorate.setNation(nation);
|
||||
GuildManager.updateAllGuildTags(protectorate);
|
||||
|
||||
if (nation.guildState == GuildState.Sovereign)
|
||||
if (protectorate.guildState.equals(GuildState.Protectorate))
|
||||
nation.guildState = GuildState.Nation;
|
||||
|
||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(player);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
@@ -113,15 +112,14 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
||||
|
||||
ArrayList<PlayerCharacter> guildMembers = SessionManager.getActivePCsInGuildID(nation.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : guildMembers) {
|
||||
ChatManager.chatGuildInfo(member, "Your Guild is now a Nation!");
|
||||
}
|
||||
for (PlayerCharacter member : guildMembers)
|
||||
ChatManager.chatGuildInfo(member, protectorate.getName() + " has sworn fealty to you.");
|
||||
|
||||
ArrayList<PlayerCharacter> swornMembers = SessionManager.getActivePCsInGuildID(targetGuild.getObjectUUID());
|
||||
ArrayList<PlayerCharacter> swornMembers = SessionManager.getActivePCsInGuildID(protectorate.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : swornMembers)
|
||||
ChatManager.chatGuildInfo(member, "Your Guild has sworn fealty to " + nation.getName() + '.');
|
||||
|
||||
for (PlayerCharacter member : swornMembers) {
|
||||
ChatManager.chatGuildInfo(member, "Your Guild has sword fealty to " + nation.getName() + '.');
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
return true;
|
||||
|
||||
@@ -437,7 +437,7 @@ public class ManageCityAssetsMsg extends ClientNetMsg {
|
||||
else
|
||||
writer.putInt((int) timeLeft / 1000); // Time remaing until bane/Seconds
|
||||
|
||||
if (attackerGuild.getGuildState() == GuildState.Sworn)
|
||||
if (attackerGuild.guildState == GuildState.Sworn)
|
||||
writer.putInt(4); //3 capture/errant,4 capture/sworn, 5 destroy/soveirgn.
|
||||
else
|
||||
writer.putInt(5);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class SendGuildEntryMsg extends ClientNetMsg {
|
||||
if (subsAndSovs.size() > 0) {
|
||||
|
||||
for (Guild guild : subsAndSovs) {
|
||||
int state = guild.getGuildState().getStateID();
|
||||
int state = guild.guildState.getStateID();
|
||||
|
||||
writer.putInt(guild.getObjectType().ordinal());
|
||||
writer.putInt(guild.getObjectUUID());
|
||||
|
||||
@@ -602,13 +602,10 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
this.isDeranking.compareAndSet(false, true);
|
||||
|
||||
if ((bane.getOwner().getGuild().getGuildState() == GuildState.Sovereign) ||
|
||||
(bane.getOwner().getGuild().getGuildState() == GuildState.Protectorate) ||
|
||||
(bane.getOwner().getGuild().getGuildState() == GuildState.Province) ||
|
||||
(bane.getOwner().getGuild().getGuildState() == GuildState.Nation))
|
||||
siegeResult = SiegeResult.DESTROY;
|
||||
else
|
||||
if (bane.getOwner().getGuild().guildState == GuildState.Sworn)
|
||||
siegeResult = SiegeResult.CAPTURE;
|
||||
else
|
||||
siegeResult = SiegeResult.DESTROY;
|
||||
|
||||
// Remove realm if city had one
|
||||
|
||||
|
||||
@@ -813,10 +813,10 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
// Determine if this city is a nation capitol
|
||||
|
||||
if (this.getGuild().getGuildState() == GuildState.Nation)
|
||||
if (this.getGuild().guildState == GuildState.Nation)
|
||||
for (Guild sub : this.getGuild().getSubGuildList()) {
|
||||
|
||||
if ((sub.getGuildState() == GuildState.Protectorate) || (sub.getGuildState() == GuildState.Province)) {
|
||||
if ((sub.guildState == GuildState.Protectorate) || (sub.guildState == GuildState.Province)) {
|
||||
this.isCapital = 1;
|
||||
break;
|
||||
}
|
||||
@@ -1173,7 +1173,8 @@ public class City extends AbstractWorldObject {
|
||||
sourceNation.getSubGuildList().remove(sourceGuild);
|
||||
|
||||
if (sourceNation.getSubGuildList().isEmpty())
|
||||
sourceNation.downgradeGuildState();
|
||||
sourceNation.guildState = GuildState.Sovereign;
|
||||
|
||||
}
|
||||
|
||||
// Link the mew guild with the tree
|
||||
@@ -1186,7 +1187,7 @@ public class City extends AbstractWorldObject {
|
||||
sourceGuild.setCityUUID(this.getObjectUUID());
|
||||
|
||||
sourceGuild.setNation(sourceGuild);
|
||||
sourceGuild.setGuildState(GuildState.Sovereign);
|
||||
sourceGuild.guildState = GuildState.Sovereign;
|
||||
GuildManager.updateAllGuildTags(sourceGuild);
|
||||
GuildManager.updateAllGuildBinds(sourceGuild, this);
|
||||
|
||||
|
||||
+12
-126
@@ -63,7 +63,7 @@ public class Guild extends AbstractWorldObject {
|
||||
private ArrayList<Guild> recommendList = new ArrayList<>();
|
||||
private ArrayList<Guild> subGuildList;
|
||||
private int nationUUID = 0;
|
||||
private GuildState guildState = GuildState.Errant;
|
||||
public GuildState guildState = GuildState.Errant;
|
||||
private String hash;
|
||||
private boolean ownerIsNPC;
|
||||
|
||||
@@ -206,23 +206,6 @@ public class Guild extends AbstractWorldObject {
|
||||
return a.nation.getObjectUUID() == b.nation.getObjectUUID() && !a.nation.isEmptyGuild();
|
||||
}
|
||||
|
||||
public static boolean canSwearIn(Guild toSub) {
|
||||
|
||||
boolean canSwear = false;
|
||||
|
||||
switch (toSub.guildState) {
|
||||
|
||||
case Protectorate:
|
||||
case Petitioner:
|
||||
canSwear = true;
|
||||
break;
|
||||
default:
|
||||
canSwear = false;
|
||||
}
|
||||
|
||||
return canSwear;
|
||||
}
|
||||
|
||||
public static void _serializeForClientMsg(Guild guild, ByteBufferWriter writer) {
|
||||
Guild.serializeForClientMsg(guild, writer, null, false);
|
||||
}
|
||||
@@ -644,93 +627,15 @@ public class Guild extends AbstractWorldObject {
|
||||
|
||||
}
|
||||
|
||||
public void upgradeGuildState(boolean nation) {
|
||||
if (nation) {
|
||||
this.guildState = GuildState.Nation;
|
||||
return;
|
||||
}
|
||||
switch (this.guildState) {
|
||||
|
||||
case Errant:
|
||||
this.guildState = GuildState.Petitioner;
|
||||
break;
|
||||
case Sworn:
|
||||
//Can't upgrade
|
||||
break;
|
||||
case Protectorate:
|
||||
this.guildState = GuildState.Province;
|
||||
break;
|
||||
case Petitioner:
|
||||
this.guildState = GuildState.Sworn;
|
||||
break;
|
||||
case Province:
|
||||
//Can't upgrade
|
||||
break;
|
||||
case Nation:
|
||||
//Can't upgrade
|
||||
break;
|
||||
case Sovereign:
|
||||
this.guildState = GuildState.Protectorate;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void downgradeGuildState() {
|
||||
|
||||
switch (this.guildState) {
|
||||
case Errant:
|
||||
break;
|
||||
case Sworn:
|
||||
this.guildState = GuildState.Errant;
|
||||
break;
|
||||
case Protectorate:
|
||||
this.guildState = GuildState.Sovereign;
|
||||
break;
|
||||
case Petitioner:
|
||||
this.guildState = GuildState.Errant;
|
||||
break;
|
||||
case Province:
|
||||
this.guildState = GuildState.Sovereign;
|
||||
break;
|
||||
case Nation:
|
||||
this.guildState = GuildState.Sovereign;
|
||||
break;
|
||||
case Sovereign:
|
||||
this.guildState = GuildState.Errant;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
City nationCap = City.getCity(nation.cityUUID);
|
||||
if (nation.getSubGuildList().size() >= nationCap.getRank()) {
|
||||
canSub = false;
|
||||
}
|
||||
return canSub;
|
||||
boolean validNation = (this.guildState == GuildState.Nation || this.guildState == GuildState.Sovereign);
|
||||
boolean validProtectorate = (toSub.guildState == GuildState.Errant || toSub.guildState == GuildState.Sovereign);
|
||||
|
||||
return validNation && validProtectorate;
|
||||
}
|
||||
|
||||
public int getRealmsOwnedFlag() {
|
||||
@@ -834,18 +739,11 @@ public class Guild extends AbstractWorldObject {
|
||||
Logger.error("FAILED TO LOAD SUB GUILDS FOR UUID " + this.getObjectUUID());
|
||||
}
|
||||
|
||||
if (this.nation == this && subGuildList.size() > 0)
|
||||
this.guildState = GuildState.Nation;
|
||||
else if (this.nation.equals(this))
|
||||
this.guildState = GuildState.Sovereign;
|
||||
else if (!this.nation.isEmptyGuild() && this.cityUUID != 0)
|
||||
this.guildState = GuildState.Province;
|
||||
else if (!this.nation.isEmptyGuild())
|
||||
this.guildState = GuildState.Sworn;
|
||||
else
|
||||
this.guildState = GuildState.Errant;
|
||||
this.guildState = GuildManager.calcuateGuildState(this);
|
||||
|
||||
if (this.cityUUID == 0)
|
||||
Logger.info(this.name + ":" + this.guildState + ":" + this.nation.name);
|
||||
|
||||
if (this.getOwnedCity() == null)
|
||||
return;
|
||||
|
||||
// Calculate number of realms this guild controls
|
||||
@@ -901,14 +799,6 @@ public class Guild extends AbstractWorldObject {
|
||||
return motto;
|
||||
}
|
||||
|
||||
public GuildState getGuildState() {
|
||||
return guildState;
|
||||
}
|
||||
|
||||
public void setGuildState(GuildState guildState) {
|
||||
this.guildState = guildState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the realmsOwned
|
||||
*/
|
||||
@@ -930,18 +820,14 @@ public class Guild extends AbstractWorldObject {
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(subGuild.getObjectUUID(), WorldServer.worldUUID))
|
||||
Logger.debug("Failed to set Nation Guild for Guild with UID " + subGuild.getObjectUUID());
|
||||
|
||||
// Guild without any subs is no longer a nation
|
||||
|
||||
if (subGuild.getOwnedCity() == null) {
|
||||
subGuild.nation = null;
|
||||
subGuild.guildState = GuildState.Errant;
|
||||
subGuild.nation = Guild.getErrantNation();
|
||||
} else {
|
||||
subGuild.nation = subGuild;
|
||||
subGuild.guildState = GuildState.Sovereign;
|
||||
}
|
||||
|
||||
// Downgrade guild
|
||||
|
||||
subGuild.downgradeGuildState();
|
||||
|
||||
// Remove from collection
|
||||
|
||||
subGuildList.remove(subGuild);
|
||||
|
||||
@@ -63,8 +63,8 @@ public class DestroyCityThread implements Runnable {
|
||||
|
||||
//Successful Update of guild
|
||||
|
||||
formerGuild.setGuildState(mbEnums.GuildState.Errant);
|
||||
formerGuild.setNation(null);
|
||||
formerGuild.guildState = mbEnums.GuildState.Errant;
|
||||
formerGuild.setNation(Guild.getErrantNation());
|
||||
formerGuild.setCityUUID(0);
|
||||
GuildManager.updateAllGuildTags(formerGuild);
|
||||
GuildManager.updateAllGuildBinds(formerGuild, null);
|
||||
|
||||
@@ -50,8 +50,8 @@ public class TransferCityThread implements Runnable {
|
||||
|
||||
if (formerGuild != null)
|
||||
if (DbManager.GuildQueries.SET_GUILD_OWNED_CITY(formerGuild.getObjectUUID(), 0)) {
|
||||
formerGuild.setGuildState(mbEnums.GuildState.Errant);
|
||||
formerGuild.setNation(null);
|
||||
formerGuild.guildState = mbEnums.GuildState.Errant;
|
||||
formerGuild.setNation(Guild.getErrantNation());
|
||||
formerGuild.setCityUUID(0);
|
||||
GuildManager.updateAllGuildTags(formerGuild);
|
||||
GuildManager.updateAllGuildBinds(formerGuild, null);
|
||||
@@ -63,13 +63,11 @@ public class TransferCityThread implements Runnable {
|
||||
|
||||
subGuildList = new ArrayList<>();
|
||||
|
||||
for (Guild subGuild : formerGuild.getSubGuildList()) {
|
||||
for (Guild subGuild : formerGuild.getSubGuildList())
|
||||
subGuildList.add(subGuild);
|
||||
}
|
||||
|
||||
for (Guild subGuild : subGuildList) {
|
||||
for (Guild subGuild : subGuildList)
|
||||
formerGuild.removeSubGuild(subGuild);
|
||||
}
|
||||
}
|
||||
|
||||
//Reset TOL to rank 1
|
||||
|
||||
Reference in New Issue
Block a user