Merge branch 'master' of 60.1.1.230:backend/jieling_server

back_recharge
wangyuan 2019-01-22 16:31:35 +08:00
commit b87c421818
4 changed files with 27 additions and 4 deletions

View File

@ -2,4 +2,5 @@ package com.ljsd.jieling.globals;
public interface GlobalGm {
int ADD_ITEM = 0;//添加道具
int ADD_CARD = 1; //添加卡牌
}

View File

@ -9,6 +9,7 @@ import com.ljsd.jieling.network.session.ISession;
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 org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@ -34,14 +35,30 @@ public class GMRequestHandler extends BaseHandler{
}
String[] commandArray = command.split("#");
int uid = Integer.parseInt(commandArray[0]);
int gmCommandType = Integer.parseInt(commandArray[1]);// type 0添加道具
int gmCommandType = Integer.parseInt(commandArray[1]);// type 0添加道具 1:卡牌
int prarm1 = 0, prarm2 = 0;
User cUser = UserManager.getUser(uid);
switch (gmCommandType){
case GlobalGm.ADD_ITEM:
giveItem(cUser,prarm1,prarm2);
break;
case GlobalGm.ADD_CARD:
giveHero(cUser,prarm1,prarm2);
break;
}
try {
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GM_RESPONSE_VALUE, null, true);
LOGGER.info("back to client!");
} catch (Exception e) {
e.printStackTrace();
}
}
private void giveHero(User cUser, int cardId, int cardNum) throws Exception {
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
Map<Integer,Integer> cardMap = new ConcurrentHashMap<>();
cardMap.put(cardId,cardNum);
ItemUtil.addCard(cUser,cardMap,dropBuilder);
}
private void giveItem(User cUser,int itemId,int itemNum) throws Exception {

View File

@ -133,6 +133,9 @@ public class ItemUtil {
ItemManager itemManager = user.getItemManager();
for (Map.Entry<Integer, Integer> entry : itemMap.entrySet()) {
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());
@ -191,6 +194,7 @@ public class ItemUtil {
addCard(user, entry.getKey(),heroList);
}
}
dropBuilder.addAllHero(heroList);
}
public static void addCard(User user,int cardId,List<CommonProto.Hero> heroList) throws Exception {

View File

@ -2,7 +2,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.CommonProto;
import com.ljsd.jieling.protocols.HeroInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
@ -44,6 +44,7 @@ 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));
}
@ -69,8 +70,8 @@ public class NettyClient {
return finalData;
}
public static GMCommandProto.GMCommand gmRequest(){
return GMCommandProto.GMCommand.newBuilder().setCommand("10000001#0#1#100").build();
public static CommonProto.GMCommand gmRequest(){
return CommonProto.GMCommand.newBuilder().setCommand("10000001#0#1#100").build();
}