back_recharge
mashiyu 2019-01-23 09:53:58 +08:00
commit 50ee40a186
2 changed files with 34 additions and 17 deletions

View File

@ -3,11 +3,12 @@ package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager; import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table; import com.ljsd.jieling.logic.Table;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Table(name = "HeroRankupConfig") @Table(name = "HeroRankupConfig")
public class SCHeroRankUpConfig implements BaseConfig{ public class SCHeroRankUpConfig implements BaseConfig{
public static Map<Integer,SCHeroRankUpConfig> scHeroRankUpConfigMap; public static Map<Integer,Map<Integer,SCHeroRankUpConfig>> scHeroRankUpConfigByType;
private int id; private int id;
@ -23,17 +24,28 @@ public class SCHeroRankUpConfig implements BaseConfig{
private int openStar; private int openStar;
private int consumeMaterial[]; private int consumeMaterial[][];
private int[] consumeCard[];
@Override @Override
public void init() throws Exception { public void init() throws Exception {
// scHeroRankUpConfigMap = STableManager.getConfig(SCHeroRankUpConfig.class); Map<Integer,Map<Integer,SCHeroRankUpConfig>> result = new HashMap<>();
Map<Integer, SCHeroRankUpConfig> config = STableManager.getConfig(SCHeroRankUpConfig.class);
for(SCHeroRankUpConfig scHeroRankUpConfig: config.values()){
int type = scHeroRankUpConfig.getType();
if(!result.containsKey(type)){
result.put(type,new HashMap<>());
}
if(type == 1){
result.get(type).put(scHeroRankUpConfig.getLimitLevel(),scHeroRankUpConfig);
}else{
result.get(type).put(scHeroRankUpConfig.getLimitStar(),scHeroRankUpConfig);
}
}
scHeroRankUpConfigByType = result;
} }
public static Map<Integer, SCHeroRankUpConfig> getScHeroRankUpConfigMap() { public static Map<Integer, SCHeroRankUpConfig> getScHeroRankUpConfigByType(int type) {
return scHeroRankUpConfigMap; return scHeroRankUpConfigByType.get(type);
} }
public int getId() { public int getId() {
@ -64,11 +76,7 @@ public class SCHeroRankUpConfig implements BaseConfig{
return openStar; return openStar;
} }
public int[] getConsumeMaterial() { public int[][] getConsumeMaterial() {
return consumeMaterial; return consumeMaterial;
} }
public int[][] getConsumeCard() {
return consumeCard;
}
} }

View File

@ -1,14 +1,18 @@
package com.ljsd.jieling.util; package com.ljsd.jieling.util;
import com.google.protobuf.GeneratedMessage; import com.google.protobuf.GeneratedMessage;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.netty.PackageConstant; import com.ljsd.jieling.netty.PackageConstant;
import com.ljsd.jieling.netty.cocdex.Tea; import com.ljsd.jieling.netty.cocdex.Tea;
import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.protocols.MessageTypeProto;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Base64;
public class MessageUtil { public class MessageUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class); private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class);
@ -79,11 +83,16 @@ public class MessageUtil {
session.writeAndFlush(byteBuf); session.writeAndFlush(byteBuf);
} }
// public static void sendErrorResponse(Msg msg, GeneratedMessage error_message, int msgId) throws Exception { public static void sendErrorResponse(ISession session,int errorCode,int msgId,String errMsg) throws Exception {
// String protoEntity = Base64.getEncoder().encodeToString(error_message.toByteArray()); GeneratedMessage generatedMessage = null;
// BaseGlobal.redisApp.hset(RedisKey.RESPONSE, String.valueOf(msg.getUid()), String.valueOf(Math.abs(msg.getIndex())), new ProtoEntity(msgId, protoEntity), -1); if(errorCode!=1 && !StringUtil.isEmpty(errMsg)){
// sendMessage(msg.getSession(), msg.getUid(), msg.getIndex(), 1, msgId, error_message, true); generatedMessage = CommonProto.ErrorResponse.newBuilder().setErrCode(errorCode).setErrMsg(errMsg).build();
// } }
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), session.getIndex(),
errorCode,msgId, generatedMessage);
session.writeAndFlush(byteBuf);
}
// //
// public static void sendResponse(Msg msg, int msgId, GeneratedMessage generatedMessage) throws Exception { // public static void sendResponse(Msg msg, int msgId, GeneratedMessage generatedMessage) throws Exception {
// String protoEntity = Base64.getEncoder().encodeToString(generatedMessage.toByteArray()); // String protoEntity = Base64.getEncoder().encodeToString(generatedMessage.toByteArray());