公会改名提交

lvxinran 2019-12-17 22:15:06 +08:00
parent 460a9ad41a
commit b00ab56b99
5 changed files with 42 additions and 14 deletions

View File

@ -177,5 +177,7 @@ public interface BIReason {
int TREASURE_RESET_CONCUME = 1044;//孙龙宝藏重置删除积分
int FAMILY_RENAME = 1045;//公会改名
}

View File

@ -9,16 +9,14 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class FamilyChangeNoticHandler extends BaseHandler {
public class FamilyChangeNoticHandler extends BaseHandler<Family.FamilyChangeRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.FAMILY_CHANGE_NOTICE_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] bytes = netData.parseClientProtoNetData();
Family.FamilyChangeRequest familyChangeRequest = Family.FamilyChangeRequest.parseFrom(bytes);
GuildLogic.changeNotice(iSession,familyChangeRequest.getContent());
public void processWithProto(ISession iSession, Family.FamilyChangeRequest proto) throws Exception {
GuildLogic.changeNotice(iSession,proto.getType(),proto.getContent());
}
}

View File

@ -92,6 +92,8 @@ public class GuildInfo extends MongoBase {
public void setAnnounce(String announce) {
this.announce = announce;
updateString("announce",announce);
}
public int getId() {
@ -102,6 +104,12 @@ public class GuildInfo extends MongoBase {
return name;
}
public void setName(String name) {
this.name = name;
updateString("name",name);
}
public String getAnnounce() {
return announce;
}

View File

@ -91,6 +91,13 @@ public class GuildLogic {
if(!"".equals(err)){
throw new ErrorCodeException(ErrorCode.newDefineCode(err));
}
boolean enough= ItemUtil.itemCost(user, SGuildSetting.sGuildSetting.getCreatCost(), BIReason.CREATE_GUILD_CONSUME, 0);
if(!enough){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
if(user.getPlayerInfoManager().getGuildId()!=0){
throw new ErrorCodeException(ErrorCode.FAMILY_IN);
}
if(StringUtil.isEmpty(announce)){
announce= SGuildSetting.sGuildSetting.getDefaultDeclaration();
}
@ -134,13 +141,7 @@ public class GuildLogic {
return "此名已存在";
}
}
boolean enough= ItemUtil.itemCost(user, SGuildSetting.sGuildSetting.getCreatCost(), BIReason.CREATE_GUILD_CONSUME, 0);
if(!enough){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
if(user.getPlayerInfoManager().getGuildId()!=0){
throw new ErrorCodeException(ErrorCode.FAMILY_IN);
}
return "";
}
@ -654,7 +655,7 @@ public class GuildLogic {
* @param session
* @param content
*/
public static void changeNotice(ISession session,String content) throws Exception {
public static void changeNotice(ISession session,int type,String content) throws Exception {
int msgId = MessageTypeProto.MessageType.FAMILY_CHANGE_NOTICE_RESPONSE_VALUE;
int uid = session.getUid();
User user = UserManager.getUser(uid);
@ -683,7 +684,20 @@ public class GuildLogic {
if(resultCode==0){
throw new ErrorCodeException(ErrorCode.FAMILY_IN_SENSITIVE);
}else{
guildInfo.setAnnounce(content);
if(type==1){
guildInfo.setAnnounce(content);
}else{
String checkResult = checkForCreateGuild(user, content, guildInfo.getAnnounce());
if(!"".equals(checkResult)){
throw new ErrorCodeException(ErrorCode.newDefineCode(checkResult));
}
int[][] renameCost = SGuildSetting.sGuildSetting.getRenameCost();
boolean b = ItemUtil.itemCost(user, renameCost, BIReason.FAMILY_RENAME, 1);
if(!b){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
guildInfo.setName(content);
}
MessageUtil.sendMessage(session,resultCode,msgId,response,true);
}
}

View File

@ -66,6 +66,8 @@ public class SGuildSetting implements BaseConfig {
private int warTime;
private int[][] renameCost;
public static SGuildSetting sGuildSetting;
@ -195,4 +197,8 @@ public class SGuildSetting implements BaseConfig {
public int getWarTime() {
return warTime;
}
public int[][] getRenameCost() {
return renameCost;
}
}