|
|
|
@ -70,6 +70,9 @@ public class GuildLogic {
|
|
|
|
|
MessageUtil.sendErrorResponse(session,0,msgId,err);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isEmpty(announce)){
|
|
|
|
|
announce= SGuildSetting.sGuildSetting.getDefaultDeclaration();
|
|
|
|
|
}
|
|
|
|
|
GuildInfo guildInfo = new GuildInfo(user.getId(),familyName,announce);
|
|
|
|
|
GuilidManager.addGuildInfo(guildInfo);
|
|
|
|
|
user.getPlayerInfoManager().setGuildId(guildInfo.getId());
|
|
|
|
@ -114,10 +117,11 @@ public class GuildLogic {
|
|
|
|
|
int msgId = MessageTypeProto.MessageType.FAMILY_RECOMEND_RESPONSE_VALUE;
|
|
|
|
|
Collection<GuildInfo> guildInfos = GuilidManager.recommandGuild(user);
|
|
|
|
|
Family.FamilyRecommandResponse.Builder builder = Family.FamilyRecommandResponse.newBuilder();
|
|
|
|
|
Map<Integer, GuildApply> applyGuildInfos = GuilidManager.getApplyGuildInfos(uid, 1);
|
|
|
|
|
for(GuildInfo guildInfo : guildInfos){
|
|
|
|
|
builder.addFamilyRecomandInfo(Family.FamilyRecomandInfo.newBuilder().
|
|
|
|
|
setFamilyBaseInfo(CBean2Proto.getFamilyBaseInfo(guildInfo))
|
|
|
|
|
.setIsApply(0)
|
|
|
|
|
.setIsApply(applyGuildInfos.containsKey(guildInfo.getId())?1:0)
|
|
|
|
|
.build());
|
|
|
|
|
}
|
|
|
|
|
MessageUtil.sendMessage(session,1,msgId,builder.build(),true);
|
|
|
|
@ -140,9 +144,10 @@ public class GuildLogic {
|
|
|
|
|
MessageUtil.sendErrorResponse(session,0,msgId,searchName +"公会不存在");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Map<Integer, GuildApply> applyGuildInfos = GuilidManager.getApplyGuildInfos(session.getUid(), 1);
|
|
|
|
|
Family.FamilySeachResponse build = Family.FamilySeachResponse.newBuilder().addFamilyRecomandInfo(Family.FamilyRecomandInfo.newBuilder().
|
|
|
|
|
setFamilyBaseInfo(CBean2Proto.getFamilyBaseInfo(guildInfo))
|
|
|
|
|
.setIsApply(0)
|
|
|
|
|
.setIsApply(applyGuildInfos.containsKey(guildInfo.getId())?1:0)
|
|
|
|
|
.build()).build();
|
|
|
|
|
MessageUtil.sendMessage(session,1,msgId,build,true);
|
|
|
|
|
}
|
|
|
|
@ -262,16 +267,21 @@ public class GuildLogic {
|
|
|
|
|
MessageUtil.sendErrorResponse(session,0,msgId,"未加入公会");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Map<Integer, GuildApply> applyGuildInfos = GuilidManager.getApplyGuildInfos(user.getPlayerInfoManager().getGuildId(), 1);
|
|
|
|
|
Map<Integer, GuildApply> applyGuildInfos = GuilidManager.getApplyGuildInfos(user.getPlayerInfoManager().getGuildId(), 0);
|
|
|
|
|
List<GuildApply> guildApplies = new ArrayList<>();
|
|
|
|
|
int now =(int)(System.currentTimeMillis()/1000);
|
|
|
|
|
for(GuildApply guildApply :applyGuildInfos.values()){
|
|
|
|
|
if(now - guildApply.getCreateTime() > SGuildSetting.sGuildSetting.getApplyReserve()){
|
|
|
|
|
GuilidManager.removeOneApplyGuildInfos(guildApply.getGuildId(),guildApply.getId());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
guildApplies.add(guildApply);
|
|
|
|
|
}
|
|
|
|
|
Collections.sort(guildApplies);
|
|
|
|
|
Family.GetFamilyApplyResponse.Builder builder = Family.GetFamilyApplyResponse.newBuilder();
|
|
|
|
|
for(GuildApply guildApply :guildApplies){
|
|
|
|
|
User userTmp = UserManager.getUser(guildApply.getId());
|
|
|
|
|
builder.addFamilyApply(CBean2Proto.getFamilyApplyInfo(userTmp)).build();
|
|
|
|
|
builder.addFamilyApply(CBean2Proto.getFamilyApplyInfo(userTmp,guildApply.getCreateTime())).build();
|
|
|
|
|
}
|
|
|
|
|
MessageUtil.sendMessage(session,1,msgId,builder.build(),true);
|
|
|
|
|
}
|
|
|
|
@ -302,12 +312,13 @@ public class GuildLogic {
|
|
|
|
|
for(Set<Integer> memberOfType : members.values()){
|
|
|
|
|
count+=memberOfType.size();
|
|
|
|
|
}
|
|
|
|
|
Map<Integer, GuildApply> applyGuildInfos = GuilidManager.getApplyGuildInfos(guildId, 1);
|
|
|
|
|
Map<Integer, GuildApply> applyGuildInfos = GuilidManager.getApplyGuildInfos(guildId, 0);
|
|
|
|
|
for(Integer addUid : applyGuildInfos.keySet()){
|
|
|
|
|
if(30-count<=0){
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
guildInfo.addMembers(addUid,GlobalsDef.MEMBER);
|
|
|
|
|
guildInfo.addMembers(GlobalsDef.MEMBER,addUid);
|
|
|
|
|
sendFamilyJoinIndication(addUid,guildInfo);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@ -315,7 +326,11 @@ public class GuildLogic {
|
|
|
|
|
GuilidManager.removeApplyGuildInfos(guildId);
|
|
|
|
|
break;
|
|
|
|
|
case 3: //同意一个
|
|
|
|
|
guildInfo.addMembers(applyId,GlobalsDef.MEMBER);
|
|
|
|
|
guildInfo.addMembers(GlobalsDef.MEMBER,applyId);
|
|
|
|
|
User targetUser = UserManager.getUser(applyId);
|
|
|
|
|
targetUser.getPlayerInfoManager().setGuildId(guildInfo.getId());
|
|
|
|
|
GuilidManager.removeOneApplyGuildInfos(guildId,applyId);
|
|
|
|
|
sendFamilyJoinIndication(applyId,guildInfo);
|
|
|
|
|
break;
|
|
|
|
|
case 4: //拒绝一个
|
|
|
|
|
GuilidManager.removeOneApplyGuildInfos(guildId,applyId);
|
|
|
|
@ -384,10 +399,6 @@ public class GuildLogic {
|
|
|
|
|
MessageUtil.sendErrorResponse(session,0,msgId,"未加入公会");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(position == 1){
|
|
|
|
|
MessageUtil.sendErrorResponse(session,0,msgId,"bu");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
|
|
|
|
int uidType = getMemberType(uid, guildInfo.getMembers());
|
|
|
|
|
int targetType = getMemberType(uid, guildInfo.getMembers());
|
|
|
|
@ -397,8 +408,12 @@ public class GuildLogic {
|
|
|
|
|
}
|
|
|
|
|
guildInfo.removeMember(targetType,targetUid);
|
|
|
|
|
guildInfo.addMembers(position,targetUid);
|
|
|
|
|
|
|
|
|
|
sendPositionChange(targetUid,position);
|
|
|
|
|
if(position == GlobalsDef.CHAIRMAN){
|
|
|
|
|
guildInfo.removeMember(GlobalsDef.CHAIRMAN,uid);
|
|
|
|
|
guildInfo.addMembers(GlobalsDef.MEMBER,targetUid);
|
|
|
|
|
sendPositionChange(uid,GlobalsDef.MEMBER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageUtil.sendMessage(session,1,msgId,null,true);
|
|
|
|
|
}
|
|
|
|
@ -501,6 +516,26 @@ public class GuildLogic {
|
|
|
|
|
MessageUtil.sendMessage(session,1,msgId,null,true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void levelFamily(ISession session) throws Exception {
|
|
|
|
|
int msgId = MessageTypeProto.MessageType.FAMILY_LEVEL_RESPONSE_VALUE;
|
|
|
|
|
int uid = session.getUid();
|
|
|
|
|
User user = UserManager.getUser(uid);
|
|
|
|
|
int guildId = user.getPlayerInfoManager().getGuildId();
|
|
|
|
|
if(guildId == 0){
|
|
|
|
|
MessageUtil.sendErrorResponse(session,0,msgId,"未加入公会");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
|
|
|
|
int uidType = getMemberType(uid, guildInfo.getMembers());
|
|
|
|
|
if(uidType == GlobalsDef.CHAIRMAN){
|
|
|
|
|
MessageUtil.sendErrorResponse(session,0,msgId,"会长不能退出公会");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
user.getPlayerInfoManager().setGuildId(uid);
|
|
|
|
|
MessageUtil.sendMessage(session,1,msgId,null,true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void sendPositionChange(int uid,int position){
|
|
|
|
|
ISession session = OnlineUserManager.getSessionByUid(uid);
|
|
|
|
|
if(session!=null){
|
|
|
|
@ -524,6 +559,17 @@ public class GuildLogic {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void sendFamilyJoinIndication(int uid,GuildInfo guildInfo) throws Exception {
|
|
|
|
|
ISession session = OnlineUserManager.getSessionByUid(uid);
|
|
|
|
|
if(session!=null){
|
|
|
|
|
User user = UserManager.getUser(uid);
|
|
|
|
|
Family.FamilyJoinIndicaion.Builder builder = Family.FamilyJoinIndicaion.newBuilder();
|
|
|
|
|
Family.FamilyJoinIndicaion build = builder.setFamilyBaseInfo(CBean2Proto.getFamilyBaseInfo(guildInfo)).setFamilyUserInfo(CBean2Proto.getFamilyUserInfo(user, GlobalsDef.MEMBER)).build();
|
|
|
|
|
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.FAMILY_JOIN_INDICATION_VALUE,build,true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void addGuildLog(int guildId, int type,String name) throws Exception {
|
|
|
|
|
switch (type) {
|
|
|
|
|
case GuildDef.Log.CREATE: {
|
|
|
|
|