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;
|
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
|
||||||
PlayerCharacter sourcePlayer;
|
PlayerCharacter sourcePlayer;
|
||||||
Guild sourceGuild;
|
Guild swornGuild;
|
||||||
Guild targetGuild;
|
Guild nation;
|
||||||
Dispatch dispatch;
|
Dispatch dispatch;
|
||||||
|
|
||||||
// get PlayerCharacter of person sending sub invite
|
// get PlayerCharacter of person sending sub invite
|
||||||
@@ -49,21 +49,21 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
|||||||
if (sourcePlayer == null)
|
if (sourcePlayer == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
sourceGuild = sourcePlayer.getGuild();
|
swornGuild = sourcePlayer.getGuild();
|
||||||
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
nation = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
||||||
|
|
||||||
//must be source guild to sub to
|
//must be source guild to sub to
|
||||||
|
|
||||||
if (targetGuild == null) {
|
if (nation == null) {
|
||||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sourceGuild == null) {
|
if (swornGuild == null) {
|
||||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceGuild.equals(targetGuild))
|
if (swornGuild.equals(nation))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false) {
|
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false) {
|
||||||
@@ -74,7 +74,7 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
|||||||
//source guild is limited to 7 subs
|
//source guild is limited to 7 subs
|
||||||
//TODO this should be based on TOL rank
|
//TODO this should be based on TOL rank
|
||||||
|
|
||||||
if (!targetGuild.canSubAGuild(sourceGuild)) {
|
if (!nation.canSubAGuild(swornGuild)) {
|
||||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -82,24 +82,21 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
|||||||
//all tests passed, let's Handle code
|
//all tests passed, let's Handle code
|
||||||
//Update Target Guild State.
|
//Update Target Guild State.
|
||||||
|
|
||||||
sourceGuild.upgradeGuildState(false);
|
swornGuild.setGuildState(GuildState.Petitioner);
|
||||||
|
|
||||||
//Add sub so GuildMaster can Swear in.
|
//Add sub so GuildMaster can Swear in.
|
||||||
|
|
||||||
ArrayList<Guild> subs = targetGuild.getSubGuildList();
|
ArrayList<Guild> subGuildList = nation.getSubGuildList();
|
||||||
subs.add(sourceGuild);
|
subGuildList.add(swornGuild);
|
||||||
|
|
||||||
targetGuild.setGuildState(GuildState.Nation);
|
|
||||||
|
|
||||||
|
|
||||||
//Let's send the message back.
|
//Let's send the message back.
|
||||||
|
|
||||||
msg.setUnknown02(1);
|
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);
|
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||||
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
|||||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) {
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) {
|
||||||
PlayerCharacter player;
|
PlayerCharacter player;
|
||||||
SwearInGuildMsg swearInMsg;
|
SwearInGuildMsg swearInMsg;
|
||||||
Guild targetGuild;
|
Guild protectorate;
|
||||||
Guild nation;
|
Guild nation;
|
||||||
Dispatch dispatch;
|
Dispatch dispatch;
|
||||||
|
|
||||||
@@ -47,9 +47,9 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
|||||||
if (player == null)
|
if (player == null)
|
||||||
return true;
|
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");
|
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -66,13 +66,13 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
|||||||
ErrorPopupMsg.sendErrorMsg(player, "Your guild is not a nation!");
|
ErrorPopupMsg.sendErrorMsg(player, "Your guild is not a nation!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!nation.getSubGuildList().contains(targetGuild)) {
|
if (!nation.getSubGuildList().contains(protectorate)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(player, "Your do not have such authority!");
|
ErrorPopupMsg.sendErrorMsg(player, "Your do not have such authority!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Guild.canSwearIn(targetGuild)) {
|
if (!Guild.canSwearIn(protectorate)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(player, targetGuild.getGuildState().name() + "cannot be sworn in");
|
ErrorPopupMsg.sendErrorMsg(player, protectorate.getGuildState().name() + "cannot be sworn in");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,29 +81,29 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
|||||||
return true;
|
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");
|
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (targetGuild.getGuildState()) {
|
|
||||||
case Petitioner:
|
|
||||||
GuildManager.updateAllGuildBinds(targetGuild, nation.getOwnedCity());
|
|
||||||
break;
|
|
||||||
case Protectorate:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//shouldn't get here.
|
//shouldn't get here.
|
||||||
break;
|
if (protectorate.getGuildState().equals(GuildState.Petitioner))
|
||||||
}
|
GuildManager.updateAllGuildBinds(protectorate, nation.getOwnedCity());
|
||||||
|
|
||||||
//update Guild state.
|
//update Guild state.
|
||||||
targetGuild.setNation(nation);
|
|
||||||
GuildManager.updateAllGuildTags(targetGuild);
|
if (protectorate.getNation().isEmptyGuild())
|
||||||
targetGuild.upgradeGuildState(false);
|
protectorate.setGuildState(GuildState.Sworn);
|
||||||
|
else
|
||||||
|
protectorate.setGuildState(GuildState.Protectorate);
|
||||||
|
|
||||||
|
protectorate.setNation(nation);
|
||||||
|
GuildManager.updateAllGuildTags(protectorate);
|
||||||
|
|
||||||
|
protectorate.upgradeGuildState(false);
|
||||||
|
|
||||||
if (nation.getGuildState() == GuildState.Sovereign)
|
if (nation.getGuildState() == GuildState.Sovereign)
|
||||||
nation.upgradeGuildState(true);
|
nation.setGuildState(GuildState.Nation);
|
||||||
|
|
||||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(player);
|
SendGuildEntryMsg msg = new SendGuildEntryMsg(player);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
@@ -117,7 +117,7 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
|||||||
ChatManager.chatGuildInfo(member, "Your Guild is now a Nation!");
|
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) {
|
for (PlayerCharacter member : swornMembers) {
|
||||||
ChatManager.chatGuildInfo(member, "Your Guild has sword fealty to " + nation.getName() + '.');
|
ChatManager.chatGuildInfo(member, "Your Guild has sword fealty to " + nation.getName() + '.');
|
||||||
|
|||||||
Reference in New Issue
Block a user