From 8057c913bb218fb2ca6004d8c6db2f917eee9c09 Mon Sep 17 00:00:00 2001 From: jiahuiwen Date: Thu, 26 Nov 2020 20:06:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=B8=BF=E8=92=99=E7=A2=91=E5=88=9D?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ljsd/jieling/globals/BIReason.java | 4 + .../jieling/handler/GetPlayerInfoHandler.java | 38 ++- .../hero/HongmengCleanTimeRequestHandler.java | 22 ++ .../HongmengOpenResonanceRequestHandler.java | 21 ++ .../hero/HongmengResonanceRequestHandler.java | 25 ++ .../hero/HongmengUpgradRequestHandler.java | 21 ++ .../ljsd/jieling/logic/dao/HeroManager.java | 78 ++++- .../ljsd/jieling/logic/hero/HeroLogic.java | 290 +++++++++++++++++- .../logic/hero/HongMengAttributeEnum.java | 23 ++ .../src/main/java/config/Hongmeng.java | 40 +++ .../src/main/java/config/HongmengUP.java | 44 +++ .../src/main/java/config/SSpecialConfig.java | 5 + 12 files changed, 595 insertions(+), 16 deletions(-) create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengCleanTimeRequestHandler.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengOpenResonanceRequestHandler.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengResonanceRequestHandler.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengUpgradRequestHandler.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HongMengAttributeEnum.java create mode 100644 tablemanager/src/main/java/config/Hongmeng.java create mode 100644 tablemanager/src/main/java/config/HongmengUP.java diff --git a/serverlogic/src/main/java/com/ljsd/jieling/globals/BIReason.java b/serverlogic/src/main/java/com/ljsd/jieling/globals/BIReason.java index fb16b7d59..c6736134c 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/globals/BIReason.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/globals/BIReason.java @@ -295,4 +295,8 @@ public interface BIReason { int SKIN_USE_CONSUME = 1073;//激活皮肤消耗 int SUB_ACTIVITY_CONSUME = 1074;//易经宝库 int SUB_ACTIVITY_CONSUME_FINISH = 1075;//易经宝库活动结束补发消耗 + + int OPEN_HONGMENG_GRAID = 1076; // 开鸿蒙阵格子消耗 + int CLEAR_HONGMENG_GRAID = 1077; // 清鸿蒙阵格子cd + int HONGMENG_UPGRIDE = 1078; // 鸿蒙碑升级消耗 } \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java index ea684f496..f64bb2df4 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java @@ -20,6 +20,7 @@ import com.ljsd.jieling.logic.activity.event.UserOnlineEvent; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.GlobalSystemControl; import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.logic.hero.HongMengAttributeEnum; import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.player.PlayerLogic; import com.ljsd.jieling.logic.question.QuestionLogic; @@ -77,7 +78,8 @@ public class GetPlayerInfoHandler extends BaseHandler{ BuyGoodsLogic.initOwernBagInfo(user); // Poster.getPoster().dispatchEvent(new UserOnlineEvent(userId)); user.getUserMissionManager().onGameEvent(user, GameEvent.LOGIN_GAME,0); - playerInfoManager.setLoginTime(TimeUtils.now()); + long now = TimeUtils.now(); + playerInfoManager.setLoginTime(now); Map guidePoints = playerInfoManager.getGuidePoints(); Map vipInfo = playerInfoManager.getVipInfo(); List list = new ArrayList<>(); @@ -119,7 +121,8 @@ public class GetPlayerInfoHandler extends BaseHandler{ .setPhoneNum(user.getPlayerInfoManager().getPhoneBindInfo().getPhoneNum()) .setState(user.getPlayerInfoManager().getPhoneBindInfo().getState()).build(); RechargeInfo rechargeInfo = playerInfoManager.getRechargeInfo(); - Map totalCountMap = user.getHeroManager().getTotalCount(); + HeroManager heroManager = user.getHeroManager(); + Map totalCountMap = heroManager.getTotalCount(); int alreadyCount =0; for(Integer id : STableManager.getFigureConfig(HeroStaticConfig.class).getRandomHeroIds()){ Integer count = totalCountMap.get(id); @@ -144,7 +147,7 @@ public class GetPlayerInfoHandler extends BaseHandler{ questState=user.getQuestionManager().getQuestState(); } //图鉴信息 - Map heroHandBook = user.getHeroManager().getHeroHandBook(); + Map heroHandBook = heroManager.getHeroHandBook(); List heroHandBookList = new ArrayList<>(); heroHandBook.forEach((k,v)->heroHandBookList.add(CommonProto.EveryHeroHandBook.newBuilder().setHeroId(k).setMaxStar(v).build())); @@ -186,8 +189,27 @@ public class GetPlayerInfoHandler extends BaseHandler{ user.getPlayerInfoManager().getMonthCard().put(Global.LMONTHCARDID, (int) (System.currentTimeMillis() / 1000)); Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.RECHARGE_BUY.getType(),Global.LMONTHCARDID)); } - - + List hongmengHeroInfos = new ArrayList<>(); + Map resonances = heroManager.getResonances(); + Map resonancesTime = heroManager.getResonancesTime(); + for (Map.Entry entry : resonances.entrySet()) { + PlayerInfoProto.HongmengHeroInfo hongmengHeroInfo = PlayerInfoProto.HongmengHeroInfo.newBuilder() + .setGridId(entry.getKey()) + .setHeroId(entry.getValue()) + .setTime(resonancesTime.containsKey(entry.getKey()) ? (resonancesTime.get(entry.getKey()) - now < 0 ? 0 : (resonancesTime.get(entry.getKey()) - now) / 1000) : 0) + .build(); + hongmengHeroInfos.add(hongmengHeroInfo); + } + List hongmengAdditions = new ArrayList<>(); + Map resonanceAddition = heroManager.getResonanceAddition(); + for (Map.Entry entry : resonanceAddition.entrySet()) { + PlayerInfoProto.HongmengAddition hongmengAddition = PlayerInfoProto.HongmengAddition + .newBuilder() + .setAdditionType(entry.getKey().getPropertyId()) + .setValue(entry.getValue()) + .build(); + hongmengAdditions.add(hongmengAddition); + } StoreLogic.reloadStoreInfo(user,7);//重载功能商店 PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse = PlayerInfoProto.GetPlayerInfoResponse.newBuilder() @@ -207,7 +229,7 @@ public class GetPlayerInfoHandler extends BaseHandler{ .setTreasureLevel(playerInfoManager.getTreasureLevel()) .setSignInInfo(CommonProto.SignInInfo.newBuilder().setDays(playerInfoManager.getSign()+1).setState(playerInfoManager.getSignTotay()).build()) .setMonsterAttackTime(user.getMapManager().getLastMonsterAttack()) - .setFirstTenth(user.getHeroManager().getFirstTenth()) + .setFirstTenth(heroManager.getFirstTenth()) .setIsDayFirst(playerInfoManager.getIsdayFirst()) .setEndInfo(endless) .setPlayerBindPhone(playerBindPhone) @@ -222,6 +244,10 @@ public class GetPlayerInfoHandler extends BaseHandler{ .setExpeditionLeve(user.getExpeditionManager().getExpeditionLeve()) .setHadLuckTime( user.getPlayerInfoManager().getLuckWheelLimitTime()) .setHadAdvanceLuckTime(user.getPlayerInfoManager().getLuckAdvanceWheelLimitTime()) + .addAllHongmengGuards(heroManager.getHongmengGuard()) + .setHongmengTablet(heroManager.getHongmengTablet()) + .addAllHongmengHeroInfos(hongmengHeroInfos) + .addAllHongmengAdditions(hongmengAdditions) .build(); ReportUtil.onReportEvent(user, ReportEventEnum.APP_LOGIN.getType()); try { diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengCleanTimeRequestHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengCleanTimeRequestHandler.java new file mode 100644 index 000000000..7a561a257 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengCleanTimeRequestHandler.java @@ -0,0 +1,22 @@ +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; + +@Component +public class HongmengCleanTimeRequestHandler extends BaseHandler { + @Override + public MessageTypeProto.MessageType getMessageCode() { + return MessageTypeProto.MessageType.HONGMENG_CLEAN_TIME_RESQUEST; + } + + @Override + public void processWithProto(ISession session, HeroInfoProto.CleanResonanceTimeRequest proto) throws Exception { + int gridId = proto.getGridId(); + HeroLogic.getInstance().cleanTime(session, MessageTypeProto.MessageType.HONGMENG_CLEAN_TIME_RESPONSE, gridId); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengOpenResonanceRequestHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengOpenResonanceRequestHandler.java new file mode 100644 index 000000000..9ee1869a6 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengOpenResonanceRequestHandler.java @@ -0,0 +1,21 @@ +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; + +@Component +public class HongmengOpenResonanceRequestHandler extends BaseHandler { + @Override + public MessageTypeProto.MessageType getMessageCode() { + return MessageTypeProto.MessageType.HONGMENG_OPEN_RESONANCE_REQUEST; + } + + @Override + public void processWithProto(ISession session, HeroInfoProto.OpenResonanceRequest proto) throws Exception { + HeroLogic.getInstance().openResonance(session, MessageTypeProto.MessageType.HONGMENG_OPEN_RESONANCE_RESPONSE, proto.getGridId()); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengResonanceRequestHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengResonanceRequestHandler.java new file mode 100644 index 000000000..4a6d523c1 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengResonanceRequestHandler.java @@ -0,0 +1,25 @@ +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; + +@Component +public class HongmengResonanceRequestHandler extends BaseHandler { + @Override + public MessageTypeProto.MessageType getMessageCode() { + return MessageTypeProto.MessageType.HONGMENG_RESONANCE_REQUEST; + } + + @Override + public void processWithProto(ISession session, HeroInfoProto.ResonanceRequest proto) throws Exception { + if (proto.getType() == 1) { + HeroLogic.getInstance().resonance(session, MessageTypeProto.MessageType.HONGMENG_RESONANCE_RESPONSE, proto.getHeroId(), proto.getGridId()); + } else { + HeroLogic.getInstance().unLoadResonance(session, MessageTypeProto.MessageType.HONGMENG_RESONANCE_RESPONSE, proto.getGridId()); + } + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengUpgradRequestHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengUpgradRequestHandler.java new file mode 100644 index 000000000..048683baf --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/hero/HongmengUpgradRequestHandler.java @@ -0,0 +1,21 @@ +package com.ljsd.jieling.handler.hero; + +import com.google.protobuf.GeneratedMessage; +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.MessageTypeProto; +import org.springframework.stereotype.Component; + +@Component +public class HongmengUpgradRequestHandler extends BaseHandler { + @Override + public MessageTypeProto.MessageType getMessageCode() { + return MessageTypeProto.MessageType.HONGMENG_UPGRADE_REQUEST; + } + + @Override + public void processWithProto(ISession iSession, GeneratedMessage proto) throws Exception { + HeroLogic.getInstance().updateHongmengTablet(iSession, MessageTypeProto.MessageType.HONGMENG_UPGRADE_RESPONSE); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java index 602be14da..86764eccd 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java @@ -1,13 +1,13 @@ package com.ljsd.jieling.logic.dao; import com.ljsd.common.mogodb.MongoBase; -import com.ljsd.jieling.db.mongo.MongoKey; import com.ljsd.jieling.logic.activity.event.Poster; import com.ljsd.jieling.logic.activity.event.RemoveHeroEvent; import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.logic.hero.HongMengAttributeEnum; +import org.luaj.vm2.ast.Str; -import java.util.HashMap; -import java.util.Map; +import java.util.*; public class HeroManager extends MongoBase { @@ -30,6 +30,19 @@ public class HeroManager extends MongoBase { this.setRootCollection(User._COLLECTION_NAME); } + // 鸿蒙守卫 + private List hongmengGuard = new ArrayList<>(); + // 共鸣英雄<格子id,英雄id> + private Map resonances = new HashMap<>(); + // 共鸣英雄<格子id,冷却时间> + private Map resonancesTime = new HashMap<>(); + // 共鸣加成 + private Map resonanceAddition = new HashMap<>(); + // 鸿蒙碑等级 + private int hongmengTablet; + // 鸿蒙碑最大等级 + private Set hongmengMaxLevel = new HashSet<>(); + public void updateRandCount(int type,int count){ updateString("totalCount." + type, count); totalCount.put(type,count); @@ -129,5 +142,64 @@ public class HeroManager extends MongoBase { skinInfo.remove(skinId); removeString(getMongoKey()+"skinInfo."+skinId); } + + public List getHongmengGuard() { + return hongmengGuard; + } + + public void setHongmengGuard(List hongmengGuard) { + this.hongmengGuard = hongmengGuard; + updateString("hongmengGuard", hongmengGuard); + } + + public Map getResonances() { + return resonances; + } + + public void setResonances(Map resonances) { + this.resonances = resonances; + updateString("resonances", resonances); + } + + public void updateResonances(int index, String heroId) { + this.resonances.put(index, heroId); + updateString("resonances."+ index, heroId); + } + + public Map getResonancesTime() { + return resonancesTime; + } + + public void updateResonancesTime(int index, long time) { + this.resonancesTime.put(index, time); + updateString("resonancesTime."+ index, time); + } + + public Map getResonanceAddition() { + return resonanceAddition; + } + + public void setResonanceAddition(Map resonanceAddition) { + this.resonanceAddition = resonanceAddition; + updateString("resonanceAddition", resonanceAddition); + } + + public int getHongmengTablet() { + return hongmengTablet; + } + + public void setHongmengTablet(int hongmengTablet) { + this.hongmengTablet = hongmengTablet; + updateString("hongmengTablet", hongmengTablet); + } + + public Set getHongmengMaxLevel() { + return hongmengMaxLevel; + } + + public void setHongmengMaxLevel(Set hongmengMaxLevel) { + this.hongmengMaxLevel = hongmengMaxLevel; + updateString("hongmengMaxLevel", hongmengMaxLevel); + } } 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 8c9676e5e..ac430c5af 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 @@ -1,18 +1,15 @@ package com.ljsd.jieling.logic.hero; -import com.ljsd.GameApplication; import com.ljsd.jieling.chat.logic.ChatLogic; import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig; import com.ljsd.jieling.config.clazzStaticCfg.HeroStaticConfig; import com.ljsd.jieling.core.GlobalsDef; -import com.ljsd.jieling.core.VipPrivilegeType; import com.ljsd.jieling.db.redis.RedisKey; import com.ljsd.jieling.db.redis.RedisUtil; 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.jbean.ActivityMission; import com.ljsd.jieling.jbean.ActivityProgressInfo; @@ -29,7 +26,6 @@ import com.ljsd.jieling.logic.fight.CombatLogic; import com.ljsd.jieling.logic.fight.passiveSkillCal.PassiveskillCalEnum; import com.ljsd.jieling.logic.item.ItemLogic; import com.ljsd.jieling.logic.mission.GameEvent; -import com.ljsd.jieling.logic.mission.MissionLoigc; import com.ljsd.jieling.logic.player.PlayerLogic; import com.ljsd.jieling.network.server.ProtocolsManager; import com.ljsd.jieling.network.session.ISession; @@ -40,7 +36,6 @@ import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.util.*; import config.*; import manager.STableManager; -import org.luaj.vm2.ast.Str; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import util.MathUtils; @@ -51,7 +46,6 @@ import java.math.BigDecimal; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; public class HeroLogic{ @@ -3268,7 +3262,6 @@ public class HeroLogic{ * 灵兽涅槃 * @param session * @param pokemonId - * @param level * @param messageType * @throws Exception */ @@ -3403,4 +3396,287 @@ public class HeroLogic{ MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true); } + + // ================共鸣、鸿蒙碑========= + /** + * 添加或更新鸿蒙守卫 + * @param user + */ + public void addOrUpdateHongmeng(User user) { + if (user.getPlayerInfoManager().getLevel() < SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_OPENLEVEL)) { + return; + } + HeroManager heroManager = user.getHeroManager(); + Collection values = heroManager.getHeroMap().values(); + List heroes = new ArrayList<>(values); + Collections.sort(heroes, new Comparator() { + @Override + public int compare(Hero hero1, Hero hero2) { + int compareValue = hero1.getLevel() - hero2.getLevel(); + if (compareValue != 0) { + return compareValue; + } + return Integer.compare(hero1.getStar(), hero2.getStar()); + } + }); + List hongmengs = heroManager.getHongmengGuard(); + hongmengs.clear(); + // 只要任意鸿蒙守卫中有未穿戴装备的部位,就不会触发装备共鸣,共鸣区域放入神将时不再自动卸下装备 1:不卸下装备 + int isUnloadEquip = 1; + + // 只要任意鸿蒙守卫未穿戴魂宝/灵宝,或强化等级为0,便不会触发对应宝物的共鸣 + int soulEquip = 1000; + int spiritEquip = 1000; + + // 共鸣等级=鸿蒙守卫中最低的等级 + int resonanceLevel = 1000; + + // 共鸣法宝=鸿蒙守卫中法宝强化最低等级 + int especialEquipLevel = 100; + + // 是否开启鸿蒙碑 + int tablet = 1; + Collection values2 = heroManager.getResonances().values(); + Map equipMap = user.getEquipManager().getEquipMap(); + String[] openLevel = SSpecialConfig.getStringValue(SSpecialConfig.HONGMENG_UPGRADE_LIMIT).split("#"); + for (int i = 0; i < heroes.size(); i++) { + Hero hero = heroes.get(i); + if (values2.contains(hero.getId())) { + continue; + } + if (hero.getEquipByPositionMap().size() != 4) { + isUnloadEquip = 0; + } + if (hero.getJewelInfo().isEmpty()) { + soulEquip = 0; + spiritEquip = 0; + } else { + for (String jewel : hero.getJewelInfo()) { + PropertyItem propertyItem = equipMap.get(jewel); + if (propertyItem == null) { + soulEquip = 0; + spiritEquip = 0; + } else { + SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(propertyItem.getEquipId()); + if (config == null) { + continue; + } + // getLocation 1魂宝 2灵宝 + if (config.getLocation() == 1) { + soulEquip = propertyItem.getLevel() < soulEquip ? propertyItem.getLevel() : soulEquip; + } else { + spiritEquip = propertyItem.getLevel() < soulEquip ? propertyItem.getLevel() : soulEquip; + } + } + } + } + if (hero.getEspecialEquipLevel() < especialEquipLevel) { + especialEquipLevel = hero.getEspecialEquipLevel(); + } + if (hero.getLevel() < Integer.parseInt(openLevel[1])) { + tablet = 0; + } + if (hero.getLevel() < resonanceLevel) { + resonanceLevel = hero.getLevel(); + } + hongmengs.add(hero.getId()); + if (hongmengs.size() >= Integer.parseInt(openLevel[0])) { + break; + } + } + if (hongmengs.size() < Integer.parseInt(openLevel[0])) { + return; + } + heroManager.setHongmengGuard(hongmengs); + // 计算共鸣属性 + Map resonanceAddition = heroManager.getResonanceAddition(); + resonanceAddition.clear(); + resonanceAddition.put(HongMengAttributeEnum.LEVEL, resonanceLevel); + resonanceAddition.put(HongMengAttributeEnum.EQUIP, isUnloadEquip); + resonanceAddition.put(HongMengAttributeEnum.SOUL_EQUIP, soulEquip); + resonanceAddition.put(HongMengAttributeEnum.SPIRIT_EQUIP, spiritEquip); + resonanceAddition.put(HongMengAttributeEnum.MAGIC_WEAPON, especialEquipLevel); + heroManager.setResonanceAddition(resonanceAddition); + // 鸿蒙碑 + if (tablet == 1 && heroManager.getHongmengTablet() == 0) { + // 开启鸿蒙碑 + heroManager.setHongmengTablet(Integer.parseInt(openLevel[1])); + } + } + + /** + * 开启共鸣区域格子 + * @param session + * @param messageType + * @throws Exception + */ + public void openResonance(ISession session, MessageTypeProto.MessageType messageType, int graidId) throws Exception { + User user = UserManager.getUser(session.getUid()); + HeroManager heroManager = user.getHeroManager(); + Map resonances = heroManager.getResonances(); + if (resonances.containsKey(graidId)) { + LOGGER.info("openResonance uid=>{} has open=>{}", user.getId(), graidId); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + Hongmeng hongmeng = Hongmeng.hongmengs.get(graidId); + if (hongmeng == null) { + LOGGER.info("openResonance uid=>{} graidId not exist=>{}", user.getId(), graidId); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + Map cost1 = new HashMap<>(1); + cost1.put(hongmeng.getPropPrice()[0], hongmeng.getPropPrice()[1]); + boolean checkCost1 = ItemUtil.checkCost(user, cost1); + if (checkCost1) { + ItemUtil.itemCost(user, cost1, BIReason.OPEN_HONGMENG_GRAID, graidId); + } else { + Map cost2 = new HashMap<>(1); + cost2.put(hongmeng.getMoneyPrice()[0], hongmeng.getMoneyPrice()[1]); + boolean checkCost2 = ItemUtil.checkCost(user, cost2); + if (!checkCost2) { + LOGGER.info("openResonance uid=>{} cost item not enough=>{}", user.getId(), graidId); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + ItemUtil.itemCost(user, cost2, BIReason.OPEN_HONGMENG_GRAID, graidId); + } + resonances.put(graidId, ""); + heroManager.setResonances(resonances); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), null); + } + + + /** + * 共鸣 + * @param session + * @param messageType + * @param heroId 需要共鸣的神将id + * @param index 需要放的共鸣区位置 + */ + public void resonance(ISession session, MessageTypeProto.MessageType messageType, String heroId, int index) throws Exception { + User user = UserManager.getUser(session.getUid()); + HeroManager heroManager = user.getHeroManager(); + Hero hero = heroManager.getHeroMap().get(heroId); + if (hero == null) { + LOGGER.info("resonance uid=>{} no the heroId=>{}", user.getId(), heroId); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + if (heroManager.getHongmengGuard().contains(heroId)) { + LOGGER.info("resonance uid=>{} the heroId=>{} is HongmengGuard", user.getId(), heroId); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + Map resonances = heroManager.getResonances(); + String resonanceInfo = resonances.get(index); + if (resonanceInfo == null || !resonanceInfo.isEmpty()) { + LOGGER.info("resonance uid=>{} the index not open=>{}", user.getId(), index); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + Map resonancesTime = heroManager.getResonancesTime(); + if (resonancesTime.get(index) != null && resonancesTime.get(index) > TimeUtils.now()) { + LOGGER.info("resonance uid=>{} time =>{}", user.getId(), resonancesTime.get(index)); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + // 添加到共鸣区 + heroManager.updateResonances(index, heroId); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), null); + } + + + /** + * 卸下共鸣英雄 + * @param session + * @param messageType + * @param index + * @throws Exception + */ + public void unLoadResonance(ISession session, MessageTypeProto.MessageType messageType, int index) throws Exception{ + User user = UserManager.getUser(session.getUid()); + HeroManager heroManager = user.getHeroManager(); + Map resonances = heroManager.getResonances(); + String resonanceInfo = resonances.get(index); + if (resonanceInfo == null || resonanceInfo.isEmpty()) { + LOGGER.info("unLoadResonance uid=>{} the index not open=>{}", user.getId(), index); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + Hero hero = heroManager.getHero(resonanceInfo); + if (hero == null) { + LOGGER.info("unLoadResonance uid=>{} cur hero is null {}", user.getId(), resonanceInfo); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + heroManager.updateResonances(index, ""); + heroManager.updateResonancesTime(index, TimeUtils.now() + SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_LATTICE_WAIT_TIME) * 1000); + heroManager.updateResonances(index, resonanceInfo); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), null); + } + + /** + * 花费妖晶清除共鸣冷却时间 + * @param session + * @param messageType + * @param index + * @throws Exception + */ + public void cleanTime(ISession session, MessageTypeProto.MessageType messageType, int index) throws Exception { + User user = UserManager.getUser(session.getUid()); + HeroManager heroManager = user.getHeroManager(); + Map resonances = heroManager.getResonances(); + String resonanceInfo = resonances.get(index); + if (resonanceInfo == null) { + LOGGER.info("cleanTime uid=>{} the index not open=>{}", user.getId(), index); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + Map resonancesTime = heroManager.getResonancesTime(); + Long unloadTime = resonancesTime.get(index); + if (unloadTime == null || unloadTime <= TimeUtils.now()) { + LOGGER.info("cleanTime uid=>{} time =>{}", user.getId(), unloadTime); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + String[] stringValue = SSpecialConfig.getStringValue(SSpecialConfig.HONGMENG_LATTICE_PRICE).split("#"); + long time = unloadTime - TimeUtils.now(); + int count = (int) (time / 1000 * Integer.parseInt(stringValue[0])); + Map cost = new HashMap<>(1); + cost.put(Integer.parseInt(stringValue[1]), count); + boolean checkCost = ItemUtil.checkCost(user, cost); + if (!checkCost) { + LOGGER.info("cleanTime uid=>{} item not enough =>{}", user.getId(), unloadTime); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + ItemUtil.itemCost(user, cost, BIReason.CLEAR_HONGMENG_GRAID, index); + heroManager.updateResonancesTime(index, 0L); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), null); + } + + /** + * 升级鸿蒙碑 + * @param session + * @param messageType + * @throws Exception + */ + public void updateHongmengTablet(ISession session, MessageTypeProto.MessageType messageType) throws Exception { + User user = UserManager.getUser(session.getUid()); + HeroManager heroManager = user.getHeroManager(); + if (heroManager.getHongmengTablet() == 0) { + LOGGER.info("updateHongmengTablet uid=>{} HongmengTablet not open=>{}", user.getId(), 0); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + String[] split = SSpecialConfig.getStringValue(SSpecialConfig.HONGMENG_UPGRADE_LIMIT).split("#"); + int maxLevel = heroManager.getHongmengMaxLevel().size() * SSpecialConfig.getIntegerValue(SSpecialConfig.HONGMENG_ONEHERO_OPENLEVEL) + Integer.parseInt(split[0]); + if (heroManager.getHongmengTablet() >= maxLevel) { + LOGGER.info("updateHongmengTablet uid=>{} curLevel={} maxLevel =>{}", user.getId(), heroManager.getHongmengTablet(), maxLevel); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + int nextLevel = heroManager.getHongmengTablet() + 1; + HongmengUP hongmengUP = HongmengUP.hongmengUPLevels.get(nextLevel); + if (hongmengUP == null) { + LOGGER.info("updateHongmengTablet uid=>{} curLevel={} maxLevel =>{} nextLevel=>{}", user.getId(), heroManager.getHongmengTablet(), maxLevel, nextLevel); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + int[][] levelUp = hongmengUP.getLevelUp(); + boolean b = ItemUtil.itemCost(user, levelUp, BIReason.HONGMENG_UPGRIDE, nextLevel); + if (!b) { + LOGGER.info("updateHongmengTablet uid=>{} nextLevel=>{} need item not enough", user.getId(), nextLevel); + throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); + } + heroManager.setHongmengTablet(nextLevel); + MessageUtil.sendMessage(session, 1, messageType.getNumber(), null); + } + } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HongMengAttributeEnum.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HongMengAttributeEnum.java new file mode 100644 index 000000000..64619049e --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HongMengAttributeEnum.java @@ -0,0 +1,23 @@ +package com.ljsd.jieling.logic.hero; + +/** + * 鸿蒙阵 加成类型 + */ +public enum HongMengAttributeEnum { + + LEVEL(1), + EQUIP(2), + SOUL_EQUIP(3), // 魂宝 + SPIRIT_EQUIP(4),// 灵宝 + MAGIC_WEAPON(5), // 法宝 + ; + private int propertyId; + + HongMengAttributeEnum(int propertyId) { + this.propertyId = propertyId; + } + + public int getPropertyId() { + return propertyId; + } +} diff --git a/tablemanager/src/main/java/config/Hongmeng.java b/tablemanager/src/main/java/config/Hongmeng.java new file mode 100644 index 000000000..20e43e99d --- /dev/null +++ b/tablemanager/src/main/java/config/Hongmeng.java @@ -0,0 +1,40 @@ +package config; + +import manager.STableManager; +import manager.Table; + +import java.util.Map; + +@Table(name = "Hongmeng") +public class Hongmeng implements BaseConfig{ + + public static Map hongmengs; + + private int id; + + private int[] propPrice; + + private int[] moneyPrice; + + + @Override + public void init() throws Exception { + hongmengs = STableManager.getConfig(Hongmeng.class); + } + + public Hongmeng getHongmengById(int id){ + return hongmengs.get(id); + } + + public int getId() { + return id; + } + + public int[] getPropPrice() { + return propPrice; + } + + public int[] getMoneyPrice() { + return moneyPrice; + } +} diff --git a/tablemanager/src/main/java/config/HongmengUP.java b/tablemanager/src/main/java/config/HongmengUP.java new file mode 100644 index 000000000..932eebff2 --- /dev/null +++ b/tablemanager/src/main/java/config/HongmengUP.java @@ -0,0 +1,44 @@ +package config; + +import manager.STableManager; +import manager.Table; + +import java.util.HashMap; +import java.util.Map; + +@Table(name = "HongmengUP") +public class HongmengUP implements BaseConfig{ + + public static Map hongmengUPs; + + public static Map hongmengUPLevels; + + private int id; + + private int hongmengLevel; + + private int[][] levelUp; + + + @Override + public void init() throws Exception { + hongmengUPs = STableManager.getConfig(HongmengUP.class); + hongmengUPLevels = new HashMap<>(); + for (HongmengUP hongmengUP : hongmengUPs.values()) { + hongmengUPLevels.put(hongmengUP.getHongmengLevel(), hongmengUP); + } + } + + public int getId() { + return id; + } + + + public int getHongmengLevel() { + return hongmengLevel; + } + + public int[][] getLevelUp() { + return levelUp; + } +} diff --git a/tablemanager/src/main/java/config/SSpecialConfig.java b/tablemanager/src/main/java/config/SSpecialConfig.java index 58288b87d..0daa472bf 100644 --- a/tablemanager/src/main/java/config/SSpecialConfig.java +++ b/tablemanager/src/main/java/config/SSpecialConfig.java @@ -69,6 +69,11 @@ public class SSpecialConfig implements BaseConfig { public static final String GUILD_WAR_ISOPEN = "Guild_war_isopen";//老公会战是否开启 public static final String LUCKYTURNDAILYLIMIT = "LuckyTurnDailyLimit";//幸运探宝每日上限 + public static final String HONGMENG_OPENLEVEL = "Hongmeng_OpenLevel";//鸿蒙阵开启等级 + public static final String HONGMENG_LATTICE_WAIT_TIME = "Hongmeng_Lattice_Waitingtime";//鸿蒙阵每个格子冷却时间(s) + public static final String HONGMENG_LATTICE_PRICE = "Hongmeng_Lattice_Price";//鸿蒙阵格子刷新价格s + public static final String HONGMENG_UPGRADE_LIMIT = "Hongmeng_upgrade_limit";//鸿蒙阵升级开启限制 + public static final String HONGMENG_ONEHERO_OPENLEVEL = "Hongmeng_Onehero_OpenLevel";//鸿蒙阵每个觉醒神将提升的等级 public static final String REPLACE_ITEM_ID = "replace_item_id";//置换玉道具ID public static final String REPLACE_COST = "replace_cost";//置换玉消耗 From c1bc98d9723ef7e77bf1646da784a573bac286bc Mon Sep 17 00:00:00 2001 From: jiahuiwen Date: Thu, 26 Nov 2020 20:24:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=B8=BF=E8=92=99=E9=98=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ljsd/jieling/handler/GetPlayerInfoHandler.java | 6 +++++- .../java/com/ljsd/jieling/logic/hero/HeroLogic.java | 10 +++++----- .../main/java/config/{Hongmeng.java => SHongmeng.java} | 8 ++++---- .../java/config/{HongmengUP.java => SHongmengUP.java} | 10 +++++----- 4 files changed, 19 insertions(+), 15 deletions(-) rename tablemanager/src/main/java/config/{Hongmeng.java => SHongmeng.java} (70%) rename tablemanager/src/main/java/config/{HongmengUP.java => SHongmengUP.java} (67%) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java index f64bb2df4..d6a77149c 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java @@ -20,6 +20,7 @@ import com.ljsd.jieling.logic.activity.event.UserOnlineEvent; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.GlobalSystemControl; import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.logic.hero.HongMengAttributeEnum; import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.player.PlayerLogic; @@ -168,7 +169,7 @@ public class GetPlayerInfoHandler extends BaseHandler{ remove.removeAll(user.getItemManager().getItemMap().keySet()); remove.forEach(n->{ try { - System.out.println("n = " + n); + LOGGER.info("GET_PLAYERINFO_REQUEST uid n = {}", userId, n); user.getItemManager().newItem(n, 0); }catch (Exception e){ e.printStackTrace(); @@ -189,6 +190,9 @@ public class GetPlayerInfoHandler extends BaseHandler{ user.getPlayerInfoManager().getMonthCard().put(Global.LMONTHCARDID, (int) (System.currentTimeMillis() / 1000)); Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.RECHARGE_BUY.getType(),Global.LMONTHCARDID)); } + // 刷新鸿蒙阵 +// HeroLogic.getInstance().addOrUpdateHongmeng(user); + // 组装鸿蒙阵信息 List hongmengHeroInfos = new ArrayList<>(); Map resonances = heroManager.getResonances(); Map resonancesTime = heroManager.getResonancesTime(); 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 6fac5975b..7461c6c25 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 @@ -3416,11 +3416,11 @@ public class HeroLogic{ Collections.sort(heroes, new Comparator() { @Override public int compare(Hero hero1, Hero hero2) { - int compareValue = hero1.getLevel() - hero2.getLevel(); + int compareValue = hero2.getLevel() - hero1.getLevel(); if (compareValue != 0) { return compareValue; } - return Integer.compare(hero1.getStar(), hero2.getStar()); + return Integer.compare(hero2.getStar(), hero1.getStar()); } }); List hongmengs = heroManager.getHongmengGuard(); @@ -3448,7 +3448,7 @@ public class HeroLogic{ if (values2.contains(hero.getId())) { continue; } - if (hero.getEquipByPositionMap().size() != 4) { + if (hero.getEquipByPositionMap().size() != 4 && isUnloadEquip == 1) { isUnloadEquip = 0; } if (hero.getJewelInfo().isEmpty()) { @@ -3522,7 +3522,7 @@ public class HeroLogic{ LOGGER.info("openResonance uid=>{} has open=>{}", user.getId(), graidId); throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } - Hongmeng hongmeng = Hongmeng.hongmengs.get(graidId); + SHongmeng hongmeng = SHongmeng.hongmengs.get(graidId); if (hongmeng == null) { LOGGER.info("openResonance uid=>{} graidId not exist=>{}", user.getId(), graidId); throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); @@ -3668,7 +3668,7 @@ public class HeroLogic{ throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); } int nextLevel = heroManager.getHongmengTablet() + 1; - HongmengUP hongmengUP = HongmengUP.hongmengUPLevels.get(nextLevel); + SHongmengUP hongmengUP = SHongmengUP.hongmengUPLevels.get(nextLevel); if (hongmengUP == null) { LOGGER.info("updateHongmengTablet uid=>{} curLevel={} maxLevel =>{} nextLevel=>{}", user.getId(), heroManager.getHongmengTablet(), maxLevel, nextLevel); throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF); diff --git a/tablemanager/src/main/java/config/Hongmeng.java b/tablemanager/src/main/java/config/SHongmeng.java similarity index 70% rename from tablemanager/src/main/java/config/Hongmeng.java rename to tablemanager/src/main/java/config/SHongmeng.java index 20e43e99d..b8dd962f5 100644 --- a/tablemanager/src/main/java/config/Hongmeng.java +++ b/tablemanager/src/main/java/config/SHongmeng.java @@ -6,9 +6,9 @@ import manager.Table; import java.util.Map; @Table(name = "Hongmeng") -public class Hongmeng implements BaseConfig{ +public class SHongmeng implements BaseConfig{ - public static Map hongmengs; + public static Map hongmengs; private int id; @@ -19,10 +19,10 @@ public class Hongmeng implements BaseConfig{ @Override public void init() throws Exception { - hongmengs = STableManager.getConfig(Hongmeng.class); + hongmengs = STableManager.getConfig(SHongmeng.class); } - public Hongmeng getHongmengById(int id){ + public SHongmeng getHongmengById(int id){ return hongmengs.get(id); } diff --git a/tablemanager/src/main/java/config/HongmengUP.java b/tablemanager/src/main/java/config/SHongmengUP.java similarity index 67% rename from tablemanager/src/main/java/config/HongmengUP.java rename to tablemanager/src/main/java/config/SHongmengUP.java index 932eebff2..647e42232 100644 --- a/tablemanager/src/main/java/config/HongmengUP.java +++ b/tablemanager/src/main/java/config/SHongmengUP.java @@ -7,11 +7,11 @@ import java.util.HashMap; import java.util.Map; @Table(name = "HongmengUP") -public class HongmengUP implements BaseConfig{ +public class SHongmengUP implements BaseConfig{ - public static Map hongmengUPs; + public static Map hongmengUPs; - public static Map hongmengUPLevels; + public static Map hongmengUPLevels; private int id; @@ -22,9 +22,9 @@ public class HongmengUP implements BaseConfig{ @Override public void init() throws Exception { - hongmengUPs = STableManager.getConfig(HongmengUP.class); + hongmengUPs = STableManager.getConfig(SHongmengUP.class); hongmengUPLevels = new HashMap<>(); - for (HongmengUP hongmengUP : hongmengUPs.values()) { + for (SHongmengUP hongmengUP : hongmengUPs.values()) { hongmengUPLevels.put(hongmengUP.getHongmengLevel(), hongmengUP); } }