心愿抽奖概率修改

back_recharge
duhui 2021-07-06 09:30:26 +08:00
parent 2ba57b1a4a
commit d3425b731f
1 changed files with 3 additions and 4 deletions

View File

@ -450,9 +450,8 @@ public class HeroLogic{
if (map.isEmpty() || weight == 0){
return item;
}
int sum = map.values().stream().mapToInt(Integer::intValue).sum();
int randomInt = MathUtils.randomInt(sum);
int randomInt = MathUtils.randomInt(weight);
// 遍历权重
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
@ -476,7 +475,7 @@ public class HeroLogic{
return result;
}
// 权重递减
anInt-=entry.getValue();
randomInt-=entry.getValue();
}
return item;
}