mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Fixing lucky displays
This commit is contained in:
parent
5f39a7cb80
commit
be9aeacd70
@ -3,11 +3,13 @@ package com.gmail.nossr50.util.random;
|
|||||||
public class RandomChanceStatic implements RandomChanceExecution {
|
public class RandomChanceStatic implements RandomChanceExecution {
|
||||||
private final double xPos;
|
private final double xPos;
|
||||||
private final double probabilityCap;
|
private final double probabilityCap;
|
||||||
|
private final boolean isLucky;
|
||||||
|
|
||||||
public RandomChanceStatic(double xPos)
|
public RandomChanceStatic(double xPos, boolean isLucky)
|
||||||
{
|
{
|
||||||
this.xPos = xPos;
|
this.xPos = xPos;
|
||||||
this.probabilityCap = xPos;
|
this.probabilityCap = xPos;
|
||||||
|
this.isLucky = isLucky;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,4 +32,8 @@ public class RandomChanceStatic implements RandomChanceExecution {
|
|||||||
public double getProbabilityCap() {
|
public double getProbabilityCap() {
|
||||||
return probabilityCap;
|
return probabilityCap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLucky() {
|
||||||
|
return isLucky;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,15 @@ public class RandomChanceUtil
|
|||||||
*/
|
*/
|
||||||
public static double getRandomChanceExecutionChance(RandomChanceExecution randomChance) {
|
public static double getRandomChanceExecutionChance(RandomChanceExecution randomChance) {
|
||||||
double chanceOfSuccess = getChanceOfSuccess(randomChance.getXPos(), randomChance.getProbabilityCap(), LINEAR_CURVE_VAR);
|
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;
|
return chanceOfSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,15 +271,18 @@ public class RandomChanceUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String[] calculateAbilityDisplayValuesStatic(Player player, PrimarySkillType primarySkillType, double chance) {
|
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);
|
double successChance = getRandomChanceExecutionChance(rcs);
|
||||||
|
|
||||||
|
RandomChanceStatic rcs_lucky = new RandomChanceStatic(chance, true);
|
||||||
|
double successChance_lucky = getRandomChanceExecutionChance(rcs_lucky);
|
||||||
|
|
||||||
String[] displayValues = new String[2];
|
String[] displayValues = new String[2];
|
||||||
|
|
||||||
boolean isLucky = Permissions.lucky(player, primarySkillType);
|
boolean isLucky = Permissions.lucky(player, primarySkillType);
|
||||||
|
|
||||||
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
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;
|
return displayValues;
|
||||||
}
|
}
|
||||||
@ -280,6 +292,8 @@ public class RandomChanceUtil
|
|||||||
successChance *= multiplier; //Currently only used for graceful roll
|
successChance *= multiplier; //Currently only used for graceful roll
|
||||||
String[] displayValues = new String[2];
|
String[] displayValues = new String[2];
|
||||||
|
|
||||||
|
//TODO: Account for lucky in this
|
||||||
|
|
||||||
boolean isLucky = Permissions.lucky(player, subSkillType.getParentSkill());
|
boolean isLucky = Permissions.lucky(player, subSkillType.getParentSkill());
|
||||||
|
|
||||||
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
displayValues[0] = percent.format(Math.min(successChance, 100.0D) / 100.0D);
|
||||||
|
Loading…
Reference in New Issue
Block a user