Fixed rounding issues regarding skills and also a fix for gold quantity

This commit is contained in:
Gonk
2020-11-09 20:44:01 +01:00
parent 3ca676c57b
commit 6dc33bcac2
2 changed files with 4 additions and 4 deletions

View File

@@ -51,7 +51,7 @@ public final class Constants {
public static final Random rnd = new Random();
public static int rollValue(final ConstRange r) { return rollValue(r.max, r.current); }
public static int rollValue(final ConstRange r, int bias) { return rollValue(r.max, r.current + bias); }
public static int rollValue(final ConstRange r, int bias) { return (int)Math.round(rollValue(r.max * 100, r.current * 100 + bias)/100.0); }
public static int rollValue(final Range r) { return rollValue(r.max, r.current); }
private static int rollValue(final int max, final int min) {
if (max <= min) return max;
@@ -59,7 +59,7 @@ public final class Constants {
}
public static boolean roll100(final int chance) { return rollResult(100, chance); }
public static boolean rollResult(final ConstRange r) { return rollResult(r.max, r.current); }
public static boolean rollResult(final ConstRange r, int bias) { return rollResult(r.max, r.current + bias); }
public static boolean rollResult(final ConstRange r, int bias) { return rollResult(r.max * 100, r.current * 100 + bias); }
public static boolean rollResult(final Range r) { return rollResult(r.max, r.current); }
private static boolean rollResult(final int probabilityMax, final int probabilityValue) { return rnd.nextInt(probabilityMax) < probabilityValue; }
}

View File

@@ -72,7 +72,7 @@ public final class SkillController {
if (player == null) return 0;
if (!ItemTypeCollection.isGoldItemType(item.itemType.id)) return 0;
return getRollBias(item, player, SkillID.coinfinder, SkillCollection.PER_SKILLPOINT_INCREASE_COINFINDER_QUANTITY_PERCENT);
return getRollBias(item.quantity, player, SkillID.coinfinder, SkillCollection.PER_SKILLPOINT_INCREASE_COINFINDER_QUANTITY_PERCENT);
}
private static int getRollBias(DropItem item, Player player, SkillID skill, int perSkillpointIncrease) {
@@ -82,7 +82,7 @@ public final class SkillController {
private static int getRollBias(ConstRange chance, Player player, SkillID skill, int perSkillpointIncrease) {
int skillLevel = player.getSkillLevel(skill);
if (skillLevel <= 0) return 0;
return chance.current * skillLevel * perSkillpointIncrease / 100;
return chance.current * skillLevel * perSkillpointIncrease;
}