From 4b324dbd2b16f922cfd4b3f02feb0a816af48c57 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Tue, 19 Feb 2019 20:46:06 +0800 Subject: [PATCH] equip --- conf/server/EquipConfig.txt | 130 +++++++++--------- .../ljsd/jieling/config/SPropertyConfig.java | 2 +- .../handler/EquipUnLoadOptHandler.java | 7 +- .../java/com/ljsd/jieling/logic/dao/Hero.java | 10 +- .../ljsd/jieling/logic/hero/HeroLogic.java | 40 +++--- .../com/ljsd/jieling/util/CBean2Proto.java | 8 +- 6 files changed, 108 insertions(+), 89 deletions(-) diff --git a/conf/server/EquipConfig.txt b/conf/server/EquipConfig.txt index bb82dee06..d9d8ddd84 100644 --- a/conf/server/EquipConfig.txt +++ b/conf/server/EquipConfig.txt @@ -1,15 +1,15 @@ Id Quality ProfessionLimit Position PropertyMin PropertyMax Pool SecondNumMin SecondNumMax SkillId IfClear int int int int mut,int#int,1 mut,int#int,1 int int int int int -3001 1 1501 1 2#42 2#70 1 0 0 0 0 -3002 1 1501 1 2#42 2#70 1 0 0 0 0 -3003 1 1502 1 2#42 2#70 1 0 0 0 0 -3004 1 1502 1 2#42 2#70 1 0 0 0 0 -3005 1 1503 1 2#42 2#70 1 0 0 0 0 -3006 1 1503 1 2#42 2#70 1 0 0 0 0 -3007 1 1504 1 2#42 2#70 1 0 0 0 0 -3008 1 1504 1 2#42 2#70 1 0 0 0 0 -3009 1 1505 1 2#42 2#70 1 0 0 0 0 -3010 1 1505 1 2#42 2#70 1 0 0 0 0 +3001 1 3 1 2#42 2#70 1 0 0 0 0 +3002 1 3 1 2#42 2#70 1 0 0 0 0 +3003 1 5 1 2#42 2#70 1 0 0 0 0 +3004 1 5 1 2#42 2#70 1 0 0 0 0 +3005 1 1 1 2#42 2#70 1 0 0 0 0 +3006 1 1 1 2#42 2#70 1 0 0 0 0 +3007 1 2 1 2#42 2#70 1 0 0 0 0 +3008 1 2 1 2#42 2#70 1 0 0 0 0 +3009 1 4 1 2#42 2#70 1 0 0 0 0 +3010 1 4 1 2#42 2#70 1 0 0 0 0 3011 1 0 2 3#43 3#72 1 0 0 0 0 3012 1 0 2 3#43 3#72 1 0 0 0 0 3013 1 0 2 4#40 4#67 1 0 0 0 0 @@ -18,16 +18,16 @@ int int int int mut,int#int,1 mut,int#int,1 int int int int int 3016 1 0 4 5#24 5#28 1 0 0 0 0 3017 1 0 3 1#460 1#767 1 0 0 0 0 3018 1 0 3 1#460 1#767 1 0 0 0 0 -3101 2 1501 1 2#56 2#93 1 0 1 0 0 -3102 2 1501 1 2#56 2#93 1 0 1 0 0 -3103 2 1502 1 2#56 2#93 1 0 1 0 0 -3104 2 1502 1 2#56 2#93 1 0 1 0 0 -3105 2 1503 1 2#56 2#93 1 0 1 0 0 -3106 2 1503 1 2#56 2#93 1 0 1 0 0 -3107 2 1504 1 2#56 2#93 1 0 1 0 0 -3108 2 1504 1 2#56 2#93 1 0 1 0 0 -3109 2 1505 1 2#56 2#93 1 0 1 0 0 -3110 2 1505 1 2#56 2#93 1 0 1 0 0 +3101 2 3 1 2#56 2#93 1 0 1 0 0 +3102 2 3 1 2#56 2#93 1 0 1 0 0 +3103 2 5 1 2#56 2#93 1 0 1 0 0 +3104 2 5 1 2#56 2#93 1 0 1 0 0 +3105 2 1 1 2#56 2#93 1 0 1 0 0 +3106 2 1 1 2#56 2#93 1 0 1 0 0 +3107 2 2 1 2#56 2#93 1 0 1 0 0 +3108 2 2 1 2#56 2#93 1 0 1 0 0 +3109 2 4 1 2#56 2#93 1 0 1 0 0 +3110 2 4 1 2#56 2#93 1 0 1 0 0 3111 2 0 2 3#58 3#96 2 0 1 0 0 3112 2 0 2 3#58 3#96 2 0 1 0 0 3113 2 0 2 4#54 4#90 2 0 1 0 0 @@ -36,16 +36,16 @@ int int int int mut,int#int,1 mut,int#int,1 int int int int int 3116 2 0 4 5#48 5#56 3 0 1 0 0 3117 2 0 3 1#616 1#1027 4 0 1 0 0 3118 2 0 3 1#616 1#1027 4 0 1 0 0 -3201 3 1501 1 2#72 2#120 5 1 3 0 1 -3202 3 1501 1 2#72 2#120 5 1 3 0 1 -3203 3 1502 1 2#72 2#120 5 1 3 0 1 -3204 3 1502 1 2#72 2#120 5 1 3 0 1 -3205 3 1503 1 2#72 2#120 5 1 3 0 1 -3206 3 1503 1 2#72 2#120 5 1 3 0 1 -3207 3 1504 1 2#72 2#120 5 1 3 0 1 -3208 3 1504 1 2#72 2#120 5 1 3 0 1 -3209 3 1505 1 2#72 2#120 5 1 3 0 1 -3210 3 1505 1 2#72 2#120 5 1 3 0 1 +3201 3 3 1 2#72 2#120 5 1 3 0 1 +3202 3 3 1 2#72 2#120 5 1 3 0 1 +3203 3 5 1 2#72 2#120 5 1 3 0 1 +3204 3 5 1 2#72 2#120 5 1 3 0 1 +3205 3 1 1 2#72 2#120 5 1 3 0 1 +3206 3 1 1 2#72 2#120 5 1 3 0 1 +3207 3 2 1 2#72 2#120 5 1 3 0 1 +3208 3 2 1 2#72 2#120 5 1 3 0 1 +3209 3 4 1 2#72 2#120 5 1 3 0 1 +3210 3 4 1 2#72 2#120 5 1 3 0 1 3211 3 0 2 3#74 3#124 6 1 3 0 1 3212 3 0 2 3#74 3#124 6 1 3 0 1 3213 3 0 2 4#70 4#116 6 1 3 0 1 @@ -54,16 +54,16 @@ int int int int mut,int#int,1 mut,int#int,1 int int int int int 3216 3 0 4 5#72 5#84 7 1 3 0 1 3217 3 0 3 1#792 1#1320 8 1 3 0 1 3218 3 0 3 1#792 1#1320 8 1 3 0 1 -3301 4 1501 1 2#383 2#638 9 2 4 0 1 -3302 4 1501 1 2#383 2#638 9 2 4 0 1 -3303 4 1502 1 2#383 2#638 9 2 4 0 1 -3304 4 1502 1 2#383 2#638 9 2 4 0 1 -3305 4 1503 1 2#383 2#638 9 2 4 0 1 -3306 4 1503 1 2#383 2#638 9 2 4 0 1 -3307 4 1504 1 2#383 2#638 9 2 4 0 1 -3308 4 1504 1 2#383 2#638 9 2 4 0 1 -3309 4 1505 1 2#383 2#638 9 2 4 0 1 -3310 4 1505 1 2#383 2#638 9 2 4 0 1 +3301 4 3 1 2#383 2#638 9 2 4 0 1 +3302 4 3 1 2#383 2#638 9 2 4 0 1 +3303 4 5 1 2#383 2#638 9 2 4 0 1 +3304 4 5 1 2#383 2#638 9 2 4 0 1 +3305 4 1 1 2#383 2#638 9 2 4 0 1 +3306 4 1 1 2#383 2#638 9 2 4 0 1 +3307 4 2 1 2#383 2#638 9 2 4 0 1 +3308 4 2 1 2#383 2#638 9 2 4 0 1 +3309 4 4 1 2#383 2#638 9 2 4 0 1 +3310 4 4 1 2#383 2#638 9 2 4 0 1 3311 4 0 2 3#396 3#659 10 2 4 0 1 3312 4 0 2 3#396 3#659 10 2 4 0 1 3313 4 0 2 4#370 4#617 10 2 4 0 1 @@ -72,16 +72,16 @@ int int int int mut,int#int,1 mut,int#int,1 int int int int int 3316 4 0 4 5#96 5#113 11 2 4 0 1 3317 4 0 3 1#4212 1#7020 12 2 4 0 1 3318 4 0 3 1#4212 1#7020 12 2 4 0 1 -3319 4 1501 1 2#383 2#638 9 2 4 0 1 -3320 4 1501 1 2#383 2#638 9 2 4 0 1 -3321 4 1502 1 2#383 2#638 9 2 4 0 1 -3322 4 1502 1 2#383 2#638 9 2 4 0 1 -3323 4 1503 1 2#383 2#638 9 2 4 0 1 -3324 4 1503 1 2#383 2#638 9 2 4 0 1 -3325 4 1504 1 2#383 2#638 9 2 4 0 1 -3326 4 1504 1 2#383 2#638 9 2 4 0 1 -3327 4 1505 1 2#383 2#638 9 2 4 0 1 -3328 4 1505 1 2#383 2#638 9 2 4 0 1 +3319 4 3 1 2#383 2#638 9 2 4 0 1 +3320 4 3 1 2#383 2#638 9 2 4 0 1 +3321 4 5 1 2#383 2#638 9 2 4 0 1 +3322 4 5 1 2#383 2#638 9 2 4 0 1 +3323 4 1 1 2#383 2#638 9 2 4 0 1 +3324 4 1 1 2#383 2#638 9 2 4 0 1 +3325 4 2 1 2#383 2#638 9 2 4 0 1 +3326 4 2 1 2#383 2#638 9 2 4 0 1 +3327 4 4 1 2#383 2#638 9 2 4 0 1 +3328 4 4 1 2#383 2#638 9 2 4 0 1 3329 4 0 2 3#396 3#659 10 2 4 0 1 3330 4 0 2 3#396 3#659 10 2 4 0 1 3331 4 0 2 4#370 4#617 10 2 4 0 1 @@ -90,25 +90,25 @@ int int int int mut,int#int,1 mut,int#int,1 int int int int int 3334 4 0 4 5#96 5#113 11 2 4 0 1 3335 4 0 3 1#4212 1#7020 12 2 4 0 1 3336 4 0 3 1#4212 1#7020 12 2 4 0 1 -4001 3 1501 1 2#72 2#120 5 1 3 0 0 -4002 3 1502 1 2#72 2#120 5 1 3 0 0 -4003 3 1503 1 2#72 2#120 5 1 3 0 0 -4004 3 1504 1 2#72 2#120 5 1 3 0 0 -4005 3 1505 1 2#72 2#120 5 1 3 0 0 +4001 3 3 1 2#72 2#120 5 1 3 0 0 +4002 3 5 1 2#72 2#120 5 1 3 0 0 +4003 3 1 1 2#72 2#120 5 1 3 0 0 +4004 3 2 1 2#72 2#120 5 1 3 0 0 +4005 3 4 1 2#72 2#120 5 1 3 0 0 4006 3 0 2 3#74 3#124 6 1 3 0 0 4007 3 0 2 4#70 4#116 6 1 3 0 0 4008 3 0 4 5#72 5#84 7 1 3 0 0 4009 3 0 3 1#792 1#1320 8 1 3 0 0 -4101 4 1501 1 2#383 2#638 9 2 4 0 0 -4102 4 1501 1 2#383 2#638 9 2 4 0 0 -4103 4 1502 1 2#383 2#638 9 2 4 0 0 -4104 4 1502 1 2#383 2#638 9 2 4 0 0 -4105 4 1503 1 2#383 2#638 9 2 4 0 0 -4106 4 1503 1 2#383 2#638 9 2 4 0 0 -4107 4 1504 1 2#383 2#638 9 2 4 0 0 -4108 4 1504 1 2#383 2#638 9 2 4 0 0 -4109 4 1505 1 2#383 2#638 9 2 4 0 0 -4110 4 1505 1 2#383 2#638 9 2 4 0 0 +4101 4 3 1 2#383 2#638 9 2 4 0 0 +4102 4 3 1 2#383 2#638 9 2 4 0 0 +4103 4 5 1 2#383 2#638 9 2 4 0 0 +4104 4 5 1 2#383 2#638 9 2 4 0 0 +4105 4 1 1 2#383 2#638 9 2 4 0 0 +4106 4 1 1 2#383 2#638 9 2 4 0 0 +4107 4 2 1 2#383 2#638 9 2 4 0 0 +4108 4 2 1 2#383 2#638 9 2 4 0 0 +4109 4 4 1 2#383 2#638 9 2 4 0 0 +4110 4 4 1 2#383 2#638 9 2 4 0 0 4111 4 0 2 3#396 3#659 10 2 4 0 0 4112 4 0 2 3#396 3#659 10 2 4 0 0 4113 4 0 2 4#370 4#617 10 2 4 0 0 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SPropertyConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SPropertyConfig.java index e16e298b7..22414e8e1 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SPropertyConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SPropertyConfig.java @@ -29,7 +29,7 @@ public class SPropertyConfig implements BaseConfig { int propertyId = sPropertyConfig.getPropertyId(); sPropertyConfigByPIDMapTmp.put(propertyId,sPropertyConfig); } - sPropertyConfigByPIDMapTmp = sPropertyConfigByPIDMap; + sPropertyConfigByPIDMap = sPropertyConfigByPIDMapTmp; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/EquipUnLoadOptHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/EquipUnLoadOptHandler.java index 091f1bc2f..c2d8066c8 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/EquipUnLoadOptHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/EquipUnLoadOptHandler.java @@ -7,6 +7,8 @@ import com.ljsd.jieling.protocols.HeroInfoProto; import com.ljsd.jieling.protocols.MessageTypeProto; import org.springframework.stereotype.Component; +import java.util.List; + @Component public class EquipUnLoadOptHandler extends BaseHandler { @Override @@ -17,9 +19,8 @@ public class EquipUnLoadOptHandler extends BaseHandler { @Override public void process(ISession iSession, PacketNetData netData) throws Exception { HeroInfoProto.EquipUnLoadOptRequest equipUnLoadOptRequest = HeroInfoProto.EquipUnLoadOptRequest.parseFrom(netData.parseClientProtoNetData()); - int type = equipUnLoadOptRequest.getType(); - String equipId = equipUnLoadOptRequest.getEquipId(); + List equipIdsList = equipUnLoadOptRequest.getEquipIdsList(); String heroId = equipUnLoadOptRequest.getHeroId(); - HeroLogic.getInstance().unloadEquipOpt(iSession,type,heroId,equipId); + HeroLogic.getInstance().unloadEquipOpt(iSession,heroId,equipIdsList); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Hero.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Hero.java index 4cd403873..3744753de 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Hero.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Hero.java @@ -136,17 +136,17 @@ public class Hero extends MongoBase { } public void setEquipByPositionMap(Map equipByPositionMap) throws Exception { - updateString("breakId",breakId); + updateString("equipByPositionMap",equipByPositionMap); this.equipByPositionMap = equipByPositionMap; } public void updateEquipPositionMap(int position,String equipId) throws Exception { - updateString("breakId." + position ,breakId); + updateString("equipByPositionMap." + position ,equipId); this.equipByPositionMap.put(position,equipId); } public void removeEquip(int position){ - removeString("breakId." + position); + removeString("equipByPositionMap." + position); this.equipByPositionMap.remove(position); } @@ -158,4 +158,8 @@ public class Hero extends MongoBase { updateString("breakId",breakId); this.breakId = breakId; } + + public int getCreateTime() { + return createTime; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index dc522b9bb..16a26ee1a 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -33,6 +33,7 @@ public class HeroLogic { } + public static class Instance { public final static HeroLogic instance = new HeroLogic(); } @@ -240,7 +241,7 @@ public class HeroLogic { public String checkTeamPos(User user, int teamId,List heroIds, List pokemonoIds ){ if(heroIds ==null || heroIds.isEmpty()){ - return "队伍信息错误"; + return ""; } Set cacheHeroIds = new HashSet<>(); @@ -630,9 +631,11 @@ public class HeroLogic { Hero hero = user.getHeroManager().getHero(heroId); Equip equip = user.getEquipManager().getEquipMap().get(equipId); if( null == equip || null == hero ){ + MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.EQUIP_WEAR_RESPONSE_VALUE,""); return; } if(!StringUtil.isEmpty(equip.getHeroId())){ + MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.EQUIP_WEAR_RESPONSE_VALUE,""); return; } int equipIdTid = equip.getEquipId(); @@ -641,38 +644,43 @@ public class HeroLogic { int professionLimit = sEquipConfig.getProfessionLimit(); SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); if(professionLimit!=0 && scHero.getProfession()!= professionLimit){ - MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.EQUIP_WEAR_REQUEST_VALUE,""); + MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.EQUIP_WEAR_RESPONSE_VALUE,""); return; } hero.updateEquipPositionMap(position,equipId); - LOGGER.info("the heroTid={},the force={}",calHeoForce(user,hero)); + //LOGGER.info("the heroTid={},the force={}",calHeoForce(user,hero)); //发送成功消息 - MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.EQUIP_WEAR_REQUEST_VALUE,null,true); + MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.EQUIP_WEAR_RESPONSE_VALUE,null,true); } - public void unloadEquipOpt(ISession session,int type,String heroId,String equipId) throws Exception { + public void unloadEquipOpt(ISession session,String heroId,List equipIds) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); - Equip equip = user.getEquipManager().getEquipMap().get(equipId); Hero hero = user.getHeroManager().getHero(heroId); - if( hero == null|| null == equip || !StringUtil.isEmpty(equip.getHeroId()) ){ + if( hero == null || equipIds.isEmpty()){ + MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.EQUIP_UNLOAD_OPT_RESPONSE_VALUE,""); return; } - int equipIdTid = equip.getEquipId(); - SEquipConfig sEquipConfig = SEquipConfig.getsEquipConfigById(equipIdTid); - int position = sEquipConfig.getPosition(); - - if(type == 1){ - equip.setHeroId(""); - hero.removeEquip(position); + List positions = new ArrayList<>(); + for(String equipId : equipIds){ + Equip equip = user.getEquipManager().getEquipMap().get(equipId); + if(null == equip || !StringUtil.isEmpty(equip.getHeroId())){ + MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.EQUIP_UNLOAD_OPT_RESPONSE_VALUE,""); + return; + } + int equipIdTid = equip.getEquipId(); + SEquipConfig sEquipConfig = SEquipConfig.getsEquipConfigById(equipIdTid); + int position = sEquipConfig.getPosition(); + positions.add(position); } - if(type == 2){ - hero.setEquipByPositionMap(new HashMap<>()); + + for(Integer position : positions){ + hero.removeEquip(position); } //发送成功消息 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java index 4ab755985..8713e04d0 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java @@ -37,6 +37,11 @@ public class CBean2Proto { } public static CommonProto.Hero getHero(Hero hero){ + Map equipByPositionMap = hero.getEquipByPositionMap(); + List equipList = new ArrayList<>(); + for(String equipId : equipByPositionMap.values()){ + equipList.add(equipId); + } CommonProto.Hero heroProto = CommonProto.Hero .newBuilder() .setId(hero.getId()) @@ -44,8 +49,9 @@ public class CBean2Proto { .setLevel(hero.getLevel()) .setStar(hero.getStar()) .setBreakId(hero.getBreakId()) + .setCreateTime(hero.getCreateTime()) .addAllSkillIdList(hero.getSkillList()) - // .addAllEquipIdList(getHeroEquip(hero.getEquipList())) + .addAllEquipIdList(equipList) .build(); return heroProto; }