Fixing lucky displays

This commit is contained in:
nossr50 2019-01-27 19:00:48 -08:00
parent 5f39a7cb80
commit be9aeacd70
2 changed files with 23 additions and 3 deletions

View File

@ -3,11 +3,13 @@ package com.gmail.nossr50.util.random;
public class RandomChanceStatic implements RandomChanceExecution {
private final double xPos;
private final double probabilityCap;
private final boolean isLucky;
public RandomChanceStatic(double xPos)
public RandomChanceStatic(double xPos, boolean isLucky)
{
this.xPos = xPos;
this.probabilityCap = xPos;
this.isLucky = isLucky;
}
/**
@ -30,4 +32,8 @@ public class RandomChanceStatic implements RandomChanceExecution {
public double getProbabilityCap() {
return probabilityCap;
}
public boolean isLucky() {
return isLucky;
}
}

View File

@ -123,6 +123,15 @@ public class RandomChanceUtil
*/
public static double getRandomChanceExecutionChance(RandomChanceExecution randomChance) {
double chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), randomChance.getProbabilityCap(), LINEAR_CURVE_VAR);
return chanceOfSuccess;
}
public static double getRandomChanceExecutionChance(RandomChanceStatic randomChance) {
double chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), randomChance.getProbabilityCap(), LINEAR_CURVE_VAR);
chanceOfSuccess = addLuck(randomChance.isLucky(), chanceOfSuccess);
return chanceOfSuccess;
}
@ -262,15 +271,18 @@ public class RandomChanceUtil
}
public static String[] calculateAbilityDisplayValuesStatic(Player player, PrimarySkillType primarySkillType, double chance) {
RandomChanceStatic rcs = new RandomChanceStatic(chance);
RandomChanceStatic rcs = new RandomChanceStatic(chance, false);
double successChance = getRandomChanceExecutionChance(rcs);
RandomChanceStatic rcs_lucky = new RandomChanceStatic(chance, true);
double successChance_lucky = getRandomChanceExecutionChance(rcs_lucky);
String[] displayValues = new String[2];
boolean isLucky = Permissions.lucky(player, primarySkillType);
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
displayValues[1] = isLucky ? percent.format(Math.min(successChance * 1.3333D, 100.0D) / 100.0D) : null;
displayValues[1] = isLucky ? percent.format(Math.min(successChance_lucky, 100.0D) / 100.0D) : null;
return displayValues;
}
@ -280,6 +292,8 @@ public class RandomChanceUtil
successChance *= multiplier; //Currently only used for graceful roll
String[] displayValues = new String[2];
//TODO: Account for lucky in this
boolean isLucky = Permissions.lucky(player, subSkillType.getParentSkill());
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);