diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/GameGM/GMRequestHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/GameGM/GMRequestHandler.java index 3cd777341..c4f42b6ce 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/GameGM/GMRequestHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/GameGM/GMRequestHandler.java @@ -16,6 +16,7 @@ import com.ljsd.jieling.handler.map.*; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.fight.CombatLogic; +import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.mission.main.VipMissionIdsType; import com.ljsd.jieling.logic.player.PlayerLogic; import com.ljsd.jieling.netty.cocdex.PacketNetData; @@ -153,7 +154,8 @@ public class GMRequestHandler extends BaseHandler{ Map scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE,scHero.getStar()); Map scHeroRankUpConfigByTypeTree = new TreeMap<>(scHeroRankUpConfigByType); SCHeroRankUpConfig scHeroRankUpConfig = ((TreeMap) scHeroRankUpConfigByTypeTree).lowerEntry(hero.getStar()).getValue(); - hero.setLevel(cUser,scHeroRankUpConfig.getOpenLevel()); + cUser.getUserMissionManager().onGameEvent(cUser, GameEvent.HERO_LEVEL_UP,hero.getOriginalLevel(),scHeroRankUpConfig.getOpenLevel()); + hero.setLevel(scHeroRankUpConfig.getOpenLevel()); hero.setStarBreakId(scHeroRankUpConfig.getId()); scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.BREAK_TYPE,scHero.getStar()); @@ -359,7 +361,8 @@ public class GMRequestHandler extends BaseHandler{ } heroTmp.upStar(maxStar-heroTmp.getStar()); SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByType.get(maxStar-1); - heroTmp.setLevel(cUser,scHeroRankUpConfig.getOpenLevel()); + cUser.getUserMissionManager().onGameEvent(cUser, GameEvent.HERO_LEVEL_UP,heroTmp.getOriginalLevel(),scHeroRankUpConfig.getOpenLevel()); + heroTmp.setLevel(scHeroRankUpConfig.getOpenLevel()); heroTmp.setStarBreakId(scHeroRankUpConfig.getId()); scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.BREAK_TYPE,scHero.getStar()); for(SCHeroRankUpConfig scHeroRankUpConfigBreak :scHeroRankUpConfigByType.values()){ diff --git a/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_addhero.java b/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_addhero.java index 5020e6c06..cc6e7eefd 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_addhero.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/kefu/Cmd_addhero.java @@ -4,6 +4,7 @@ import com.ljsd.jieling.config.clazzStaticCfg.HeroStaticConfig; import com.ljsd.jieling.core.GlobalsDef; import com.ljsd.jieling.globals.BIReason; import com.ljsd.jieling.logic.dao.Hero; +import com.ljsd.jieling.logic.mission.GameEvent; import rpc.protocols.CommonProto; import rpc.protocols.Expedition; import com.ljsd.jieling.util.ItemUtil; @@ -40,7 +41,8 @@ public class Cmd_addhero extends GmRoleAbstract{ Map scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE,scHero.getStar()); Map scHeroRankUpConfigByTypeTree = new TreeMap<>(scHeroRankUpConfigByType); SCHeroRankUpConfig scHeroRankUpConfig = ((TreeMap) scHeroRankUpConfigByTypeTree).lowerEntry(hero.getStar()).getValue(); - hero.setLevel(getUser(),scHeroRankUpConfig.getOpenLevel()); + getUser().getUserMissionManager().onGameEvent(getUser(), GameEvent.HERO_LEVEL_UP,hero.getOriginalLevel(),scHeroRankUpConfig.getOpenLevel()); + hero.setLevel(scHeroRankUpConfig.getOpenLevel()); hero.setStarBreakId(scHeroRankUpConfig.getId()); scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.BREAK_TYPE,scHero.getStar()); 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 868d32929..53b397cbc 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 @@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory; import java.util.*; -public class Hero extends MongoBase { +public class Hero extends MongoBase implements Cloneable { private static final Logger LOGGER = LoggerFactory.getLogger(Hero.class); private String id; @@ -31,15 +31,15 @@ public class Hero extends MongoBase { private int star; - private Map equipByPositionMap; + private Map equipByPositionMap; - private Map soulEquipByPositionMap; + private Map soulEquipByPositionMap; private int breakId; - private int starBreakId; + private int starBreakId; - private int createTime ; + private int createTime; private int lastUpdateEnergyTime; @@ -49,17 +49,18 @@ public class Hero extends MongoBase { private int isLock; - private int createType ; - private int changeId ; + private int createType; + private int changeId; private Set jewelInfo = new HashSet<>(); private int skin; - public Hero(){ + + public Hero() { //绑定关系 this.setRootCollection(User._COLLECTION_NAME); } - public Hero(int uid,int heroTid,int initStar,Hero hero) { + public Hero(int uid, int heroTid, int initStar, Hero hero) { this.setRootCollection(User._COLLECTION_NAME); this.id = KeyGenUtils.produceIdByModule(UUIDEnum.HERO, uid); this.templateId = heroTid; @@ -67,35 +68,35 @@ public class Hero extends MongoBase { SCHero hero1 = SCHero.getsCHero().get(heroTid); int initCfgStar = hero1.getStar(); int maxStar = hero1.getMaxRank(); - if(hero.getStar()maxStar){ - this.star=maxStar; - }else { + if (hero.getStar() < initCfgStar) { + this.star = initCfgStar; + } else if (hero.getStar() > maxStar) { + this.star = maxStar; + } else { this.star = hero.getStar(); } - if(initCfgStar scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE,initCfgStar); - if(scHeroRankUpConfigByType!=null) { - SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByType.get(hero.getStar()-1); + if (initCfgStar < hero.getStar()) { + Map scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE, initCfgStar); + if (scHeroRankUpConfigByType != null) { + SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByType.get(hero.getStar() - 1); starBreakId = scHeroRankUpConfig.getId(); } } this.equipByPositionMap = new HashMap<>(); - // this.soulEquipByPositionMap = hero.soulEquipByPositionMap; + // this.soulEquipByPositionMap = hero.soulEquipByPositionMap; this.soulEquipByPositionMap = new HashMap<>(); this.breakId = hero.breakId; - this.createTime = (int)(System.currentTimeMillis()/1000); - this.speed = hero.speed; - this.especialEquipLevel = hero.especialEquipLevel; - this.createType = 1; + this.createTime = (int) (System.currentTimeMillis() / 1000); + this.speed = hero.speed; + this.especialEquipLevel = hero.especialEquipLevel; + this.createType = 1; } - public Hero(int uid, int heroTid, int initStar){ + public Hero(int uid, int heroTid, int initStar) { this.setRootCollection(User._COLLECTION_NAME); - this.id = KeyGenUtils.produceIdByModule(UUIDEnum.HERO,uid); + this.id = KeyGenUtils.produceIdByModule(UUIDEnum.HERO, uid); SCHero scHero = SCHero.getsCHero().get(heroTid); this.templateId = scHero.getId(); @@ -104,24 +105,24 @@ public class Hero extends MongoBase { this.equipByPositionMap = new HashMap<>(); this.soulEquipByPositionMap = new HashMap<>(); this.especialEquipLevel = 1; - if(initStar!=scHero.getStar()){ - Map scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE,scHero.getStar()); - if(scHeroRankUpConfigByType!=null) { - SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByType.get(initStar-1); + if (initStar != scHero.getStar()) { + Map scHeroRankUpConfigByType = STableManager.getFigureConfig(HeroStaticConfig.class).getScHeroRankUpConfigByShow(GlobalsDef.UP_STAR_TYPE, scHero.getStar()); + if (scHeroRankUpConfigByType != null) { + SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByType.get(initStar - 1); starBreakId = scHeroRankUpConfig.getId(); } } - createTime = (int)(System.currentTimeMillis()/1000); + createTime = (int) (System.currentTimeMillis() / 1000); lastUpdateEnergyTime = createTime; breakId = 0; jewelInfo = new HashSet<>(2); } - public void upStar(int upStar) throws Exception { + public void upStar(int upStar) { this.star += upStar; - updateString("star",star); + updateString("star", star); } @@ -129,14 +130,13 @@ public class Hero extends MongoBase { this.id = id; } - public void setLevel(User user,int level) throws Exception { - user.getUserMissionManager().onGameEvent(user, GameEvent.HERO_LEVEL_UP,this.level,level); + public void setLevel(int level){ updateString("level",level); this.level = level; } - public void setStar(int star) throws Exception { - updateString("star",star); + public void setStar(int star) { + updateString("star", star); this.star = star; } @@ -145,7 +145,7 @@ public class Hero extends MongoBase { } public void setSpeed(int speed) { - updateString("speed",speed); + updateString("speed", speed); this.speed = speed; } @@ -159,6 +159,7 @@ public class Hero extends MongoBase { /** * 获取等级,如果在鸿蒙阵中,需要返回鸿蒙等级 + * * @param heroManager * @return */ @@ -168,15 +169,15 @@ public class Hero extends MongoBase { int maxLevel = scHero.getMaxLevel(); // 如果鸿蒙碑开启 返回鸿蒙系统中神将返回鸿蒙碑等级 - if (heroManager.getHongmengTablet() > 0){ + if (heroManager.getHongmengTablet() > 0) { // 存在共鸣或者使者 if (heroManager.getResonances().values().contains(id) || heroManager.getHongmengGuards().values().contains(id)) { // 鸿蒙碑超过等级上限,返回鸿蒙碑等级 - if (heroManager.getHongmengTablet() <= maxLevel){ + if (heroManager.getHongmengTablet() <= maxLevel) { return heroManager.getHongmengTablet(); } // 最高品质大于等于10的英雄,返回鸿蒙碑等级,否则返回上限等级 - return scHero.getMaxRank() >= 10?heroManager.getHongmengTablet():maxLevel; + return scHero.getMaxRank() >= 10 ? heroManager.getHongmengTablet() : maxLevel; } } if (heroManager.getResonances().values().contains(id)) { @@ -184,7 +185,7 @@ public class Hero extends MongoBase { HongMengAddAttribute hongMengAddAttribute = heroManager.getResonanceAddition().get(HongMengAttributeEnum.LEVEL); if (hongMengAddAttribute != null) { // 是否达到限制等级 - return hongMengAddAttribute.value >= maxLevel ? maxLevel:hongMengAddAttribute.value; + return hongMengAddAttribute.value >= maxLevel ? maxLevel : hongMengAddAttribute.value; } } return level; @@ -192,9 +193,10 @@ public class Hero extends MongoBase { /** * 获取原始等级 + * * @return */ - public int getOriginalLevel (){ + public int getOriginalLevel() { return level; } @@ -203,11 +205,11 @@ public class Hero extends MongoBase { } public Map getEquipByPositionMap() { - return equipByPositionMap==null?new HashMap<>():equipByPositionMap; + return equipByPositionMap == null ? new HashMap<>() : equipByPositionMap; } public Map getEquipByHongmengPositionMap(HeroManager heroManager) { - if (!equipByPositionMap.isEmpty()){ + if (!equipByPositionMap.isEmpty()) { return equipByPositionMap; } // 英雄在共鸣池中 @@ -217,62 +219,63 @@ public class Hero extends MongoBase { if (hongMengByEquip != null && hongMengByEquip.value != -1) { // 根据星级获取装备位置和信息 Map map = SEquipConfig.starByPositionMap.get(hongMengByEquip.value); - return map==null?new HashMap<>():map; + return map == null ? new HashMap<>() : map; } } return equipByPositionMap; } public void setEquipByPositionMap(Map equipByPositionMap) throws Exception { - updateString("equipByPositionMap",equipByPositionMap); + updateString("equipByPositionMap", equipByPositionMap); this.equipByPositionMap = equipByPositionMap; } - public void updateEquipPositionMap(int position,int equipId) throws Exception { - updateString("equipByPositionMap." + position ,equipId); - this.equipByPositionMap.put(position,equipId); + public void updateEquipPositionMap(int position, int equipId) throws Exception { + updateString("equipByPositionMap." + position, equipId); + this.equipByPositionMap.put(position, equipId); } - public void updateMutliEquipPositionMap(Map equipByPositionMapTmp) throws Exception { + public void updateMutliEquipPositionMap(Map equipByPositionMapTmp) throws Exception { this.equipByPositionMap.putAll(equipByPositionMapTmp); - updateString("equipByPositionMap" ,equipByPositionMap); + updateString("equipByPositionMap", equipByPositionMap); } - public void removeEquip(int position){ - if (!equipByPositionMap.containsKey(position)){ + public void removeEquip(int position) { + if (!equipByPositionMap.containsKey(position)) { return; } - removeString(getMongoKey()+".equipByPositionMap." + position); + removeString(getMongoKey() + ".equipByPositionMap." + position); this.equipByPositionMap.remove(position); } public Map getSoulEquipByPositionMap() { - if(soulEquipByPositionMap == null){ - Map map = new HashMap<>(); - updateString("soulEquipByPositionMap" ,map); + if (soulEquipByPositionMap == null) { + Map map = new HashMap<>(); + updateString("soulEquipByPositionMap", map); return map; - }else { + } else { return soulEquipByPositionMap; } } - public void updateSoulEquipPositionMap(int position,int equipId) { - updateString("soulEquipByPositionMap." + position ,equipId); - this.soulEquipByPositionMap.put(position,equipId); + public void updateSoulEquipPositionMap(int position, int equipId) { + updateString("soulEquipByPositionMap." + position, equipId); + this.soulEquipByPositionMap.put(position, equipId); } - public void removeSoulEquip(int position){ - removeString(getMongoKey()+".soulEquipByPositionMap." + position); + public void removeSoulEquip(int position) { + removeString(getMongoKey() + ".soulEquipByPositionMap." + position); this.soulEquipByPositionMap.remove(position); } /** * breaId 鸿蒙阵 + * * @param heroManager * @return */ - public int getBreakIdByHongMeng(HeroManager heroManager){ + public int getBreakIdByHongMeng(HeroManager heroManager) { // 英雄在共鸣池中 if (heroManager.getResonances().values().contains(id) || heroManager.getHongmengGuards().values().contains(id)) { return HeroLogic.getInstance().calRobotBreaByLevel(templateId, getLevel(heroManager)); @@ -285,7 +288,7 @@ public class Hero extends MongoBase { } public void setBreakId(int breakId) throws Exception { - updateString("breakId",breakId); + updateString("breakId", breakId); this.breakId = breakId; } @@ -294,14 +297,13 @@ public class Hero extends MongoBase { } - public void setCreateTime(int createTime) throws Exception { - updateString("createTime",createTime); + updateString("createTime", createTime); this.createTime = createTime; } public void setLastUpdateEnergyTime(int lastUpdateEnergyTime) throws Exception { - updateString("lastUpdateEnergyTime",lastUpdateEnergyTime); + updateString("lastUpdateEnergyTime", lastUpdateEnergyTime); this.lastUpdateEnergyTime = lastUpdateEnergyTime; } @@ -314,12 +316,13 @@ public class Hero extends MongoBase { } public void setStarBreakId(int starBreakId) { - updateString("starBreakId",starBreakId); + updateString("starBreakId", starBreakId); this.starBreakId = starBreakId; } - public void updateEspecial(int especialEquipLevel){ + + public void updateEspecial(int especialEquipLevel) { this.especialEquipLevel = especialEquipLevel; - updateString("especialEquipLevel",especialEquipLevel); + updateString("especialEquipLevel", especialEquipLevel); } @@ -328,22 +331,26 @@ public class Hero extends MongoBase { } public void setIsLock(int isLock) { - updateString("isLock",isLock); + updateString("isLock", isLock); this.isLock = isLock; } + public void setEspecialEquipLevel(int especialEquipLevel) { + this.especialEquipLevel = especialEquipLevel; + } + public int getEspecialEquipLevel() { return especialEquipLevel; } - public int getEspecialEquipLevelByHongmeng(HeroManager heroManager,String heroId) { + public int getEspecialEquipLevelByHongmeng(HeroManager heroManager, String heroId) { // 英雄在共鳴池中 if (heroManager.getResonances().values().contains(heroId)) { // 法宝 HongMengAddAttribute hongMengAddAttribute = heroManager.getResonanceAddition().get(HongMengAttributeEnum.MAGIC_WEAPON); - if (hongMengAddAttribute != null){ + if (hongMengAddAttribute != null) { // 对比本身和共鸣等级,选高的 - return especialEquipLevel >= hongMengAddAttribute.value?especialEquipLevel:hongMengAddAttribute.value; + return especialEquipLevel >= hongMengAddAttribute.value ? especialEquipLevel : hongMengAddAttribute.value; } } return especialEquipLevel; @@ -353,18 +360,19 @@ public class Hero extends MongoBase { return jewelInfo; } - public void addJewel(String jewelId){ + public void addJewel(String jewelId) { jewelInfo.add(jewelId); - updateString("jewelInfo",jewelInfo); + updateString("jewelInfo", jewelInfo); } - public void removeJewel(String jewelId){ + + public void removeJewel(String jewelId) { jewelInfo.remove(jewelId); - updateString("jewelInfo",jewelInfo); + updateString("jewelInfo", jewelInfo); } public void setJewelInfo(Set jewelInfo) { this.jewelInfo = jewelInfo; - updateString("jewelInfo",this.jewelInfo); + updateString("jewelInfo", this.jewelInfo); } public int getCreateType() { @@ -373,13 +381,13 @@ public class Hero extends MongoBase { public void setCreateType(int createType) { this.createType = createType; - updateString("createType",createType); + updateString("createType", createType); } public void setChangeId(int changeId) { this.changeId = changeId; - updateString("changeId",changeId); + updateString("changeId", changeId); } public int getChangeId() { @@ -392,7 +400,17 @@ public class Hero extends MongoBase { public void setSkin(int skin) { this.skin = skin; - updateString("skin",skin); + updateString("skin", skin); + } + @Override + public Hero clone() { + Hero hero = null; + try { + hero = (Hero) super.clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + return hero; } } diff --git a/worldserver/src/main/java/com/world/logic/HeroLogic.java b/worldserver/src/main/java/com/world/logic/HeroLogic.java index 2235b1c77..a0d47a99a 100644 --- a/worldserver/src/main/java/com/world/logic/HeroLogic.java +++ b/worldserver/src/main/java/com/world/logic/HeroLogic.java @@ -694,7 +694,8 @@ public class HeroLogic { } if(!isBreak){ - hero.setLevel( user,targetLevel); + user.getUserMissionManager().onGameEvent(user, GameEvent.HERO_LEVEL_UP,hero.getOriginalLevel(),targetLevel); + hero.setLevel(targetLevel); }else{ hero.setBreakId(breakId); user.getUserMissionManager().onGameEvent(user,GameEvent.HERO_UP,1); @@ -2355,7 +2356,7 @@ public class HeroLogic { itemNum.add(item.getItemNum()); }); ReportUtil.onReportEvent(user,ReportEventEnum.HERO_COMPOSITION.getType(),String.valueOf(hero.getTemplateId()),hero.getLevel(user.getHeroManager()),hero.getStar(),itemId,itemNum); - hero.setLevel(user,1); + hero.setLevel(1); hero.setBreakId(0); HeroInfoProto.HeroReturnResponse build = HeroInfoProto.HeroReturnResponse.newBuilder().setDrop(drop).build(); MessageUtil.sendMessage(session,1,responseMsgId,build,true);