英雄皮肤添加
parent
4b53c7e5d0
commit
aa94e3bc5b
|
@ -15,6 +15,7 @@ import com.ljsd.jieling.util.MessageUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -44,7 +45,19 @@ public class GetAllHerosHandler extends BaseHandler{
|
|||
User user = UserManager.getUser(userId);
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
Map<String, Hero> heroMap = heroManager.getHeroMap();
|
||||
int nowTime = TimeUtils.nowInt();
|
||||
for(Hero hero : heroMap.values()){
|
||||
//检测皮肤
|
||||
if(hero.getSkin()!=0){
|
||||
if(!heroManager.getSkinInfo().containsKey(hero.getSkin())){
|
||||
hero.setSkin(0);
|
||||
}else{
|
||||
int skin= heroManager.getSkinInfo().get(hero.getSkin());
|
||||
if(skin!=-1&&skin<nowTime){
|
||||
hero.setSkin(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
heroList.add(CBean2Proto.getHero(hero));
|
||||
}
|
||||
boolean isSendFinish = false;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.hero;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/10/31
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class ChangeHeroSkinHandler extends BaseHandler<HeroInfoProto.ChangeSkinRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.HERO_SKIN_CHANGE_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, HeroInfoProto.ChangeSkinRequest proto) throws Exception {
|
||||
HeroLogic.getInstance().changeSkin(iSession,proto.getHeroId(),proto.getSkinId(), MessageTypeProto.MessageType.HERO_SKIN_CHANGE_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.hero;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/10/31
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class GetAllSkinHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.HERO_SKIN_GET_ALL_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
HeroLogic.getInstance().getAllSkin(iSession,MessageTypeProto.MessageType.HERO_SKIN_GET_ALL_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -117,4 +117,13 @@ public class HeroManager extends MongoBase {
|
|||
this.mustRandomCount = mustRandomCount;
|
||||
updateString("mustRandomCount",mustRandomCount);
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getSkinInfo() {
|
||||
return skinInfo;
|
||||
}
|
||||
public void addSkin(int skinId,int time){
|
||||
skinInfo.put(skinId,time);
|
||||
updateString("skinInfo."+skinId,time);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3224,6 +3224,47 @@ public class HeroLogic{
|
|||
|
||||
Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(session.getUid()));
|
||||
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有皮肤信息
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public void getAllSkin(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
Map<Integer, Integer> skinInfo = user.getHeroManager().getSkinInfo();
|
||||
HeroInfoProto.GetAllSkinResponse.Builder response = HeroInfoProto.GetAllSkinResponse.newBuilder();
|
||||
if(!skinInfo.isEmpty()){
|
||||
skinInfo.forEach((k,v)->response.addSkinInfo(CommonProto.SkinInfo.newBuilder().setSkinId(k).setOverTime(v).build()));
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更换皮肤
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public void changeSkin(ISession session,String heroId,int skinId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
Map<Integer, Integer> skinInfo = user.getHeroManager().getSkinInfo();
|
||||
if(!skinInfo.containsKey(skinId)||(skinInfo.get(skinId)!=-1&&skinInfo.get(skinId)<TimeUtils.nowInt())){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
Hero hero = user.getHeroManager().getHero(heroId);
|
||||
if(hero==null||hero.getSkin()==skinId){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
SHeroSkin sHeroSkin = SHeroSkin.skinMapByType.get(skinId);
|
||||
if(sHeroSkin==null||sHeroSkin.getHeroId()!=hero.getTemplateId()){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
|
||||
hero.setSkin(skinId);
|
||||
|
||||
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.ljsd.jieling.exception.ErrorCode;
|
|||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.globals.GlobalItemType;
|
||||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.ktbeans.ReportEventEnum;
|
||||
import com.ljsd.jieling.ktbeans.ReportUtil;
|
||||
|
@ -30,6 +31,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import util.MathUtils;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -140,6 +142,15 @@ public class ItemLogic {
|
|||
if (itemList.size() == 0 ){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if(itemList.size()==1){
|
||||
CommonProto.Item item = itemList.iterator().next();
|
||||
//如果是使用皮肤
|
||||
if(SItem.getsItemMap().get(item.getItemId()).getItemType()== GlobalItemType.DECORATION){
|
||||
useHeroSkin(iSession,user,item);
|
||||
MessageUtil.sendMessage(iSession, 1,msgId, PlayerInfoProto.UseAndPriceItemResponse.newBuilder().build(), true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int openBoxLimits = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getOpenBoxLimits();
|
||||
for (CommonProto.Item item :itemList){
|
||||
SItem sItem = SItem.getsItemMap().get(item.getItemId());
|
||||
|
@ -176,6 +187,30 @@ public class ItemLogic {
|
|||
sendUseAndPriceItemMessage(iSession, msgId, drop);
|
||||
}
|
||||
|
||||
private void useHeroSkin(ISession session,User user,CommonProto.Item item) throws ErrorCodeException {
|
||||
Map<Integer, Integer> skinInfo = user.getHeroManager().getSkinInfo();
|
||||
SHeroSkin sHeroSkin = STableManager.getConfig(SHeroSkin.class).get(item.getItemId());
|
||||
if(sHeroSkin==null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if(skinInfo.containsKey(item.getItemId())){
|
||||
if(skinInfo.get(item.getItemId())==-1||skinInfo.get(item.getItemId())> TimeUtils.nowInt()){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
}
|
||||
int time;
|
||||
if(sHeroSkin.getTime()==0){
|
||||
time = -1;
|
||||
}else{
|
||||
time = sHeroSkin.getTime()+TimeUtils.nowInt();
|
||||
}
|
||||
user.getHeroManager().addSkin(sHeroSkin.getType(),time);
|
||||
HeroInfoProto.GetSkinIndication indication = HeroInfoProto.GetSkinIndication.newBuilder()
|
||||
.setSkinInfo(CommonProto.SkinInfo.newBuilder().setSkinId(sHeroSkin.getType()).setOverTime(time))
|
||||
.build();
|
||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.HERO_SKIN_USE_INDICATION_VALUE,indication,true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用选择宝箱道具
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="HeroSkin")
|
||||
public class SHeroSkin implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int type;
|
||||
|
||||
private int heroId;
|
||||
|
||||
private String readingName;
|
||||
|
||||
private int[][] unlockProperty;
|
||||
|
||||
private int[][] monomerProperty;
|
||||
|
||||
private int time;
|
||||
|
||||
private int isDefault;
|
||||
|
||||
private int order;
|
||||
|
||||
private int[] price;
|
||||
|
||||
|
||||
public static Map<Integer,SHeroSkin> skinMapByType;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
Map<Integer, SHeroSkin> config = STableManager.getConfig(SHeroSkin.class);
|
||||
|
||||
Map<Integer,SHeroSkin> skinMapByTypeTemp = new HashMap<>();
|
||||
|
||||
for(Map.Entry<Integer,SHeroSkin> entry:config.entrySet()){
|
||||
|
||||
skinMapByTypeTemp.put(entry.getValue().getType(),entry.getValue());
|
||||
|
||||
}
|
||||
skinMapByType =skinMapByTypeTemp;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getHeroId() {
|
||||
return heroId;
|
||||
}
|
||||
|
||||
public String getReadingName() {
|
||||
return readingName;
|
||||
}
|
||||
|
||||
public int[][] getUnlockProperty() {
|
||||
return unlockProperty;
|
||||
}
|
||||
|
||||
public int[][] getMonomerProperty() {
|
||||
return monomerProperty;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
public int getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public int[] getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue