Compare commits
2 Commits
lakebane-easy
...
subdate
| Author | SHA1 | Date | |
|---|---|---|---|
| c02564d7af | |||
| 945f85443d |
@@ -15,6 +15,7 @@ import engine.Enum.GuildState;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.GuildManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
@@ -26,8 +27,6 @@ import engine.objects.Guild;
|
||||
import engine.objects.GuildStatusController;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AcceptSubInviteHandler() {
|
||||
@@ -38,69 +37,74 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
|
||||
PlayerCharacter sourcePlayer;
|
||||
Guild sourceGuild;
|
||||
Guild targetGuild;
|
||||
PlayerCharacter playerCharacter;
|
||||
Guild protectorate;
|
||||
Guild nation;
|
||||
Dispatch dispatch;
|
||||
|
||||
// get PlayerCharacter of person sending sub invite
|
||||
|
||||
sourcePlayer = SessionManager.getPlayerCharacter(origin);
|
||||
playerCharacter = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (sourcePlayer == null)
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
|
||||
sourceGuild = sourcePlayer.getGuild();
|
||||
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
||||
protectorate = playerCharacter.getGuild();
|
||||
nation = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
||||
|
||||
//must be source guild to sub to
|
||||
|
||||
if (targetGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
if (nation == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
if (sourceGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
if (protectorate == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sourceGuild.equals(targetGuild))
|
||||
if (protectorate.equals(nation))
|
||||
return true;
|
||||
|
||||
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Only a guild leader can accept fealty!");
|
||||
if (GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "Only a guild leader can accept fealty!");
|
||||
return true;
|
||||
}
|
||||
|
||||
//source guild is limited to 7 subs
|
||||
//TODO this should be based on TOL rank
|
||||
|
||||
if (!targetGuild.canSubAGuild(sourceGuild)) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
if (!nation.canSubAGuild(protectorate)) {
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
|
||||
//all tests passed, let's Handle code
|
||||
//Update Target Guild State.
|
||||
|
||||
sourceGuild.upgradeGuildState(false);
|
||||
// Update database
|
||||
|
||||
//Add sub so GuildMaster can Swear in.
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(protectorate.getObjectUUID(), nation.getObjectUUID())) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
ArrayList<Guild> subs = targetGuild.getSubGuildList();
|
||||
subs.add(sourceGuild);
|
||||
//update Guild states.
|
||||
|
||||
targetGuild.setGuildState(GuildState.Nation);
|
||||
protectorate.setNation(nation);
|
||||
GuildManager.updateAllGuildTags(protectorate);
|
||||
protectorate.upgradeGuildState(false);
|
||||
|
||||
if (nation.getGuildState() == GuildState.Sovereign)
|
||||
nation.upgradeGuildState(true);
|
||||
|
||||
//Let's send the message back.
|
||||
|
||||
msg.setUnknown02(1);
|
||||
msg.setResponse("Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
msg.setResponse("Your guild is now a " + protectorate.getGuildState().name() + '.');
|
||||
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
ChatManager.chatSystemInfo(sourcePlayer, "Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
ChatManager.chatSystemInfo(playerCharacter, "Your guild is now a " + protectorate.getGuildState().name() + '.');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user