forked from MagicBane/Server
Rework of helper method
This commit is contained in:
@@ -3154,5 +3154,10 @@ public class mbEnums {
|
||||
Always
|
||||
}
|
||||
|
||||
public enum ModificationType {
|
||||
ADD,
|
||||
MULTIPLY
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ public class Behaviours {
|
||||
public static Object Standard(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
||||
PowerAction powerAction, Effect effect, ModifierEntry modifierEntry) {
|
||||
|
||||
return WpakPowerManager.applyCurveToValue(modifierEntry.compoundCurveType, modifierEntry.max, rank);
|
||||
return WpakPowerManager.getModifiedValue(modifierEntry, rank);
|
||||
}
|
||||
|
||||
public static Object FPSubTypeAttr(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
||||
PowerAction powerAction, Effect effect, ModifierEntry modifierEntry) {
|
||||
return WpakPowerManager.applyCurveToValue(modifierEntry.compoundCurveType, modifierEntry.min, rank);
|
||||
return WpakPowerManager.getModifiedValue(modifierEntry, rank);
|
||||
}
|
||||
|
||||
public static Object SubTypeSourceType(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
||||
@@ -59,7 +59,7 @@ public class Behaviours {
|
||||
public static Object FPSubTypeDmg(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
||||
PowerAction powerAction, Effect effect, ModifierEntry modifierEntry) {
|
||||
String key = modifierEntry.arg1;
|
||||
float value = WpakPowerManager.applyCurveToValue(modifierEntry.compoundCurveType, modifierEntry.max, rank);
|
||||
float value = WpakPowerManager.getModifiedValue(modifierEntry, rank);
|
||||
return new Pair<>(key,value);
|
||||
}
|
||||
|
||||
|
||||
@@ -418,19 +418,30 @@ public class WpakPowerManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static float applyCurveToValue(mbEnums.CompoundCurveType curve, float value, int rank) {
|
||||
public static float getModifiedValue(ModifierEntry modifierEntry, int rank) {
|
||||
|
||||
float scaledValue;
|
||||
mbEnums.ModificationType modificationType = mbEnums.ModificationType.ADD;
|
||||
|
||||
// Method scales by either integer or float values driven by the curve type
|
||||
|
||||
if (EnumSet.of(mbEnums.CompoundCurveType.DefaultFlat, mbEnums.CompoundCurveType.DefaultSlope,
|
||||
mbEnums.CompoundCurveType.DefaultSlopeDown).contains(curve))
|
||||
scaledValue = value + (curve.getValue() * rank);
|
||||
else
|
||||
scaledValue = value * (1 + (curve.getValue() * rank));
|
||||
if (EnumSet.of(mbEnums.ModType.Health, mbEnums.ModType.Mana,
|
||||
mbEnums.ModType.Stamina).contains(modifierEntry.type))
|
||||
if (modifierEntry.percentage == 0)
|
||||
modificationType = mbEnums.ModificationType.MULTIPLY;
|
||||
|
||||
scaledValue = scaledValue * 0.01f;
|
||||
if (modifierEntry.percentage != 0f) { //Stat Percent Modifiers
|
||||
if (modificationType.equals(mbEnums.ModificationType.ADD))
|
||||
scaledValue = modifierEntry.percentage + (modifierEntry.compoundCurveType.getValue() * rank);
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user