From a6a71fa7c0d760c1d2039b98e63387a76e152639 Mon Sep 17 00:00:00 2001 From: duhui Date: Wed, 17 Mar 2021 15:30:01 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A4=A7=E9=97=B9=E5=A4=A9=E5=AE=AB,?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=80=AA=E7=89=A9=E9=98=B5=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ljsd/jieling/logic/rank/RankLogic.java | 13 ++++++++++--- .../src/main/java/config/SExpeditionSetting.java | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/rank/RankLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/rank/RankLogic.java index 52dda4de7..371fff797 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/rank/RankLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/rank/RankLogic.java @@ -15,6 +15,8 @@ import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank; import com.ljsd.jieling.network.server.GlobalidHelper; import com.ljsd.jieling.network.server.WorldHelper; import com.ljsd.jieling.network.session.ISession; +import config.SExpeditionSetting; +import manager.STableManager; import rpc.protocols.CommonProto; import rpc.protocols.MessageTypeProto; import rpc.protocols.PlayerInfoProto; @@ -28,8 +30,10 @@ import util.MathUtils; import util.TimeUtils; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @author lvxinran @@ -132,6 +136,7 @@ public class RankLogic { * @throws Exception */ public List> getRandomUserByRank(User user,int counts) throws Exception { + List> result = new ArrayList<>(); // 获取排行信息 PlayerInfoProto.RankResponse rankResponse = getRankInfo(user,1,50); // 计时器 @@ -139,10 +144,12 @@ public class RankLogic { int rankSize = rankResponse.getRanksCount(); if (rankSize <= 0){ - throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"战力排行榜暂无数据,没有人上榜"); + // 排行榜没有玩家,走默认表配置 + int[] defaults = STableManager.getConfig(SExpeditionSetting.class).get(1).getDefaultLineup(); + List collect = Arrays.stream(defaults).boxed().collect(Collectors.toList()); + result.add(collect); + return result; } - - List> result = new ArrayList<>(); // 计数器 int count = 0; do { diff --git a/tablemanager/src/main/java/config/SExpeditionSetting.java b/tablemanager/src/main/java/config/SExpeditionSetting.java index 1511ee04a..7e63a4a2c 100644 --- a/tablemanager/src/main/java/config/SExpeditionSetting.java +++ b/tablemanager/src/main/java/config/SExpeditionSetting.java @@ -36,6 +36,8 @@ public class SExpeditionSetting implements BaseConfig { private int[][] playerLevelfix; private int specialReward; + + private int[] defaultLineup; @Override public void init() throws Exception { @@ -106,4 +108,8 @@ public class SExpeditionSetting implements BaseConfig { public int getSpecialReward() { return specialReward; } + + public int[] getDefaultLineup() { + return defaultLineup; + } } \ No newline at end of file From 7a3075ffe93814ec29f92dcbfe0df170919eaa95 Mon Sep 17 00:00:00 2001 From: duhui Date: Wed, 17 Mar 2021 17:23:41 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A4=A7=E9=97=B9=E5=A4=A9=E5=AE=AB,?= =?UTF-8?q?=E6=8B=9B=E5=8B=9F=E8=8B=B1=E9=9B=84=E8=A3=85=E5=A4=87=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Expedition/HeroNodeGetInfoRequestHandler.java | 15 +++++++++++++-- .../ljsd/jieling/logic/dao/ExpeditionManager.java | 12 ++++++------ .../java/com/ljsd/jieling/logic/dao/Jewel.java | 9 +++++++++ .../jieling/logic/expedition/ExpeditionLogic.java | 14 ++++++-------- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/Expedition/HeroNodeGetInfoRequestHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/Expedition/HeroNodeGetInfoRequestHandler.java index d3c2bc60f..f12b55f80 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/Expedition/HeroNodeGetInfoRequestHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/Expedition/HeroNodeGetInfoRequestHandler.java @@ -6,6 +6,7 @@ import com.ljsd.jieling.exception.ErrorCodeException; import com.ljsd.jieling.handler.BaseHandler; import com.ljsd.jieling.logic.dao.ExpeditionNodeInfo; import com.ljsd.jieling.logic.dao.Hero; +import com.ljsd.jieling.logic.dao.PropertyItem; import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.expedition.ExpeditionLogic; @@ -93,20 +94,30 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler { CommonProto.ViewHeroInfo.Builder inner = CommonProto.ViewHeroInfo.newBuilder(); + + // 英雄属性 Map heroNotBufferAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, true, 0); for(Map.Entry item : heroNotBufferAttribute.entrySet()){ inner.addSpecialEffects(CommonProto.SpecialEffects.newBuilder().setPropertyId(item.getKey()).setPropertyValue(item.getValue()).build()); } - for(Integer equipId : hero.getEquipByPositionMap().values()){ + // 装备 + for(Integer equipId : hero.getEquipByPositionMap().values()){ inner.addEquip(CBean2Proto.getEquipProto(equipId)); } + // 大闹天宫装备信息 + Map equipMap = user.getExpeditionManager().getEquipMap(); + // 魂宝,灵宝 + for(String equipId : hero.getJewelInfo()){ + inner.addEquip(CBean2Proto.getEquipProto(equipMap.get(equipId))); + } + // 英雄战力 inner.setForce(HeroLogic.getInstance().calForce(heroNotBufferAttribute)); + // 英雄 inner.setHero(CBean2Proto.getHero(hero)); builder.addViewHeroInfo(inner); user.getExpeditionManager().getGHeroSet().add(hero.getTemplateId()); }); - // nodeInfo.setState(ExpeditionLogic.NODESTATE_HERO); return builder.build(); } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ExpeditionManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ExpeditionManager.java index e6bbebf53..c40ec23d8 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ExpeditionManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ExpeditionManager.java @@ -204,23 +204,23 @@ public class ExpeditionManager extends MongoBase { } - public void addEquip(User user, PropertyItem equip) throws Exception { + public void addEquip(PropertyItem equip){ equip.init(this.getRootId(),getMongoKey() + ".equipMap." + equip.getId()); updateString("equipMap." + equip.getId(), equip); equipMap.put(equip.getId(),equip); } - public void clearEquip() throws Exception { - updateString("equipMap", equipMap); + public void clearEquip(){ equipMap.clear(); + updateString("equipMap", equipMap); } - public void clearEquipToTemp() throws Exception { - updateString("equipMapTemp" , equipMapTemp); + public void clearEquipToTemp(){ equipMapTemp.clear(); + updateString("equipMapTemp" , equipMapTemp); } - public void addEquipToTemp(User user, PropertyItem equip) throws Exception { + public void addEquipToTemp(PropertyItem equip){ equip.init(this.getRootId(),getMongoKey() + ".equipMapTemp." + equip.getId()); updateString("equipMapTemp." + equip.getId(), equip); equipMapTemp.put(equip.getId(),equip); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Jewel.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Jewel.java index ae85a2e6d..74545d301 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Jewel.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/Jewel.java @@ -30,6 +30,15 @@ public class Jewel extends PropertyItem { this.setJewelType(STableManager.getConfig(SJewelConfig.class).get(jewelId).getLocation()); } + public Jewel(int uid,int jewelId,Jewel jewel){ + this.setRootCollection(User._COLLECTION_NAME); + super.setId(KeyGenUtils.produceIdByModule(UUIDEnum.JEWEL, uid)); + this.setEquipId(jewelId); + this.setJewelType(STableManager.getConfig(SJewelConfig.class).get(jewelId).getLocation()); + this.setBuildLevel(jewel.getBuildLevel()); + this.setLevel(jewel.getLevel()); + } + public int getBuildLevel() { return buildLevel; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/expedition/ExpeditionLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/expedition/ExpeditionLogic.java index 2affba23b..de41090ac 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/expedition/ExpeditionLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/expedition/ExpeditionLogic.java @@ -617,7 +617,7 @@ public class ExpeditionLogic { * @param newHero * @param type */ - private static void addExpeditionJewel(User user,Hero newHero,int type) throws Exception { + private static void addExpeditionJewel(User user,Hero newHero,int type){ Set jewelInfo = newHero.getJewelInfo(); if (jewelInfo == null || jewelInfo.size() <= 0){ // 没有魂宝灵宝 @@ -642,15 +642,13 @@ public class ExpeditionLogic { continue; } // 修改装备id为表里类型,1:魂宝,2:灵宝 - if (jewel.getJewelType() == 1){ - jewel.setEquipId(equip[0]); - }else { - jewel.setEquipId(equip[1]); - } + int jewelId = jewel.getJewelType() == 1?equip[0]:equip[1]; + + Jewel jews = new Jewel(user.getId(), jewelId,jewel); // 添加到大闹天宫装备背包,此操作会更新唯一id - user.getExpeditionManager().addEquip(user,jewel); + user.getExpeditionManager().addEquip(jews); // 新的装备id - set.add(jewel.getId()); + set.add(jews.getId()); } newHero.setJewelInfo(set); } From e63d4612c52fd12450d82ff9eda359a8f94a651e Mon Sep 17 00:00:00 2001 From: duhui Date: Wed, 17 Mar 2021 18:27:24 +0800 Subject: [PATCH 3/3] =?UTF-8?q?excel=E5=B7=A5=E5=85=B7=E7=B1=BB=E4=BC=98?= =?UTF-8?q?=E5=8C=96,=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/src/main/java/ExcelUtils.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/src/main/java/ExcelUtils.java b/test/src/main/java/ExcelUtils.java index 5bc88eb96..8871c71ed 100644 --- a/test/src/main/java/ExcelUtils.java +++ b/test/src/main/java/ExcelUtils.java @@ -16,6 +16,9 @@ public class ExcelUtils { public static void main(String[] args) throws Exception { File oldfile = new File(path); + if (!oldfile.exists()&&!oldfile.isDirectory()){ + oldfile.mkdir(); + } String[] list = oldfile.list(); oldFileNames.addAll(Arrays.asList(list)); readExcelData();