fix
parent
c3dc08c1b3
commit
771ce8de89
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.globals;
|
||||
|
||||
public interface GlobalGm {
|
||||
int ADD_ITEM = 0;//添加道具
|
||||
int ADD_CARD = 1; //添加卡牌
|
||||
int ADD_GEM = 0; // 添加钻石
|
||||
int ADD_ITEM = 1;//添加道具
|
||||
int ADD_CARD = 2; //添加卡牌
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ public interface GlobalItemType {
|
|||
int SUCCESSIVELY_RANDOM = 2; // 依次随机
|
||||
|
||||
// 物品类型
|
||||
int GEM = 1; // 钻石Id(充值获得)
|
||||
int GEM = 3; // 钻石Id(充值获得)
|
||||
int ITEM = 10; //道具
|
||||
int CARD = 11; // 卡牌
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.ljsd.jieling.protocols.CommonProto;
|
|||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -34,11 +35,20 @@ public class GMRequestHandler extends BaseHandler{
|
|||
return;
|
||||
}
|
||||
String[] commandArray = command.split("#");
|
||||
int uid = Integer.parseInt(commandArray[0]);
|
||||
int gmCommandType = Integer.parseInt(commandArray[1]);// type 0:添加道具 1:卡牌
|
||||
int uid = iSession.getUid();
|
||||
int gmCommandType = Integer.parseInt(commandArray[0]);// type 0:钻石(type#数量) 1:道具 2: 卡牌
|
||||
int prarm1 = 0, prarm2 = 0;
|
||||
if (gmCommandType == 0){
|
||||
prarm1 = Integer.parseInt(commandArray[1]);
|
||||
}else if (gmCommandType == 1 || gmCommandType ==2){
|
||||
prarm1 = Integer.parseInt(commandArray[1]);
|
||||
prarm2 = Integer.parseInt(commandArray[2]);
|
||||
}
|
||||
User cUser = UserManager.getUser(uid);
|
||||
switch (gmCommandType){
|
||||
case GlobalGm.ADD_GEM:
|
||||
cUser.getPlayerInfoManager().setGem(prarm1+cUser.getPlayerInfoManager().getGem());
|
||||
break;
|
||||
case GlobalGm.ADD_ITEM:
|
||||
giveItem(cUser,prarm1,prarm2);
|
||||
break;
|
||||
|
|
|
@ -33,13 +33,18 @@ public class GetAllItemHandler extends BaseHandler {
|
|||
int msgIndex = netData.getIndex();
|
||||
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());
|
||||
|
||||
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={}",
|
||||
userId, token,msgId,msgIndex);
|
||||
int index = getItemInfoRequest.getIndex();
|
||||
boolean isSendFinish = true;
|
||||
User user = UserManager.getUserForLogin(userId);
|
||||
List<CommonProto.Item> itemList = ItemUtil.getAllItem(user);
|
||||
List<CommonProto.Item> allItemList = ItemUtil.getAllItem(user,index);
|
||||
if (allItemList.size() > 200){
|
||||
isSendFinish = false;
|
||||
}
|
||||
PlayerInfoProto.GetItemInfoResponse getItemInfoResponse = PlayerInfoProto.GetItemInfoResponse.newBuilder()
|
||||
.addAllItemlist(itemList)
|
||||
.addAllItemlist(allItemList)
|
||||
.setIsSendFinish(isSendFinish)
|
||||
.build();
|
||||
try {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_ITEMINFO_RESPONSE_VALUE, getItemInfoResponse, true);
|
||||
|
|
|
@ -266,11 +266,11 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
|
||||
}
|
||||
|
||||
if (OnlineUserManager.checkUidOnline(session.getUid())){
|
||||
ISession iSession = OnlineUserManager.getSessionByUid(session.getUid());
|
||||
MessageUtil.sendErrorCode(session, ErrorCode.reloginCode);
|
||||
iSession.close();
|
||||
}
|
||||
// if (OnlineUserManager.checkUidOnline(session.getUid())){
|
||||
// ISession iSession = OnlineUserManager.getSessionByUid(session.getUid());
|
||||
// MessageUtil.sendErrorCode(session, ErrorCode.reloginCode);
|
||||
// iSession.close();
|
||||
// }
|
||||
|
||||
// if (myToken != packetNetData.getToken()){
|
||||
// return 1;
|
||||
|
|
|
@ -19,9 +19,6 @@ public class CBean2Proto {
|
|||
.setVipLevel(playerManager.getVipLevel())
|
||||
.setFamilyId(playerManager.getFamilyId())
|
||||
.setHead(playerManager.getHead())
|
||||
.setGold(playerManager.getGold())
|
||||
.setGem(playerManager.getGem())
|
||||
.setChargeGem(playerManager.getChargeGem())
|
||||
.build();
|
||||
return player;
|
||||
}
|
||||
|
|
|
@ -9,10 +9,7 @@ import com.ljsd.jieling.protocols.CommonProto;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class ItemUtil {
|
||||
|
@ -132,10 +129,10 @@ public class ItemUtil {
|
|||
List<CommonProto.Item> itemProtoList = new CopyOnWriteArrayList<>();
|
||||
ItemManager itemManager = user.getItemManager();
|
||||
for (Map.Entry<Integer, Integer> entry : itemMap.entrySet()) {
|
||||
SItem sItem = SItem.getsItemMap().get(entry.getKey());
|
||||
if (sItem == null){
|
||||
continue;
|
||||
}
|
||||
SItem sItem = SItem.getsItemMap().get (entry.getKey());
|
||||
// if (sItem == null){
|
||||
// continue;
|
||||
// }
|
||||
Item item = itemManager.getItem(entry.getKey());
|
||||
if (item == null){
|
||||
item = itemManager.newItem(entry.getKey(), entry.getValue());
|
||||
|
@ -173,7 +170,7 @@ public class ItemUtil {
|
|||
}
|
||||
|
||||
|
||||
public static List<CommonProto.Item > getAllItem(User user){
|
||||
public static List<CommonProto.Item > getAllItem(User user,int index){
|
||||
List<CommonProto.Item > itemList = new ArrayList<>();
|
||||
ItemManager itemManager = user.getItemManager();
|
||||
Map<Integer, Item> itemMap = itemManager.getItemMap();
|
||||
|
@ -182,9 +179,32 @@ public class ItemUtil {
|
|||
itemList.add(CBean2Proto.getItem(entry.getValue()));
|
||||
}
|
||||
}
|
||||
listByPage(itemList,index);
|
||||
return itemList;
|
||||
}
|
||||
|
||||
private static void listByPage(List<CommonProto.Item> itemList,int pagesize) {
|
||||
int totalcount=itemList.size();
|
||||
int pagecount=0;
|
||||
int m=totalcount%pagesize;
|
||||
if (m>0){
|
||||
pagecount=totalcount/pagesize+1;
|
||||
}else{
|
||||
pagecount=totalcount/pagesize;
|
||||
}
|
||||
for(int i=1;i<=pagecount;i++){
|
||||
if (m==0){
|
||||
itemList = itemList.subList((i-1)*pagesize,pagesize*(i));
|
||||
}else{
|
||||
if (i==pagecount){
|
||||
itemList= itemList.subList((i-1)*pagesize,totalcount);
|
||||
}else{
|
||||
itemList= itemList.subList((i-1)*pagesize,pagesize*(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void addCard(User user,Map<Integer,Integer> cardMap,CommonProto.Drop.Builder dropBuilder) throws Exception {
|
||||
List<CommonProto.Hero> heroList = new CopyOnWriteArrayList<>();
|
||||
|
@ -278,5 +298,4 @@ public class ItemUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class NettyClient {
|
|||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(NettyClient.class);
|
||||
|
||||
private static int uid = 10000009;
|
||||
private static int uid = 10000018;
|
||||
private static int msgIndex = 1;
|
||||
private static int token=543242;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class NettyClient {
|
|||
.channel(NioSocketChannel.class)
|
||||
.handler(new NettyTCPClientInitializer());
|
||||
|
||||
Channel ch = b.connect("127.0.0.1",18090).sync().channel();
|
||||
Channel ch = b.connect("127.0.0.1",16080).sync().channel();
|
||||
|
||||
NettyTCPClientHandler handler = ch.pipeline().get(NettyTCPClientHandler.class);
|
||||
//------------------------------------------测试类型-------------------------------------------------------
|
||||
|
@ -42,9 +42,11 @@ public class NettyClient {
|
|||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
handler.sendRequest_jieling(makeFinalMessage(gameMessage, MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE));
|
||||
handler.sendRequest_jieling(makeFinalMessage(getHero(), MessageTypeProto.MessageType.GET_HEROINFO_REQUEST_VALUE));
|
||||
handler.sendRequest_jieling(makeFinalMessage(getRandomHero(), MessageTypeProto.MessageType.HERO_RAND_REQQUEST_VALUE));
|
||||
handler.sendRequest_jieling(makeFinalMessage(gmRequest(), MessageTypeProto.MessageType.GM_REQUEST_VALUE));
|
||||
// handler.sendRequest_jieling(makeFinalMessage(getHero(), MessageTypeProto.MessageType.GET_HEROINFO_REQUEST_VALUE));
|
||||
// handler.sendRequest_jieling(makeFinalMessage(getRandomHero(), MessageTypeProto.MessageType.HERO_RAND_REQQUEST_VALUE));
|
||||
for (int i = 800; i< 900;i++){
|
||||
handler.sendRequest_jieling(makeFinalMessage(gmRequest(i), MessageTypeProto.MessageType.GM_REQUEST_VALUE));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -70,8 +72,8 @@ public class NettyClient {
|
|||
return finalData;
|
||||
}
|
||||
|
||||
public static CommonProto.GMCommand gmRequest(){
|
||||
return CommonProto.GMCommand.newBuilder().setCommand("10000001#0#1#100").build();
|
||||
public static CommonProto.GMCommand gmRequest(int itemId){
|
||||
return CommonProto.GMCommand.newBuilder().setCommand("1#"+itemId+"#10000").build();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue