forked from MagicBane/Server
State being set manually
This commit is contained in:
@@ -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,21 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
||||
//all tests passed, let's Handle code
|
||||
//Update Target Guild State.
|
||||
|
||||
sourceGuild.upgradeGuildState(false);
|
||||
swornGuild.setGuildState(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.
|
||||
|
||||
msg.setUnknown02(1);
|
||||
msg.setResponse("Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
msg.setResponse("Your guild is now a " + swornGuild.getGuildState().name() + '.');
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
|
||||
|
||||
ChatManager.chatSystemInfo(sourcePlayer, "Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
ChatManager.chatSystemInfo(sourcePlayer, "Your guild is now a " + swornGuild.getGuildState().name() + '.');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,13 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Your guild is not a nation!");
|
||||
return true;
|
||||
}
|
||||
if (!nation.getSubGuildList().contains(targetGuild)) {
|
||||
if (!nation.getSubGuildList().contains(protectorate)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Your do not have such authority!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Guild.canSwearIn(targetGuild)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, targetGuild.getGuildState().name() + "cannot be sworn in");
|
||||
if (!Guild.canSwearIn(protectorate)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, protectorate.getGuildState().name() + "cannot be sworn in");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -81,29 +81,29 @@ 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;
|
||||
}
|
||||
//shouldn't get here.
|
||||
if (protectorate.getGuildState().equals(GuildState.Petitioner))
|
||||
GuildManager.updateAllGuildBinds(protectorate, nation.getOwnedCity());
|
||||
|
||||
//update Guild state.
|
||||
targetGuild.setNation(nation);
|
||||
GuildManager.updateAllGuildTags(targetGuild);
|
||||
targetGuild.upgradeGuildState(false);
|
||||
|
||||
if (protectorate.getNation().isEmptyGuild())
|
||||
protectorate.setGuildState(GuildState.Sworn);
|
||||
else
|
||||
protectorate.setGuildState(GuildState.Protectorate);
|
||||
|
||||
protectorate.setNation(nation);
|
||||
GuildManager.updateAllGuildTags(protectorate);
|
||||
|
||||
protectorate.upgradeGuildState(false);
|
||||
|
||||
if (nation.getGuildState() == GuildState.Sovereign)
|
||||
nation.upgradeGuildState(true);
|
||||
nation.setGuildState(GuildState.Nation);
|
||||
|
||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(player);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
@@ -117,7 +117,7 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
||||
ChatManager.chatGuildInfo(member, "Your Guild is now a Nation!");
|
||||
}
|
||||
|
||||
ArrayList<PlayerCharacter> swornMembers = SessionManager.getActivePCsInGuildID(targetGuild.getObjectUUID());
|
||||
ArrayList<PlayerCharacter> swornMembers = SessionManager.getActivePCsInGuildID(protectorate.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : swornMembers) {
|
||||
ChatManager.chatGuildInfo(member, "Your Guild has sword fealty to " + nation.getName() + '.');
|
||||
|
||||
Reference in New Issue
Block a user