掉落组修改

back_recharge
lvxinran 2021-04-17 18:01:30 +08:00
parent 1b4a0f6386
commit 0f43fb3888
2 changed files with 29 additions and 1 deletions

View File

@ -6,7 +6,7 @@ public interface GlobalItemType {
int WEIGHT_DROP = 2; //随机掉落 int WEIGHT_DROP = 2; //随机掉落
int SUCCESSIVELY_RANDOM = 3; // 依次随机 int SUCCESSIVELY_RANDOM = 3; // 依次随机
int SELETEONE = 4; //n 选1 int SELETEONE = 4; //n 选1
int NO_REPEATED_FIX_COUNT = 5;//按照物品在组内的占比出(不可重复)
// 物品类型 // 物品类型
int GEM = 3; // 钻石Id(充值获得) int GEM = 3; // 钻石Id(充值获得)
int ITEM = 0; //道具 int ITEM = 0; //道具
@ -32,6 +32,7 @@ public interface GlobalItemType {
int SELECTSecretBox=20; // 自选宝箱(前端要区分) int SELECTSecretBox=20; // 自选宝箱(前端要区分)
int SpecialMonster=21; // 灵兽 int SpecialMonster=21; // 灵兽
int SpecialMonsterItem=22; // 灵兽碎片 int SpecialMonsterItem=22; // 灵兽碎片
int HeroUpItem = 25;//进阶狗粮
//物品使用类型 //物品使用类型
int NO_USE = 0 ; //不使用 int NO_USE = 0 ; //不使用
int RANDOM_USE = 1; // 随机使用 int RANDOM_USE = 1; // 随机使用

View File

@ -414,6 +414,9 @@ public class ItemUtil {
case GlobalItemType.SUCCESSIVELY_RANDOM: case GlobalItemType.SUCCESSIVELY_RANDOM:
getSuccessivelyRandmoMap(user,sRewardGroup,rewards,weights,itemObj,dropRatio); getSuccessivelyRandmoMap(user,sRewardGroup,rewards,weights,itemObj,dropRatio);
break; break;
case GlobalItemType.NO_REPEATED_FIX_COUNT:
getFixRandomMap(user,sRewardGroup.getRewardMaxNum(),rewards,weights,itemObj,dropRatio);
break;
default: default:
break; break;
} }
@ -457,6 +460,29 @@ public class ItemUtil {
getMap(sRewardItem.getItemId(),itemNum, itemObj,dropRatio); getMap(sRewardItem.getItemId(),itemNum, itemObj,dropRatio);
} }
} }
private static void getFixRandomMap(User user,int randomItemNum ,String[] rewardArr,String[] weightArr,ItemMap itemObj,float dropRatio)throws ErrorCodeException {
if(rewardArr.length!=weightArr.length||randomItemNum>rewardArr.length){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
int[][] randomArray = new int[rewardArr.length][];
for(int i = 0 ; i <rewardArr.length;i++){
int[] tempArray = new int[2];
tempArray[0] =Integer.valueOf(rewardArr[i]);
tempArray[1] =Integer.valueOf(weightArr[i]);
randomArray[i] = tempArray;
}
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){
continue;
}
getMap(sRewardItem.getItemId(),itemNum, itemObj,dropRatio);
}
}
/** /**
* *
@ -543,6 +569,7 @@ public class ItemUtil {
case GlobalItemType.RIDE: case GlobalItemType.RIDE:
case GlobalItemType.SELECTSecretBox: case GlobalItemType.SELECTSecretBox:
case GlobalItemType.SpecialMonsterItem: case GlobalItemType.SpecialMonsterItem:
case GlobalItemType.HeroUpItem:
itemType = GlobalItemType.ITEM; itemType = GlobalItemType.ITEM;
break; break;
default: default: