Merge branch 'master_test_hw' of http://60.1.1.230/backend/jieling_server into master_test_hw

lvxinran 2020-09-10 16:25:09 +08:00
commit 77098ce6a1
2 changed files with 33 additions and 4 deletions

View File

@ -105,6 +105,9 @@ public class MathUtils {
return Math.round(num);
}
public static long numRount(double num){
return Math.round(num);
}
/**
* >=min <= max
*
@ -368,10 +371,36 @@ public class MathUtils {
return result;
}
/**
*
* to fix zsx
* <li>
* When a {@code double} must be used as a source for a
* {@code BigDecimal}, note that this constructor provides an
* exact conversion; it does not give the same result as
* converting the {@code double} to a {@code String} using the
* {@link Double#toString(double)} method and then using the
* {@link #BigDecimal(String)} constructor. To get that result,
* use the {@code static} {@link #valueOf(double)} method.
* </ol>
* @param d1
* @param d2
* @return
*/
public static double doubleAdd(double d1 ,double d2){
BigDecimal b1 = new BigDecimal(Double.toString(d1));
BigDecimal b2 = new BigDecimal(Double.toString(d2));
BigDecimal b1 = new BigDecimal(String.valueOf(d1));
BigDecimal b2 = new BigDecimal(String.valueOf(d2));
return b1.add(b2).doubleValue();
}
public static double doubleSubtract(double d1 ,double d2){
BigDecimal b1 = new BigDecimal(String.valueOf(d1));
BigDecimal b2 = new BigDecimal(String.valueOf(d2));
return b1.subtract(b2).doubleValue();
}
public static double floatToDouble(float f){
return Double.parseDouble(Float.toString(f));
}
}

View File

@ -448,7 +448,7 @@ public class ItemUtil {
if (sRewardItem.getRandomMin() == sRewardItem.getRandomMax()) {
itemNum = sRewardItem.getRandomMin();
}else {
itemNum = MathUtils.numRount(MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()) * sRewardItem.getGrowChance());
itemNum =(int) MathUtils.numRount(MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()) * MathUtils.floatToDouble(sRewardItem.getGrowChance()));
}
//权重加成 1等级权重加成
@ -481,7 +481,7 @@ public class ItemUtil {
private static void getMap(int itemId ,int itemNum, Map<Integer, Integer> itemMap,
Map<Integer, Integer> cardMap,Map<Integer,Integer> equipMap ,Map<Integer,Integer> randomMap,float dropRatio) throws ErrorCodeException{
Map<Integer, Integer> mapRe = getMapRe(itemId, itemMap, cardMap, equipMap, randomMap);
putcountMap(itemId,MathUtils.numRount((itemNum * dropRatio)) , mapRe);
putcountMap(itemId,(int)MathUtils.numRount((itemNum * MathUtils.floatToDouble(dropRatio))) , mapRe);
}
public static Map<Integer, Integer> getMapRe(int itemId, Map<Integer, Integer> itemMap,