心愿抽奖概率修改
parent
2ba57b1a4a
commit
d3425b731f
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue