hero
parent
ee1defd706
commit
cbd48c5097
|
|
@ -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,54 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.config.SCHero;
|
||||
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 GetAllHeroHandler extends BaseHandler {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GetAllHeroHandler.class);
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GET_HEROINFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] packetData = netData.parseClientProtoNetData();
|
||||
int uid = iSession.getUid();
|
||||
List<CommonProto.Hero> heroList = new ArrayList<>();
|
||||
// SCHero scHero = SCHero.getsCHero().get(1);
|
||||
CommonProto.Hero hero = CommonProto.Hero.newBuilder()
|
||||
.setHeroId(1)
|
||||
.setAttack(2)
|
||||
.setStar(2)
|
||||
.setHeroType(1)
|
||||
.setLevel(1)
|
||||
.setHp(1000)
|
||||
.setMDefence(2000)
|
||||
.setPDefence(3000)
|
||||
.setSpeed(4000)
|
||||
.addAllEquipList(new ArrayList<>())
|
||||
.addAllSkillList(new ArrayList<>())
|
||||
.build();
|
||||
|
||||
|
||||
heroList.add(hero);
|
||||
HeroInfoProto.GetHeroInfoResponse build = HeroInfoProto.GetHeroInfoResponse.newBuilder().addAllHeroList(heroList).build();
|
||||
//HeroInfoProto.HeroInfo.GetHeroInfoResponse build = HeroInfoProto.HeroInfo.GetHeroInfoResponse.newBuilder().setHeroList(hero).build();
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_HEROINFO_RESPONSE_VALUE, build, true);
|
||||
LOGGER.info("back to client!");
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -41,10 +42,14 @@ public class NettyClient {
|
|||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
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.GetHeroInfoRequest getHero(){
|
||||
return HeroInfoProto.GetHeroInfoRequest.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];
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ 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 io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
|
@ -16,6 +18,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 +109,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.GetHeroInfoResponse getHeroInfoResponse = HeroInfoProto.GetHeroInfoResponse.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