forked from MagicBane/Server
Rework of helper method
This commit is contained in:
@@ -423,27 +423,29 @@ public class WpakPowerManager {
|
|||||||
float scaledValue;
|
float scaledValue;
|
||||||
mbEnums.ModificationType modificationType = mbEnums.ModificationType.ADD;
|
mbEnums.ModificationType modificationType = mbEnums.ModificationType.ADD;
|
||||||
|
|
||||||
// Method scales by either integer or float values driven by the curve type
|
// Only subset of these used for percent heals and such
|
||||||
|
// are multiplicative. Everything else is additive.
|
||||||
|
|
||||||
if (EnumSet.of(mbEnums.ModType.Health, mbEnums.ModType.Mana,
|
if (EnumSet.of(mbEnums.ModType.Health, mbEnums.ModType.Mana,
|
||||||
mbEnums.ModType.Stamina).contains(modifierEntry.type))
|
mbEnums.ModType.Stamina).contains(modifierEntry.type))
|
||||||
if (modifierEntry.percentage == 0)
|
if (modifierEntry.percentage == 0)
|
||||||
modificationType = mbEnums.ModificationType.MULTIPLY;
|
modificationType = mbEnums.ModificationType.MULTIPLY;
|
||||||
|
|
||||||
if (modifierEntry.percentage != 0f) { //Stat Percent Modifiers
|
return modifierEntry.percentage != 0f
|
||||||
if (modificationType.equals(mbEnums.ModificationType.ADD))
|
? calculatePercentageBasedValue(modifierEntry, rank, modificationType)
|
||||||
scaledValue = modifierEntry.percentage + (modifierEntry.compoundCurveType.getValue() * rank);
|
: calculateBaseValue(modifierEntry, rank, modificationType);
|
||||||
else
|
|
||||||
scaledValue = modifierEntry.percentage * (1 + (modifierEntry.compoundCurveType.getValue() * rank));
|
|
||||||
scaledValue = scaledValue * 0.01f;
|
|
||||||
} else { //Stat Modifiers
|
|
||||||
if (modificationType.equals(mbEnums.ModificationType.ADD))
|
|
||||||
scaledValue = modifierEntry.min + (modifierEntry.compoundCurveType.getValue() * rank);
|
|
||||||
else
|
|
||||||
scaledValue = modifierEntry.min * (1 + (modifierEntry.compoundCurveType.getValue() * rank));
|
|
||||||
}
|
|
||||||
|
|
||||||
return scaledValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static float calculatePercentageBasedValue(ModifierEntry modifierEntry, int rank, mbEnums.ModificationType modificationType) {
|
||||||
|
float scaledValue = modificationType.equals(mbEnums.ModificationType.ADD)
|
||||||
|
? modifierEntry.percentage + (modifierEntry.compoundCurveType.getValue() * rank)
|
||||||
|
: modifierEntry.percentage * (1 + (modifierEntry.compoundCurveType.getValue() * rank));
|
||||||
|
return scaledValue * 0.01f;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float calculateBaseValue(ModifierEntry modifierEntry, int rank, mbEnums.ModificationType modificationType) {
|
||||||
|
return modificationType.equals(mbEnums.ModificationType.ADD)
|
||||||
|
? modifierEntry.min + (modifierEntry.compoundCurveType.getValue() * rank)
|
||||||
|
: modifierEntry.min * (1 + (modifierEntry.compoundCurveType.getValue() * rank));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user