Merge branch 'master' of http://60.1.1.230/backend/jieling_server
# Conflicts: # serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.javaback_recharge
commit
565fd161d6
|
@ -54,4 +54,4 @@ int int int int int int float float float float float mut,int#int,2 mut,int#int,
|
|||
52 2052 0 0 4 10 1834 140 0 220 176 10100#10|10101#20 null
|
||||
53 2053 0 0 4 10 1943 135 219 0 176 10100#10|10101#20 null
|
||||
54 2054 0 0 4 10 1630 169 0 176 163 10100#10|10101#20 null
|
||||
55 2055 0 0 4 10 1508 205 163 0 194 10100#10|10101#20 null
|
||||
55 2055 0 0 4 10 1508 205 163 0 194 10100#10|10101#20 null
|
||||
|
|
|
@ -27,6 +27,7 @@ dependencies {
|
|||
compile("com.google.protobuf:protobuf-java:2.5.0")
|
||||
compile("com.fasterxml.jackson.core:jackson-core:2.3.1")
|
||||
compile("com.fasterxml.jackson.core:jackson-databind:2.3.3")
|
||||
compile group: 'com.google.code.gson', name: 'gson', version: '2.2.4'
|
||||
compile files("${System.properties['java.home']}/../lib/tools.jar")
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class GameApplication {
|
|||
|
||||
RedisUtil.getInstence().init(configurableApplicationContext);
|
||||
|
||||
STableManager.initialize("com.ljsd.jieling.config");
|
||||
// STableManager.initialize("com.ljsd.jieling.config");
|
||||
|
||||
UserManager.init(configurableApplicationContext);
|
||||
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name = "HeroRankupConfig")
|
||||
public class SCHeroRankUpConfig implements BaseConfig{
|
||||
public static Map<Integer,SCHeroRankUpConfig> scHeroRankUpConfigMap;
|
||||
|
||||
private int id;
|
||||
|
||||
private int type;
|
||||
|
||||
private float rankupPara;
|
||||
|
||||
private int limitLevel;
|
||||
|
||||
private int openLevel;
|
||||
|
||||
private int limitStar;
|
||||
|
||||
private int openStar;
|
||||
|
||||
private int consumeMaterial[];
|
||||
|
||||
private int[] consumeCard[];
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
scHeroRankUpConfigMap = STableManager.getConfig(SCHeroRankUpConfig.class);
|
||||
}
|
||||
|
||||
public static Map<Integer, SCHeroRankUpConfig> getScHeroRankUpConfigMap() {
|
||||
return scHeroRankUpConfigMap;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public float getRankupPara() {
|
||||
return rankupPara;
|
||||
}
|
||||
|
||||
public int getLimitLevel() {
|
||||
return limitLevel;
|
||||
}
|
||||
|
||||
public int getOpenLevel() {
|
||||
return openLevel;
|
||||
}
|
||||
|
||||
public int getLimitStar() {
|
||||
return limitStar;
|
||||
}
|
||||
|
||||
public int getOpenStar() {
|
||||
return openStar;
|
||||
}
|
||||
|
||||
public int[] getConsumeMaterial() {
|
||||
return consumeMaterial;
|
||||
}
|
||||
|
||||
public int[][] getConsumeCard() {
|
||||
return consumeCard;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name = "HeroLevelConfig")
|
||||
public class SHeroLevlConfig implements BaseConfig{
|
||||
|
||||
public static Map<Integer, SHeroLevlConfig> sHeroLevlConfigMap;
|
||||
|
||||
private int id;
|
||||
|
||||
private int level;
|
||||
|
||||
private float characterLevelPara;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sHeroLevlConfigMap = STableManager.getConfig(SHeroLevlConfig.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Map<Integer, SHeroLevlConfig> getsCHero() {
|
||||
return sHeroLevlConfigMap;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public static Map<Integer, SHeroLevlConfig> getsHeroLevlConfigMap() {
|
||||
return sHeroLevlConfigMap;
|
||||
}
|
||||
|
||||
public float getCharacterLevelPara() {
|
||||
return characterLevelPara;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.db.redis;
|
||||
|
||||
public class RedisKey {
|
||||
|
||||
private final static String Delimiter_colon = ":";
|
||||
|
||||
private final static String areaId = "0";
|
||||
|
||||
public static final String TOKEN = "JL_TOKEN";
|
||||
|
||||
/**
|
||||
* 最近登录服务器列表
|
||||
*/
|
||||
public static final String USER_SERVER_INFO = "JL_USER_SERVER_INFO";
|
||||
|
||||
|
||||
|
||||
|
||||
public static String getKey(String type, String key, boolean withServerId) {
|
||||
if (withServerId) {
|
||||
return areaId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
|
||||
} else {
|
||||
return type + Delimiter_colon + String.valueOf(key);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.db.redis;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
|
@ -15,6 +16,8 @@ import java.util.concurrent.TimeUnit;
|
|||
public class RedisUtil {
|
||||
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
private RedisUtil() {
|
||||
}
|
||||
|
||||
|
@ -195,12 +198,12 @@ public class RedisUtil {
|
|||
*
|
||||
* @param key
|
||||
* 键 不能为null
|
||||
* @param item
|
||||
* @param mapKey
|
||||
* 项 不能为null
|
||||
* @return 值
|
||||
*/
|
||||
public Object hget(String key, String item) {
|
||||
return redisTemplate.opsForHash().get(key, item);
|
||||
public Object hget(String key, String mapKey) {
|
||||
return redisTemplate.opsForHash().get(key, mapKey);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,15 +265,18 @@ public class RedisUtil {
|
|||
*
|
||||
* @param key
|
||||
* 键
|
||||
* @param item
|
||||
* @param mapKey
|
||||
* 项
|
||||
* @param value
|
||||
* 值
|
||||
* @return true 成功 false失败
|
||||
*/
|
||||
public boolean hset(String key, String item, Object value) {
|
||||
public boolean hset(String key, String mapKey, Object value) {
|
||||
try {
|
||||
redisTemplate.opsForHash().put(key, item, value);
|
||||
if (!(value instanceof String)){
|
||||
value = gson.toJson(value);
|
||||
}
|
||||
redisTemplate.opsForHash().put(key, mapKey, value);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -283,7 +289,7 @@ public class RedisUtil {
|
|||
*
|
||||
* @param key
|
||||
* 键
|
||||
* @param item
|
||||
* @param mapKey
|
||||
* 项
|
||||
* @param value
|
||||
* 值
|
||||
|
@ -291,9 +297,12 @@ public class RedisUtil {
|
|||
* 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
|
||||
* @return true 成功 false失败
|
||||
*/
|
||||
public boolean hset(String key, String item, Object value, long time) {
|
||||
public boolean hset(String key, String mapKey, Object value, long time) {
|
||||
try {
|
||||
redisTemplate.opsForHash().put(key, item, value);
|
||||
if (!(value instanceof String)){
|
||||
value = gson.toJson(value);
|
||||
}
|
||||
redisTemplate.opsForHash().put(key, mapKey, value);
|
||||
if (time > 0) {
|
||||
expire(key, time);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class DrawHeroHandler extends BaseHandler {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DrawHeroHandler.class);
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.DRAW_HERO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
int userId = netData.getUserId();
|
||||
int token = netData.getToken();
|
||||
int msgId = netData.getMsgId();
|
||||
int msgIndex = netData.getIndex();
|
||||
HeroInfoProto.DrawHeroRequest request
|
||||
= HeroInfoProto.DrawHeroRequest.parseFrom(netData.parseClientProtoNetData());
|
||||
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
|
||||
userId, token,msgId,msgIndex,request.getType(),request.getStr());
|
||||
|
||||
|
||||
List<CommonProto.Hero> heroList = new ArrayList<>();
|
||||
CommonProto.Hero hero1 = CommonProto.Hero.newBuilder()
|
||||
.setId("aaa")
|
||||
.setHeroId(1)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.build();
|
||||
|
||||
CommonProto.Hero hero2 = CommonProto.Hero.newBuilder()
|
||||
.setId("bbb")
|
||||
.setHeroId(2)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.build();
|
||||
|
||||
CommonProto.Hero hero3 = CommonProto.Hero.newBuilder()
|
||||
.setId("ccc")
|
||||
.setHeroId(3)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.build();
|
||||
|
||||
heroList.add(hero1);
|
||||
heroList.add(hero2);
|
||||
heroList.add(hero3);
|
||||
|
||||
HeroInfoProto.DrawHeroResponse build
|
||||
= HeroInfoProto.DrawHeroResponse.newBuilder()
|
||||
.addAllHeroList(heroList)
|
||||
.build();
|
||||
|
||||
try {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.DRAW_HERO_RESPONSE_VALUE, build, true);
|
||||
LOGGER.info("back to client!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ public class GMRequestHandler extends BaseHandler{
|
|||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GM_COMMAND;
|
||||
return MessageTypeProto.MessageType.GM_REQUEST;
|
||||
}
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class GetAllHerosHandler extends BaseHandler{
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GetAllHerosHandler.class);
|
||||
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GET_HEROINFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
int userId = netData.getUserId();
|
||||
int token = netData.getToken();
|
||||
int msgId = netData.getMsgId();
|
||||
int msgIndex = netData.getIndex();
|
||||
byte[] message = netData.parseClientProtoNetData();
|
||||
HeroInfoProto.GetHeroListInfoRequest getHeroInfoRequest
|
||||
= HeroInfoProto.GetHeroListInfoRequest.parseFrom(message);
|
||||
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
|
||||
userId, token,msgId,msgIndex,getHeroInfoRequest.getNum(),getHeroInfoRequest.getStr());
|
||||
|
||||
// // SCHero scHero = SCHero.getsCHero().get(1);
|
||||
|
||||
List<CommonProto.Hero> heroList = new ArrayList<>();
|
||||
CommonProto.Hero hero1 = CommonProto.Hero.newBuilder()
|
||||
.setId("aaa")
|
||||
.setHeroId(1)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.build();
|
||||
|
||||
CommonProto.Hero hero2 = CommonProto.Hero.newBuilder()
|
||||
.setId("bbb")
|
||||
.setHeroId(2)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.build();
|
||||
|
||||
CommonProto.Hero hero3 = CommonProto.Hero.newBuilder()
|
||||
.setId("ccc")
|
||||
.setHeroId(3)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.build();
|
||||
|
||||
heroList.add(hero1);
|
||||
heroList.add(hero2);
|
||||
heroList.add(hero3);
|
||||
|
||||
HeroInfoProto.GetHeroListInfoResponse build
|
||||
= HeroInfoProto.GetHeroListInfoResponse.newBuilder()
|
||||
.addAllHeroList(heroList)
|
||||
.build();
|
||||
|
||||
try {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_HEROINFO_RESPONSE_VALUE, build, true);
|
||||
LOGGER.info("back to client!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,12 +2,17 @@ package com.ljsd.jieling.handler;
|
|||
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class GetAllItemHandler extends BaseHandler {
|
||||
|
||||
|
@ -24,11 +29,41 @@ public class GetAllItemHandler extends BaseHandler {
|
|||
int token = netData.getToken();
|
||||
int msgId = netData.getMsgId();
|
||||
int msgIndex = netData.getIndex();
|
||||
PlayerInfoProto.PlayerInfo.GetItemInfoRequest getItemInfoRequest
|
||||
= PlayerInfoProto.PlayerInfo.GetItemInfoRequest.parseFrom(netData.parseClientProtoNetData());
|
||||
PlayerInfoProto.GetItemInfoRequest getItemInfoRequest
|
||||
= PlayerInfoProto.GetItemInfoRequest.parseFrom(netData.parseClientProtoNetData());
|
||||
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
|
||||
userId, token,msgId,msgIndex,getItemInfoRequest.getNum(),getItemInfoRequest.getStr());
|
||||
|
||||
List<CommonProto.Item> itemList = new ArrayList<>();
|
||||
CommonProto.Item item1 = CommonProto.Item.newBuilder()
|
||||
.setItemId(1)
|
||||
.setItemNum(111)
|
||||
.build();
|
||||
CommonProto.Item item2 = CommonProto.Item.newBuilder()
|
||||
.setItemId(2)
|
||||
.setItemNum(222)
|
||||
.build();
|
||||
CommonProto.Item item3 = CommonProto.Item.newBuilder()
|
||||
.setItemId(3)
|
||||
.setItemNum(333)
|
||||
.build();
|
||||
|
||||
|
||||
itemList.add(item1);
|
||||
itemList.add(item2);
|
||||
itemList.add(item3);
|
||||
|
||||
// User user = UserManager.getUserForLogin(userId);
|
||||
// List<CommonProto.Item> itemList = ItemUtil.getAllItem(user);
|
||||
PlayerInfoProto.GetItemInfoResponse getItemInfoResponse = PlayerInfoProto.GetItemInfoResponse.newBuilder()
|
||||
.addAllItemlist(itemList)
|
||||
.build();
|
||||
try {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_ITEMINFO_RESPONSE_VALUE, getItemInfoResponse, true);
|
||||
LOGGER.info("back to client!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.logic.dao.User;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
|
@ -30,18 +31,18 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
int token = netData.getToken();
|
||||
int msgId = netData.getMsgId();
|
||||
int msgIndex = netData.getIndex();
|
||||
PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest getPlayerInfoRequest
|
||||
= PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest.parseFrom(netData.parseClientProtoNetData());
|
||||
PlayerInfoProto.GetPlayerInfoRequest getPlayerInfoRequest
|
||||
= PlayerInfoProto.GetPlayerInfoRequest.parseFrom(netData.parseClientProtoNetData());
|
||||
|
||||
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
|
||||
userId, token,msgId,msgIndex,getPlayerInfoRequest.getNum(),getPlayerInfoRequest.getStr());
|
||||
|
||||
User user = UserManager.getUserForLogin(userId);
|
||||
|
||||
CommonProto.Common.Player player = CBean2Proto.getPlayer(userId, user.getPlayerInfoManager());
|
||||
CommonProto.Player player = CBean2Proto.getPlayer(userId, user.getPlayerInfoManager());
|
||||
|
||||
PlayerInfoProto.PlayerInfo.GetPlayerInfoResponse getPlayerInfoResponse
|
||||
= PlayerInfoProto.PlayerInfo.GetPlayerInfoResponse.newBuilder()
|
||||
PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse
|
||||
= PlayerInfoProto.GetPlayerInfoResponse.newBuilder()
|
||||
.setPlayer(player)
|
||||
.build();
|
||||
try {
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.ljsd.jieling.logic.dao.User;
|
|||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
|
@ -30,18 +29,35 @@ public class LoginRequestHandler extends BaseHandler {
|
|||
int msgId = netData.getMsgId();
|
||||
int msgIndex = netData.getIndex();
|
||||
byte[] message = netData.parseClientProtoNetData();
|
||||
PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest getPlayerInfoRequest
|
||||
= PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest.parseFrom(message);
|
||||
PlayerInfoProto.LoginRequest loginRequest
|
||||
= PlayerInfoProto.LoginRequest.parseFrom(message);
|
||||
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
|
||||
userId, token,msgId,msgIndex,getPlayerInfoRequest.getNum(),getPlayerInfoRequest.getStr());
|
||||
//TODO
|
||||
User userForLogin = UserManager.getUserForLogin(userId);
|
||||
userId, token,msgId,msgIndex,loginRequest.getNum(),loginRequest.getStr());
|
||||
|
||||
PlayerInfoProto.PlayerInfo.LoginResponse loginResponse
|
||||
= PlayerInfoProto.PlayerInfo.LoginResponse.newBuilder()
|
||||
//登陆注册入内存
|
||||
User user = UserManager.userLogin(userId);
|
||||
user.getPlayerInfoManager().setOpenId(loginRequest.getOpenId());
|
||||
|
||||
// UserServerInfo userServerInfo = new UserServerInfo(user.getPlayerInfoManager());
|
||||
// String key = RedisKey.getKey(RedisKey.USER_SERVER_INFO,loginRequest.getOpenId(),false);
|
||||
// RedisUtil.getInstence().hset(key,10086+"", userServerInfo);
|
||||
//
|
||||
// UserServerInfo userServerInfo1 = new UserServerInfo(user.getPlayerInfoManager());
|
||||
// RedisUtil.getInstence().hset(key,10087+"", userServerInfo1);
|
||||
//
|
||||
// UserServerInfo userServerInfo2 = new UserServerInfo(user.getPlayerInfoManager());
|
||||
// RedisUtil.getInstence().hset(key,10088+"", userServerInfo2);
|
||||
|
||||
// Map<String, UserServerInfo> userServerInfoMap = RedisUtil.getInstence().hget(RedisKey.USER_SERVER_INFO, loginRequest.getOpenId(), UserServerInfo.class, -1, false);
|
||||
|
||||
String newToken = UserManager.getNewToken(userId);
|
||||
|
||||
PlayerInfoProto.LoginResponse loginResponse
|
||||
= PlayerInfoProto.LoginResponse.newBuilder()
|
||||
.setResultCode(0)
|
||||
.setNewToken("123456")
|
||||
.setNewToken(newToken)
|
||||
.build();
|
||||
|
||||
try {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.LOGIN_RESPONSE_VALUE, loginResponse, true);
|
||||
LOGGER.info("back to client!");
|
||||
|
|
|
@ -17,7 +17,7 @@ public class MapEnterRequestHandler extends BaseHandler{
|
|||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] message = netData.parseClientProtoNetData();
|
||||
MapInfoProto.MapInfo.MapEnterRequest mapEnterRequest = MapInfoProto.MapInfo.MapEnterRequest.parseFrom(message);
|
||||
MapInfoProto.MapEnterRequest mapEnterRequest = MapInfoProto.MapEnterRequest.parseFrom(message);
|
||||
MapLogic.getInstance().enterMap(iSession, mapEnterRequest.getMapId(), MessageTypeProto.MessageType.MAP_ENTER_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class MapGetInfoRequestHandler extends BaseHandler {
|
|||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapInfoProto.MapInfo.MapGetInfoResponse mapGetInfoResponse = MapInfoProto.MapInfo.MapGetInfoResponse
|
||||
MapInfoProto.MapGetInfoResponse mapGetInfoResponse = MapInfoProto.MapGetInfoResponse
|
||||
.newBuilder()
|
||||
.setMapId(user.getMapManager().getCurMapId())
|
||||
.build();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.config.SCMap;
|
||||
import com.ljsd.jieling.config.SCMapEventsConfig;
|
||||
import com.ljsd.jieling.config.SCMapEventsItemConfig;
|
||||
import com.ljsd.jieling.logic.dao.MapManager;
|
||||
import com.ljsd.jieling.logic.dao.User;
|
||||
|
@ -11,7 +11,6 @@ import com.ljsd.jieling.protocols.CommonProto;
|
|||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.config.SCMapEventsConfig;
|
||||
import com.ljsd.jieling.util.ToolsUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -65,19 +64,20 @@ public class MapLogic {
|
|||
user.setMapManager(mapManager);
|
||||
}
|
||||
}
|
||||
List<CommonProto.Common.Cell> cells = new ArrayList<>(mapManager.getMapInfo().size());
|
||||
|
||||
List<CommonProto.Cell> cells = new ArrayList<>(mapManager.getMapInfo().size());
|
||||
for (Map.Entry<Integer, Cell> entry : mapManager.getMapInfo().entrySet()) {
|
||||
List<CommonProto.Common.CellEvent> cellEvents = new ArrayList<>();
|
||||
List<CommonProto.CellEvent> cellEvents = new ArrayList<>();
|
||||
Cell cell = entry.getValue();
|
||||
for (Map.Entry<Integer, Integer> cellEntry : cell.getEventIds().entrySet()) {
|
||||
CommonProto.Common.CellEvent cellEvent = CommonProto.Common.CellEvent
|
||||
CommonProto.CellEvent cellEvent = CommonProto.CellEvent
|
||||
.newBuilder()
|
||||
.setEventId(cellEntry.getKey())
|
||||
.setState(cellEntry.getValue())
|
||||
.build();
|
||||
cellEvents.add(cellEvent);
|
||||
}
|
||||
CommonProto.Common.Cell cellProto = CommonProto.Common.Cell
|
||||
CommonProto.Cell cellProto = CommonProto.Cell
|
||||
.newBuilder()
|
||||
.setCellId(entry.getKey())
|
||||
.addAllCellEvents(cellEvents)
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.ljsd.jieling.logic;
|
||||
|
||||
public class CalHeroFinalAttri {
|
||||
|
||||
public static CalHeroFinalAttri getInstance(){
|
||||
return Instance.instance;
|
||||
}
|
||||
|
||||
private static class Instance{
|
||||
public final static CalHeroFinalAttri instance = new CalHeroFinalAttri();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -30,7 +30,7 @@ public class Hero extends MongoBase {
|
|||
|
||||
private List<Skill> skillList;
|
||||
|
||||
private List<Equip> quipList;
|
||||
private List<Equip> equipList;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
|
@ -129,4 +129,20 @@ public class Hero extends MongoBase {
|
|||
public int getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public List<Skill> getSkillList() {
|
||||
return skillList;
|
||||
}
|
||||
|
||||
public void setSkillList(List<Skill> skillList) {
|
||||
this.skillList = skillList;
|
||||
}
|
||||
|
||||
public List<Equip> getEquipList() {
|
||||
return equipList;
|
||||
}
|
||||
|
||||
public void setEquipList(List<Equip> equipList) {
|
||||
this.equipList = equipList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ public class Item extends MongoBase {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
|
|
@ -5,9 +5,10 @@ import com.ljsd.jieling.config.SItem;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ItemManager extends MongoBase {
|
||||
private Map<Integer, Item> itemMap;
|
||||
private Map<Integer, Item> itemMap = new ConcurrentHashMap<>();
|
||||
|
||||
public ItemManager() {
|
||||
itemMap = new HashMap();
|
||||
|
|
|
@ -5,6 +5,8 @@ import com.ljsd.common.mogodb.MongoBase;
|
|||
|
||||
public class PlayerManager extends MongoBase {
|
||||
|
||||
private String openId;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private int level;
|
||||
|
@ -26,6 +28,14 @@ public class PlayerManager extends MongoBase {
|
|||
private int mapId;
|
||||
|
||||
|
||||
public String getOpenId() {
|
||||
return openId;
|
||||
}
|
||||
|
||||
public void setOpenId(String openId) {
|
||||
this.openId = openId;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@ import java.util.List;
|
|||
|
||||
public class Skill extends MongoBase {
|
||||
|
||||
private String id;
|
||||
|
||||
private int skillId;
|
||||
|
||||
private int skillType;
|
||||
|
@ -19,6 +17,7 @@ public class Skill extends MongoBase {
|
|||
|
||||
private List<Integer> effectIdList;
|
||||
|
||||
|
||||
public int getSkillId() {
|
||||
return skillId;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ public class UserManager {
|
|||
userMap.put(user._getIntId(), user);
|
||||
}
|
||||
|
||||
public static boolean isUserExist(int uid) {
|
||||
return userMap.containsKey(uid);
|
||||
}
|
||||
|
||||
public static User getUserForLogin(int uid) throws Exception {
|
||||
User user = userMap.get(uid);
|
||||
if (user == null) {
|
||||
|
@ -36,16 +40,51 @@ public class UserManager {
|
|||
}
|
||||
|
||||
private static void refreshUserLoginInfo(User user) {
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
||||
public static User userLogin(int uid) throws Exception {
|
||||
User user = ljsdMongoTemplate.findById(User.getCollectionName(), Integer.toString(uid), User.class);
|
||||
if (user == null) {
|
||||
user = registerUser(uid);
|
||||
}else {
|
||||
if (!UserManager.isUserExist(uid)){
|
||||
UserManager.addUser(user);
|
||||
}
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
private static User registerUser(int uid) throws Exception {
|
||||
User user = new User(uid,new PlayerManager(),new ItemManager(),new HeroManager(),new MapManager());
|
||||
initPlayer(user);
|
||||
UserManager.addUser(user);
|
||||
ljsdMongoTemplate.save(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
private static void initPlayer(User user) throws Exception {
|
||||
PlayerManager playerManager = user.getPlayerInfoManager();
|
||||
playerManager.setNickName("戒灵666");
|
||||
playerManager.setLevel(1);
|
||||
playerManager.setExp(0);
|
||||
playerManager.setVipLevel(0);
|
||||
playerManager.setFamilyId("12345");
|
||||
playerManager.setHead("image_head_1");
|
||||
playerManager.setGold(100000l);
|
||||
playerManager.setGem(9999);
|
||||
playerManager.setChargeGem(666);
|
||||
|
||||
ItemManager itemManager = user.getItemManager();
|
||||
//TODO
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
//TODO
|
||||
MapManager mapManager = user.getMapManager();
|
||||
//TODO
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static User getUser(int uid) throws Exception {
|
||||
User user = userMap.get(uid);
|
||||
|
@ -65,5 +104,8 @@ public class UserManager {
|
|||
}
|
||||
|
||||
|
||||
public static String getNewToken(int userId) {
|
||||
|
||||
return "33521";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
public class UserServerInfo {
|
||||
|
||||
private long loginTime;
|
||||
|
||||
private int level;
|
||||
|
||||
public UserServerInfo(PlayerManager playerInfoManager) {
|
||||
this.loginTime = System.currentTimeMillis();
|
||||
this.level = playerInfoManager.getLevel();
|
||||
}
|
||||
|
||||
public long getLoginTime() {
|
||||
return loginTime;
|
||||
}
|
||||
|
||||
public void setLoginTime(long loginTime) {
|
||||
this.loginTime = loginTime;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
}
|
|
@ -1,19 +1,20 @@
|
|||
package com.ljsd.jieling.util;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.Item;
|
||||
import com.ljsd.jieling.logic.dao.ItemManager;
|
||||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CBean2Proto {
|
||||
|
||||
|
||||
public static CommonProto.Common.Player getPlayer(int uid, PlayerManager playerManager) {
|
||||
CommonProto.Common.Player player = CommonProto.Common.Player
|
||||
public static CommonProto.Player getPlayer(int uid, PlayerManager playerManager) {
|
||||
CommonProto.Player player = CommonProto.Player
|
||||
.newBuilder()
|
||||
.setUid(uid)
|
||||
.setNickName(playerManager.getNickName())
|
||||
.setLevel(playerManager.getLevel())
|
||||
.setExp(playerManager.getExp())
|
||||
.setVipLevel(playerManager.getVipLevel())
|
||||
.setFamilyId(playerManager.getFamilyId())
|
||||
|
@ -25,8 +26,8 @@ public class CBean2Proto {
|
|||
return player;
|
||||
}
|
||||
|
||||
public static CommonProto.Common.Item getItem(Item item){
|
||||
CommonProto.Common.Item itemProto = CommonProto.Common.Item
|
||||
public static CommonProto.Item getItem(Item item){
|
||||
CommonProto.Item itemProto = CommonProto.Item
|
||||
.newBuilder()
|
||||
.setItemId(item.getItemId())
|
||||
.setItemNum(item.getItemNum())
|
||||
|
@ -35,12 +36,46 @@ public class CBean2Proto {
|
|||
return itemProto;
|
||||
}
|
||||
|
||||
public static CommonProto.Common.Hero getHero(Hero hero){
|
||||
CommonProto.Common.Hero heroProto = CommonProto.Common.Hero
|
||||
public static CommonProto.Hero getHero(Hero hero){
|
||||
CommonProto.Hero heroProto = CommonProto.Hero
|
||||
.newBuilder()
|
||||
|
||||
.setId(hero.getId())
|
||||
.setHeroId(hero.getTemplateId())
|
||||
.setHeroType(hero.getHeroType())
|
||||
.setLevel(hero.getLevel())
|
||||
.setStar(hero.getStar())
|
||||
.setQuality(1)
|
||||
.setHp(hero.getHp())
|
||||
.setAttack(hero.getAttack())
|
||||
.setPDefence(hero.getpDefence())
|
||||
.setMDefence(hero.getmDefence())
|
||||
.setSpeed(hero.getSpeed())
|
||||
.addAllSkillList(getHeroSkill(hero.getSkillList()))
|
||||
.addAllEquipList(getHeroEquip(hero.getEquipList()))
|
||||
.build();
|
||||
return heroProto;
|
||||
}
|
||||
|
||||
private static List<CommonProto.Skill> getHeroSkill(List<Skill> skillList) {
|
||||
|
||||
List<CommonProto.Skill> skills = new ArrayList<>();
|
||||
for(Skill skill : skillList){
|
||||
CommonProto.Skill skill1 = CommonProto.Skill
|
||||
.newBuilder()
|
||||
.setSkillId(skill.getSkillId())
|
||||
.setSkillType(skill.getSkillType())
|
||||
.setLevel(skill.getLevel())
|
||||
.setStar(skill.getStar())
|
||||
.addAllEffectId(skill.getEffectIdList())
|
||||
.build();
|
||||
skills.add(skill1);
|
||||
}
|
||||
return skills;
|
||||
}
|
||||
|
||||
private static List<CommonProto.Equip> getHeroEquip(List<Equip> equipList) {
|
||||
List<CommonProto.Equip> equips = new ArrayList<>();
|
||||
return equips;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,9 +5,12 @@ import com.ljsd.jieling.logic.dao.Item;
|
|||
import com.ljsd.jieling.logic.dao.ItemManager;
|
||||
import com.ljsd.jieling.logic.dao.User;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemUtil {
|
||||
|
@ -55,4 +58,17 @@ public class ItemUtil {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static List<CommonProto.Item > getAllItem(User user){
|
||||
List<CommonProto.Item > itemList = new ArrayList<>();
|
||||
ItemManager itemManager = user.getItemManager();
|
||||
Map<Integer, Item> itemMap = itemManager.getItemMap();
|
||||
if (itemMap.size() !=0 ){
|
||||
for (Map.Entry<Integer, Item> entry :itemMap.entrySet()){
|
||||
itemList.add(CBean2Proto.getItem(entry.getValue()));
|
||||
}
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ spring.redis.expireTime = -1
|
|||
#spring.data.mongodb.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/ysj_wx_1
|
||||
#spring.data.mongodb2.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/develop_ysj_wx_1
|
||||
#mongodb2 develop
|
||||
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/ysj_msy
|
||||
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_msy
|
||||
mongodb.options.maxWaitTime = 120000
|
||||
mongodb.options.connectTimeout = 1000
|
||||
mongodb.options.socketTimeout = 0
|
||||
|
|
|
@ -3,20 +3,99 @@ import org.apache.poi.ss.usermodel.*;
|
|||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class ExcelUtils {
|
||||
private static boolean isWrite = true;
|
||||
private static String excelPath ="tmp/";
|
||||
private static String path = "C:/ljsd/jieling_conf/";
|
||||
private static String excelPath ="D:/tmp/"; //excel 文件
|
||||
private static String path = "conf/server/";
|
||||
private static Set<String> oldFileNames = new HashSet<>();
|
||||
private static String javaFilePath = "serverlogic/src/main/java/com/ljsd/jieling/config/";
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
File oldfile = new File(path);
|
||||
String[] list = oldfile.list();
|
||||
oldFileNames.addAll(Arrays.asList(list));
|
||||
readExcelData();
|
||||
//只加载新文件
|
||||
Set<String> newFileNames = new HashSet<>();
|
||||
File newfile = new File(path);
|
||||
String[] newList = newfile.list();
|
||||
newFileNames.addAll(Arrays.asList(newList));
|
||||
newFileNames.removeAll(oldFileNames);
|
||||
if(!newFileNames.isEmpty()){
|
||||
for(String newFileName : newFileNames){
|
||||
String finalNewFileName = newFileName.replaceAll(".txt", "");
|
||||
genJavaFile(finalNewFileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static void genJavaFile(String fileName){
|
||||
|
||||
Map<String,String> fieldInfo = new HashMap<>();
|
||||
File file = new File("conf/server/"+fileName +".txt");
|
||||
StringBuffer stringBuffer = new StringBuffer("package com.ljsd.jieling.config;\n" +
|
||||
"\n" +
|
||||
"import com.ljsd.jieling.logic.STableManager;\n" +
|
||||
"import com.ljsd.jieling.logic.Table;\n" +
|
||||
"\n" +
|
||||
"import java.util.Map;\n" +
|
||||
"\n" +
|
||||
"@Table(name =\"").append(fileName).append("\")\r\n");
|
||||
stringBuffer.append("public class S").append(fileName).append(" implements BaseConfig {\n\n");
|
||||
StringBuffer getInfos = new StringBuffer();
|
||||
if(file.exists()){
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
||||
String firstLine = bufferedReader.readLine();
|
||||
String secondLine = bufferedReader.readLine();
|
||||
String[] s = firstLine.split("\t");
|
||||
String[] s1 = secondLine.split("\t");
|
||||
|
||||
for(int i=0;i<s.length;i++){
|
||||
String fieldType = typeInfo(s1[i]);
|
||||
String fieldName = s[i];
|
||||
String firstChart = fieldName.substring(0, 1).toLowerCase();
|
||||
StringBuffer finalFieldName = new StringBuffer().append(firstChart).append(fieldName.substring(1));
|
||||
getInfos.append("\tpublic ").append(fieldType).append(" ").append("get").append(fieldName).append("() {\n" +
|
||||
" return " ).append(finalFieldName).append(";\r\n").append(
|
||||
" }\r\n\n");
|
||||
stringBuffer.append("\tprivate ").append(fieldType).append(" ").append(finalFieldName).append(";").
|
||||
append("\r\n\n");
|
||||
}
|
||||
System.out.println(firstLine);
|
||||
System.out.println(secondLine);
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
getInfos.append("\r\n}");
|
||||
stringBuffer.append(" \n\t@Override\n" +
|
||||
" public void init() throws Exception {\n" +
|
||||
" \n" +
|
||||
" }\n\n\n");
|
||||
File targetJavaFile = new File(javaFilePath + "S" + fileName + ".java");
|
||||
try(PrintWriter printWriter = new PrintWriter(new FileOutputStream(targetJavaFile));) {
|
||||
printWriter.print(stringBuffer);
|
||||
printWriter.print(getInfos);
|
||||
printWriter.flush();
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(stringBuffer);
|
||||
System.out.println(getInfos);
|
||||
}
|
||||
|
||||
public static void readExcelData() throws IOException {
|
||||
File file = new File(excelPath);
|
||||
if (file.exists()) {
|
||||
|
@ -40,6 +119,31 @@ public class ExcelUtils {
|
|||
}
|
||||
}
|
||||
|
||||
private static String typeInfo(String fieldInfo){
|
||||
//mut,int#int,2
|
||||
if(fieldInfo.contains("mut")){
|
||||
String[] split = fieldInfo.split("#");
|
||||
String[] typeInfos = split[1].split(",");
|
||||
int nums = Integer.parseInt(typeInfos[1]);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if("string".equals(typeInfos[0])){
|
||||
sb.append("String");
|
||||
}else{
|
||||
sb.append(typeInfos[0]);
|
||||
}
|
||||
|
||||
|
||||
for(int i=0;i<nums;i++){
|
||||
sb.append("[]");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
if("string".equals(fieldInfo)){
|
||||
return "String";
|
||||
}
|
||||
return fieldInfo;
|
||||
}
|
||||
|
||||
private static void buildDataInfo(Workbook wb) throws IOException {
|
||||
Sheet sheet;
|
||||
Row row;
|
||||
|
@ -63,7 +167,7 @@ public class ExcelUtils {
|
|||
// }
|
||||
if (row != null) {
|
||||
StringBuilder info = new StringBuilder();
|
||||
int colnum = row2.getLastCellNum();
|
||||
int colnum = row1.getLastCellNum();
|
||||
for (int j = 1; j < colnum; j++) {
|
||||
int cellFormatValue = (int) getCellFormatValue(row1.getCell(j));
|
||||
if (cellFormatValue == 3){
|
||||
|
@ -72,21 +176,7 @@ public class ExcelUtils {
|
|||
Cell cell = row.getCell(j);
|
||||
if (cell == null){
|
||||
Cell cell1 = row4.getCell(j);
|
||||
if (cell1==null){
|
||||
String in = getIn(row2.getCell(j).toString());
|
||||
if (info.length() == 0){
|
||||
info = info.append(in);
|
||||
}else{
|
||||
info.append("\t").append(in);
|
||||
}
|
||||
}else{
|
||||
cellData = getCellFormatValue(cell1);
|
||||
if (info.length() == 0){
|
||||
info = info.append(cellData);
|
||||
}else{
|
||||
info.append("\t").append(cellData);
|
||||
}
|
||||
}
|
||||
info = getStringBuilder(row2, info, j, cell1);
|
||||
}else{
|
||||
if (getCellFormatValue(row1.getCell(j)).toString().isEmpty()){
|
||||
continue;
|
||||
|
@ -111,6 +201,26 @@ public class ExcelUtils {
|
|||
out.close();
|
||||
}
|
||||
|
||||
private static StringBuilder getStringBuilder(Row row2, StringBuilder info, int j, Cell cell1) {
|
||||
Object cellData;
|
||||
if (cell1==null){
|
||||
String in = getIn(row2.getCell(j).toString());
|
||||
if (info.length() == 0){
|
||||
info = info.append(in);
|
||||
}else{
|
||||
info.append("\t").append(in);
|
||||
}
|
||||
}else{
|
||||
cellData = getCellFormatValue(cell1);
|
||||
if (info.length() == 0){
|
||||
info = info.append(cellData);
|
||||
}else{
|
||||
info.append("\t").append(cellData);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private static String getIn(String row2) {
|
||||
String str = "";
|
||||
switch (row2) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package network.client;
|
|||
import com.google.protobuf.*;
|
||||
import com.ljsd.jieling.netty.cocdex.Tea;
|
||||
import com.ljsd.jieling.protocols.GMCommandProto;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
|
@ -36,15 +37,19 @@ public class NettyClient {
|
|||
NettyTCPClientHandler handler = ch.pipeline().get(NettyTCPClientHandler.class);
|
||||
//------------------------------------------测试类型-------------------------------------------------------
|
||||
// GameProto.GameMessage gameMessage = new NettyClient().sendLoginMessageTest();//登陆请求
|
||||
PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest gameMessage = new NettyClient().sendRegisterMessageTest();//注册请求
|
||||
PlayerInfoProto.GetPlayerInfoRequest gameMessage = new NettyClient().sendRegisterMessageTest();//注册请求
|
||||
LOGGER.info(gameMessage.toString());
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
handler.sendRequest_jieling(makeFinalMessage(gameMessage, MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE));
|
||||
handler.sendRequest_jieling(makeFinalMessage(gmRequest(), MessageTypeProto.MessageType.GM_COMMAND_VALUE));
|
||||
handler.sendRequest_jieling(makeFinalMessage(getHero(), MessageTypeProto.MessageType.GET_HEROINFO_REQUEST_VALUE));
|
||||
|
||||
}
|
||||
|
||||
public static HeroInfoProto.GetHeroListInfoRequest getHero(){
|
||||
return HeroInfoProto.GetHeroListInfoRequest.newBuilder().setNum(1).setStr("111").build();
|
||||
}
|
||||
|
||||
private static byte[] makeFinalMessage(MessageLite request, int msgNum) {
|
||||
byte[] messageData = request.toByteArray();
|
||||
byte[] packetData = new byte[messageData.length + 16];
|
||||
|
@ -64,9 +69,9 @@ public class NettyClient {
|
|||
}
|
||||
|
||||
|
||||
private PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest sendRegisterMessageTest(){
|
||||
private PlayerInfoProto.GetPlayerInfoRequest sendRegisterMessageTest(){
|
||||
LOGGER.info("register");
|
||||
PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest registerRequest = PlayerInfoProto.PlayerInfo.GetPlayerInfoRequest
|
||||
PlayerInfoProto.GetPlayerInfoRequest registerRequest = PlayerInfoProto.GetPlayerInfoRequest
|
||||
.newBuilder()
|
||||
// .setNum(888)
|
||||
// .setStr("666")
|
||||
|
|
|
@ -3,6 +3,9 @@ package network.client;
|
|||
import com.google.protobuf.MessageLite;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.netty.cocdex.Tea;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
@ -16,6 +19,8 @@ import java.util.concurrent.BlockingDeque;
|
|||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static com.ljsd.jieling.protocols.MessageTypeProto.MessageType.GET_HEROINFO_RESPONSE_VALUE;
|
||||
|
||||
/**
|
||||
* Created by justin on 14-8-12.
|
||||
*/
|
||||
|
@ -105,9 +110,15 @@ public class NettyTCPClientHandler extends SimpleChannelInboundHandler<Object> {
|
|||
int userId = packetNetData.getUserId();
|
||||
int token = packetNetData.getToken();
|
||||
int msgId = packetNetData.getMsgId();
|
||||
byte[] packetData = packetNetData.getPacketData();
|
||||
|
||||
byte[] packetData = packetNetData.parseServerProtoNetData();
|
||||
|
||||
if(msgId == GET_HEROINFO_RESPONSE_VALUE){
|
||||
HeroInfoProto.GetHeroListInfoResponse getHeroInfoResponse = HeroInfoProto.GetHeroListInfoResponse.parseFrom(packetData);
|
||||
// int heroListCount = getHeroInfoResponse.getHeroListCount();
|
||||
//int heroListCount = getHeroInfoResponse.getHeroListCount();
|
||||
// System.out.println("--->>>>" + heroListCount);
|
||||
}
|
||||
|
||||
System.out.println("back hartbeat id : "+msgId);
|
||||
|
||||
|
|
Loading…
Reference in New Issue