diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java index f5a792a39..dbdafac43 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java @@ -92,7 +92,7 @@ public class ItemUtil { addCard(user, itemObj.getCardMap(), dropBuilder,reason); addEquip(user, itemObj.getEquipMap(), dropBuilder,reason); addSpecialMonster(user,itemObj,dropBuilder,reason); - addMagicSoldier(user,itemObj.getMagicSoldierMap(),dropBuilder,reason); + addMagicSoldier(user,itemObj.getMagicSoldierMap(),dropBuilder); } @@ -151,14 +151,13 @@ public class ItemUtil { return dropBuilder; } - public static int dropByMail(User user, int[][] itemArr,CommonProto.Drop.Builder dropBuilder,int reason) throws Exception { - ItemMap itemObj = new ItemMap(); - - selectItemArr(itemArr,itemObj); - int ints = addItemByMail(user, itemObj.getItemMap(), dropBuilder, reason); - maptoAddWithOutItem(user,itemObj,dropBuilder,reason); - return ints; - } +// public static int dropByMail(User user, int[][] itemArr,CommonProto.Drop.Builder dropBuilder,int reason) throws Exception { +// ItemMap itemObj = new ItemMap(); +// selectItemArr(itemArr,itemObj); +// int ints = addItemByMail(user, itemObj.getItemMap(), dropBuilder, reason); +// maptoAddWithOutItem(user,itemObj,dropBuilder,reason); +// return ints; +// } public static int dropByMail(User user, long[][] itemArr,CommonProto.Drop.Builder dropBuilder,int reason) throws Exception { ItemMap itemObj = new ItemMap(); @@ -304,7 +303,7 @@ public class ItemUtil { return getReward(itemObj); } - public static String getMailRewardLong (List itemArrs) throws Exception { + public static String getMailRewardLong (List itemArrs) { ItemMap itemObj = new ItemMap(); for(long[][] itemArr : itemArrs){ selectLongItemArr(itemArr,itemObj); @@ -322,9 +321,14 @@ public class ItemUtil { /** * 主线挂机奖励 - * @throws ErrorCodeException */ public static void combineRewardByMainLine(User user,boolean isLoop,boolean fiexdOrRandom, int[] dropGroupIds,int time,ItemMap itemObj,int reason)throws ErrorCodeException{ + combineReward(user, fiexdOrRandom, dropGroupIds, time, itemObj); + // 特权加成奖励 + extraAddItem(user,itemObj.getItemMap(),reason); + } + + private static void combineReward(User user, boolean fiexdOrRandom, int[] dropGroupIds, int time, ItemMap itemObj) throws ErrorCodeException { for (int id:dropGroupIds){ SRewardGroup sRewardGroup = SRewardGroup.getsRewardItemMap().get(id); // 次数 @@ -345,38 +349,16 @@ public class ItemUtil { combineRewardDropGroup(user, new int[]{id}, 1,itemObj); } } - // 特权加成奖励 - extraAddItem(user,itemObj.getItemMap(),reason); } /** * 主线挂机奖励,避免循环 - * @throws ErrorCodeException */ public static void combineRewardByMainLine(User user,boolean isLoop,boolean fiexdOrRandom, List groupList,ItemMap itemObj,int reason)throws ErrorCodeException{ for (int[][] list : groupList) { int[] groups = list[0]; int time = list[1][0]; - for (int id:groups){ - SRewardGroup sRewardGroup = SRewardGroup.getsRewardItemMap().get(id); - // 次数 - long num = time / sRewardGroup.getDrapRate(); - // 基础奖励和随机奖励 - if (fiexdOrRandom){ - combineRewardDropGroup(user, new int[]{id}, num,itemObj); - }else { - while (num-->0){ - combineRewardDropGroup(user, new int[]{id}, 1,itemObj); - } - } - // 不足掉落的时间,看脸随机 - int remainder = time % sRewardGroup.getDrapRate(); - // 1-掉落时间,随机数值 - int random = MathUtils.random(1, sRewardGroup.getDrapRate()); - if (random <= remainder){ - combineRewardDropGroup(user, new int[]{id}, 1,itemObj); - } - } + combineReward(user, fiexdOrRandom, groups, time, itemObj); } // 特权加成奖励 extraAddItem(user,itemObj.getItemMap(),reason); @@ -404,9 +386,9 @@ public class ItemUtil { } } - public static void combineReward(int[][] itemArr,ItemMap itemObj)throws ErrorCodeException{ - selectItemArr(itemArr,itemObj); - } +// public static void combineReward(int[][] itemArr,ItemMap itemObj) { +// selectItemArr(itemArr,itemObj); +// } public static void drop(User user,CommonProto.Drop.Builder dropBuilder,ItemMap itemObj,int reason) throws Exception { // useRandomItem(user, randomMap, reason); @@ -450,19 +432,19 @@ public class ItemUtil { return reward.toString(); } - private static void selectItemArr(int[][] itemArr,ItemMap itemObj) throws ErrorCodeException{ + private static void selectItemArr(int[][] itemArr,ItemMap itemObj) { for (int[] items : itemArr){ getMap(items[0],items[1],itemObj,1); } } - private static void selectItemArr(int[][] itemArr,ItemMap itemObj,float count) throws ErrorCodeException{ + private static void selectItemArr(int[][] itemArr,ItemMap itemObj,float count) { for (int[] items : itemArr){ getMap(items[0],items[1],itemObj,count); } } - private static void selectLongItemArr(long[][] itemArr,ItemMap itemObj) throws ErrorCodeException{ + private static void selectLongItemArr(long[][] itemArr,ItemMap itemObj) { for (long[] items : itemArr){ getMap((int)items[0],items[1],itemObj,1); } @@ -511,7 +493,7 @@ public class ItemUtil { } } - private static void getSuccessivelyRandmoMap(User user,SRewardGroup sRewardGroup, String[] rewardArr, String[] weightArr,ItemMap itemObj, float dropRatio) throws ErrorCodeException { + private static void getSuccessivelyRandmoMap(User user,SRewardGroup sRewardGroup, String[] rewardArr, String[] weightArr,ItemMap itemObj, float dropRatio) { for (int i = 0; i < sRewardGroup.getRewardMaxNum(); i++) { int id = 0; for (int j = 0; j < sRewardGroup.getLoop(); j++) { @@ -534,7 +516,7 @@ public class ItemUtil { } } - private static void getRandomMap(User user,int randomItemNum ,String[] rewardArr,String[] weightArr,ItemMap itemObj,float dropRatio)throws ErrorCodeException { + private static void getRandomMap(User user,int randomItemNum ,String[] rewardArr,String[] weightArr,ItemMap itemObj,float dropRatio) { for (int i = 0 ; i < randomItemNum;i++){ int index = MathUtils.randomForStrArray(weightArr); if (index == -1) { @@ -563,19 +545,18 @@ public class ItemUtil { } int[] randomResult = MathUtils.randomFromWeightWithTaking(randomArray,randomItemNum); - for (int i = 0 ; i < randomResult.length;i++){ - SRewardItem sRewardItem = SRewardItem.getsDropMap().get(randomResult[i]); - int itemNum = getItemNum(user,sRewardItem); - if (itemNum <= 0){ + for (int j : randomResult) { + SRewardItem sRewardItem = SRewardItem.getsDropMap().get(j); + int itemNum = getItemNum(user, sRewardItem); + if (itemNum <= 0) { continue; } - getMap(sRewardItem.getItemId(),itemNum, itemObj,dropRatio); + getMap(sRewardItem.getItemId(), itemNum, itemObj, dropRatio); } } /** * 成长百分比 - * @return */ private static int getItemNum(User user,SRewardItem sRewardItem) { int itemNum ; @@ -598,7 +579,7 @@ public class ItemUtil { return itemNum; } - private static void getMap(User user,int[] itemInfo,ItemMap itemObj,float dropRatio) throws ErrorCodeException{ + private static void getMap(User user,int[] itemInfo,ItemMap itemObj,float dropRatio) { for (int id :itemInfo){ SRewardItem sRewardItem = SRewardItem.getsDropMap().get(id); int itemNum = getItemNum(user,sRewardItem); @@ -691,17 +672,14 @@ public class ItemUtil { } private static void putCountMap(int itemId,int itemNum, Map map) { - map.merge(itemId, itemNum, (a, b) -> b + a); + map.merge(itemId, itemNum, Integer::sum); } private static void putCountLongMap(int itemId,long itemNum, Map map) { - map.merge(itemId, itemNum, (a, b) -> b + a); + map.merge(itemId, itemNum, Long::sum); } /** * 添加道具 - * @param user - * @param itemMap - * @throws Exception */ public static void addItem(User user, Map itemMap,CommonProto.Drop.Builder dropBuilder,int reason) throws Exception { addItemByMail(user,itemMap,dropBuilder,reason); @@ -709,9 +687,6 @@ public class ItemUtil { /** * 添加道具 - * @param user - * @param itemMap - * @throws Exception */ public static int addItemByMail(User user, Map itemMap,CommonProto.Drop.Builder dropBuilder,int reason) throws Exception { if (itemMap.isEmpty()) { @@ -856,9 +831,6 @@ public class ItemUtil { /** * 发送装备图鉴修改推送 - * @param _uid - * @param _itemManage - * @param _equipList */ private static void SendEquipBookIndication(int _uid,ItemManager _itemManage, List_equipList){ if (_equipList==null||_equipList.isEmpty())return; @@ -979,7 +951,6 @@ public class ItemUtil { /** * 孙龙宝藏升级 //zsx 保留 TODO 由事件分发到 Activitylogic 去处理 - * @param user */ public static void treasureLevelUp(User user) throws Exception { @@ -992,7 +963,7 @@ public class ItemUtil { if (levelConfig != null) { //需要先确定下每级真实需要的经验,与客户端实现方式同步,认为表里填的升到下一级所需经验是前边各级经验总和 int[][] integral = levelConfig.getIntegral(); - if(integral==null||integral.length<=0||integral[0].length<=0){ + if(integral==null|| integral.length == 0 || integral[0].length == 0){ return; } STreasureSunlongConfig lastLevelConfig = STreasureSunlongConfig.levelTreasureConfigMap.get(activity.getId()).get(levelConfig.getLevel() - 1); @@ -1113,12 +1084,6 @@ public class ItemUtil { /** * type = 1获得 2 消耗 - * @param user - * @param itemId - * @param itemNum - * @param type - * @param reason - * @throws Exception */ public static void baseItemReport(User user,int itemId,int itemNum,int type,int reason) throws Exception { ReportEventEnum item; @@ -1201,9 +1166,6 @@ public class ItemUtil { /** * 添加装备(特指 宝器,法相等,(帽,衣,裤,鞋)基础装备算道具) - * @param user - * @param equipMap - * @param dropBuilder */ public static void addEquip(User user, Map equipMap, CommonProto.Drop.Builder dropBuilder,int reason) throws Exception { if (equipMap == null || equipMap.isEmpty()) { @@ -1333,10 +1295,6 @@ public class ItemUtil { /** * 添加卡牌 - * @param user - * @param cardMap - * @param dropBuilder - * @throws Exception */ public static void addCard(User user,Map cardMap,CommonProto.Drop.Builder dropBuilder,int reason) throws Exception { if (cardMap.isEmpty()) { @@ -1410,10 +1368,8 @@ public class ItemUtil { * 真充券: 只获得对应金额的妖晶和名望经验 * 现金卡: 计入游戏内所有累计充值的活动,不计入单笔充值和直购类活动 * 仙充卡(用gm扶持): 计入游戏内所有累计充值的活动和单笔充值活动,不计入直购类活动 - * @param user - * @return */ - public static boolean rmbItemHandler(User user, CommonProto.Item item) throws ErrorCodeException { + public static void rmbItemHandler(User user, CommonProto.Item item) throws ErrorCodeException { SItem sItem = SItem.getsItemMap().get(item.getItemId()); HashSet integers = new HashSet<>(); @@ -1421,7 +1377,7 @@ public class ItemUtil { integers.add(GlobalItemType.DAY_TRUE_RECHARGE_JUAN); if (!rmbItemSet.contains(sItem.getItemType()) && !integers.contains(sItem.getItemType())){ - return false; + return; } NewRechargeInfo info = user.getPlayerInfoManager().getNewRechargeInfo(); int num = sItem.getExtraReward()[1][0]; @@ -1440,7 +1396,6 @@ public class ItemUtil { // 线下自动返利 Poster.getPoster().dispatchEvent(new AutoRechargeBackEvent(user.getId(), (int)totalNum, GmActivityLogic.item_token)); } - return true; } public static void addCard(User user,int cardId,List heroList,int reason) throws Exception { @@ -1477,10 +1432,6 @@ public class ItemUtil { /** * 消耗道具 - * @param user - * @param costItems - * @return - * @throws Exception */ public static boolean itemCost(User user,int[][] costItems,int reason,int subReson) throws Exception { Map itemMap = new HashMap<>(); @@ -1495,9 +1446,6 @@ public class ItemUtil { /** * 消耗道具 - * @param user - * @return - * @throws Exception */ public static boolean itemCost(User user,List itemArrs,int reason,int subReson) throws Exception { Map itemMap = new HashMap<>(); @@ -1630,10 +1578,6 @@ public class ItemUtil { /** * 使用随机物品 - * @param user - * @param randomMap - * @return - * @throws Exception */ public static CommonProto.Drop.Builder useRandomItem(User user,Map randomMap,int reason) throws Exception { StringBuilder dropIds = new StringBuilder(); @@ -1643,12 +1587,12 @@ public class ItemUtil { SItem sItem = SItem.getsItemMap().get(itemId); int[] rewardGroup = sItem.getRewardGroup(); for (int i = 0; i < itemNum; i++){ - for (int j = 0; j < rewardGroup.length ; j++) { - if (dropIds.length() == 0){ + for (int k : rewardGroup) { + if (dropIds.length() == 0) { dropIds = new StringBuilder(); - dropIds.append(rewardGroup[j]); - }else{ - dropIds.append("#").append(rewardGroup[j]); + dropIds.append(k); + } else { + dropIds.append("#").append(k); } } @@ -1664,11 +1608,6 @@ public class ItemUtil { /** * 分解,合成 使用 道具消耗检验 - * @param user - * @param sItem - * @param itemNum - * @return - * @throws Exception */ public static boolean checkCost(User user ,SItem sItem , int itemNum,int reason,int subReason) throws Exception { if (sItem == null){ @@ -1723,9 +1662,6 @@ public class ItemUtil { /** * 战斗消耗校验 - * @param user - * @param costItems - * @return */ public static boolean fightItemCost(User user,int[][] costItems) throws Exception { Map itemMap = new HashMap<>(); @@ -1736,44 +1672,38 @@ public class ItemUtil { /** * 检测卡牌和道具上限 * 2021-1-25:装备属于道具一种,所以不再另作处理,做默认 - * @param user - * @param itemArr - * @return */ - public static int checkCardAndEquipLimit( User user ,int[][] itemArr) { - int result = 0; - - SGameSetting gameSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting(); - Map itemTypeMap = getItemTypeMap(itemArr); - for (Map.Entry entry : itemTypeMap.entrySet()) { - if (entry.getKey() == GlobalItemType.CARD){ - int hasHeroNum = user.getHeroManager().getHeroMap().size(); - // 英雄数量超最大上限 - if (hasHeroNum+entry.getValue() > gameSetting.getHeroNumlimit()){ - result++; - } - } - } - - // 道具校验 - for(int[] ints:itemArr){ - Item item = user.getItemManager().getItem(ints[0]); - SItem sItem = SItem.getsItemMap().get(ints[0]); - //数量超过了 - if (item!=null&&item.getItemNum()+ints[1] > sItem.getItemNumlimit()){ - result++; - } - } - - return result; - } +// public static int checkCardAndEquipLimit( User user ,int[][] itemArr) { +// int result = 0; +// +// SGameSetting gameSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting(); +// Map itemTypeMap = getItemTypeMap(itemArr); +// for (Map.Entry entry : itemTypeMap.entrySet()) { +// if (entry.getKey() == GlobalItemType.CARD){ +// int hasHeroNum = user.getHeroManager().getHeroMap().size(); +// // 英雄数量超最大上限 +// if (hasHeroNum+entry.getValue() > gameSetting.getHeroNumlimit()){ +// result++; +// } +// } +// } +// +// // 道具校验 +// for(int[] ints:itemArr){ +// Item item = user.getItemManager().getItem(ints[0]); +// SItem sItem = SItem.getsItemMap().get(ints[0]); +// //数量超过了 +// if (item!=null&&item.getItemNum()+ints[1] > sItem.getItemNumlimit()){ +// result++; +// } +// } +// +// return result; +// } /** * 检测卡牌和道具上限 * 2021-1-25:装备属于道具一种,所以不再另作处理,做默认 - * @param user - * @param itemArr - * @return */ public static int checkCardAndEquipLimit(User user ,long[][] itemArr) { int result = 0; @@ -1809,25 +1739,23 @@ public class ItemUtil { * @param itemArr * @return */ - public static Map getItemTypeMap(int[][] itemArr){ - Map itemTypeMap = new HashMap<>(); - for (int[] ints : itemArr) { - int itemId = ints[0]; - SItem sItem = SItem.getsItemMap().get(itemId); - int itemType = getItemType(sItem); - if(itemTypeMap.containsKey(itemType)){ - itemTypeMap.put(itemType,itemTypeMap.get(itemType)+ints[1]); - }else{ - itemTypeMap.put(itemType,ints[1]); - } - } - return itemTypeMap; - } +// public static Map getItemTypeMap(int[][] itemArr){ +// Map itemTypeMap = new HashMap<>(); +// for (int[] ints : itemArr) { +// int itemId = ints[0]; +// SItem sItem = SItem.getsItemMap().get(itemId); +// int itemType = getItemType(sItem); +// if(itemTypeMap.containsKey(itemType)){ +// itemTypeMap.put(itemType,itemTypeMap.get(itemType)+ints[1]); +// }else{ +// itemTypeMap.put(itemType,ints[1]); +// } +// } +// return itemTypeMap; +// } /** * 获取物品种类map - * @param itemArr - * @return */ public static Map getItemTypeMap(long[][] itemArr){ Map itemTypeMap = new HashMap<>(); @@ -1846,9 +1774,6 @@ public class ItemUtil { /** * 特权加成收益计算 - * @param user - * @param itemMap - * @return */ public static void privilegeAddToMainLevelChallenge(User user, ItemMap itemMap){ HashMap map = new HashMap<>(); @@ -1862,10 +1787,6 @@ public class ItemUtil { /** * 挑战奖励加成 - * @param user - * @param itemId - * @param sourceNum - * @return */ private static long challengeRewardNum(User user,int itemId,long sourceNum){ switch (itemId){ @@ -1886,11 +1807,6 @@ public class ItemUtil { /** * 特权加成收益计算 - * @param user - * @param reason - * @param itemId - * @param sourceNum - * @return */ public static long privilegeAdd(User user,int reason,int itemId,long sourceNum){ // 基础奖励,挂机 @@ -1906,10 +1822,6 @@ public class ItemUtil { /** * 挂机基础奖励加成 - * @param user - * @param itemType - * @param sourceNum - * @return */ private static long baseReward(User user,int itemType,long sourceNum){ switch (itemType){ @@ -1935,10 +1847,6 @@ public class ItemUtil { /** * 挂机随机奖励加成 - * @param user - * @param itemType - * @param sourceNum - * @return */ private static long randomReward(User user,int itemType,long sourceNum){ switch (itemType){ @@ -2048,13 +1956,8 @@ public class ItemUtil { /** * 掉落神兵 - * @param user - * @param map - * @param dropBuilder - * @param reason - * @throws Exception */ - private static void addMagicSoldier(User user,Map map,CommonProto.Drop.Builder dropBuilder,int reason) throws Exception { + private static void addMagicSoldier(User user,Map map,CommonProto.Drop.Builder dropBuilder) { if(map == null || map.isEmpty()){ return; } @@ -2064,15 +1967,6 @@ public class ItemUtil { MagicSoldier soldier = new MagicSoldier(user.getId(), entry.getKey()); manager.setMagicSoldier(soldier); dropBuilder.addMagicSoldier(CBean2Proto.toBeanMagicSoldier(soldier)); - try { -// ReportUtil.onReportEvent(user,ReportEventEnum.GET_BEAST.getType(),entry.getKey(),animal.getQuality(),reason); -// if (animal.getQuality() >= SSpecialConfig.getIntegerValue(SSpecialConfig.ANIMAL_BROADCAST_QUALITY)) { //策划资质改成星级 -// String nameColor = user.getPlayerInfoManager().getNameColor(); -// String message = SErrorCodeEerverConfig.getI18NMessageNeedConvert("animal_get_broadcast_content", -// new Object[]{nameColor,user.getPlayerInfoManager().getNickName(), animal.getName()}, new int[]{0,0,1}); -// ChatLogic.getInstance().sendSysChatMessage(message,Global.LUCKY_LUCK,"0",0,0,0,0,0); -// } - }catch (Exception e){} } } }