master_ob2
PC-202302260912\Administrator 2023-08-02 15:14:48 +08:00
parent de1bc8de1a
commit ee336f0110
1 changed files with 82 additions and 188 deletions

View File

@ -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<long[][]> itemArrs) throws Exception {
public static String getMailRewardLong (List<long[][]> 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<int[][]> 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<Integer, Integer> map) {
map.merge(itemId, itemNum, (a, b) -> b + a);
map.merge(itemId, itemNum, Integer::sum);
}
private static void putCountLongMap(int itemId,long itemNum, Map<Integer, Long> 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<Integer, Long> 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<Integer, Long> 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<Integer>_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<Integer,Integer> 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<Integer,Integer> 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<Integer> 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<CommonProto.Hero> 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<Integer, Integer> itemMap = new HashMap<>();
@ -1495,9 +1446,6 @@ public class ItemUtil {
/**
*
* @param user
* @return
* @throws Exception
*/
public static boolean itemCost(User user,List<int[][]> itemArrs,int reason,int subReson) throws Exception {
Map<Integer, Integer> 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<Integer,Integer> 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<Integer, Integer> 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<Integer, Integer> itemTypeMap = getItemTypeMap(itemArr);
for (Map.Entry<Integer, Integer> 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<Integer, Integer> itemTypeMap = getItemTypeMap(itemArr);
// for (Map.Entry<Integer, Integer> 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<Integer,Integer> getItemTypeMap(int[][] itemArr){
Map<Integer,Integer> 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<Integer,Integer> getItemTypeMap(int[][] itemArr){
// Map<Integer,Integer> 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<Integer,Long> getItemTypeMap(long[][] itemArr){
Map<Integer,Long> itemTypeMap = new HashMap<>();
@ -1846,9 +1774,6 @@ public class ItemUtil {
/**
*
* @param user
* @param itemMap
* @return
*/
public static void privilegeAddToMainLevelChallenge(User user, ItemMap itemMap){
HashMap<Integer, Long> 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<Integer,Integer> map,CommonProto.Drop.Builder dropBuilder,int reason) throws Exception {
private static void addMagicSoldier(User user,Map<Integer,Integer> 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){}
}
}
}