forked from MagicBane/Server
Methods made static and moved to manager
This commit is contained in:
@@ -67,47 +67,6 @@ public class Power {
|
||||
public boolean isProjectile = false;
|
||||
public HashMap<String, Float> conditions = new HashMap<>();
|
||||
|
||||
public int getRecycleTime(int trains) { // returns cast time in ms
|
||||
if (this.curves.get("RECYCLETIME") != null)
|
||||
return (int) (((this.recycle_time + (this.curves.get("RECYCLETIME").getValue() * trains)) * 1000) + getCastTime(trains));
|
||||
else
|
||||
return (int) (((this.recycle_time * (1 + (this.curves.get("RECYCLETIME").getValue() * trains))) * 1000) + getCastTime(trains));
|
||||
}
|
||||
public int getCastTime(int trains) { // returns cast time in ms
|
||||
if (this.curves.get("INITTIME") != null)
|
||||
return (int) ((this.init_time + (this.curves.get("INITTIME").getValue() * trains)) * 1000);
|
||||
else
|
||||
return (int) ((this.init_time * (1 + (this.curves.get("INITTIME").getValue() * trains))) * 1000);
|
||||
}
|
||||
|
||||
public boolean allowedInCombat() {
|
||||
switch(castingMode.name()){
|
||||
case "NONE":
|
||||
case "BOTH":
|
||||
case "COMBAT":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean allowedOutOfCombat() {
|
||||
switch(castingMode.name()){
|
||||
case "NONE":
|
||||
case "BOTH":
|
||||
case "NONCOMBAT":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getCost(int trains) {
|
||||
if (this.curves.get("COSTAMT") != null)
|
||||
return this.cost + (float)(this.curves.get("COSTAMT").getValue() * trains);
|
||||
else
|
||||
return this.cost * (1 + (float)(this.curves.get("COSTAMT").getValue() * trains));
|
||||
|
||||
}
|
||||
|
||||
public boolean isSpell(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -132,13 +132,13 @@ public class WpakPowerManager {
|
||||
}
|
||||
|
||||
//get casting time
|
||||
int time = powerCast.getRecycleTime(trains);
|
||||
int time = getRecycleTime(powerCast, trains);
|
||||
|
||||
//combat mode sanity check
|
||||
if (playerCharacter.isCombat()) {
|
||||
if (!powerCast.allowedInCombat())
|
||||
if (!allowedInCombat(powerCast))
|
||||
return true;
|
||||
} else if (!powerCast.allowedOutOfCombat())
|
||||
} else if (!allowedOutOfCombat(powerCast))
|
||||
return true;
|
||||
|
||||
//stunned check
|
||||
@@ -199,7 +199,7 @@ public class WpakPowerManager {
|
||||
}
|
||||
}
|
||||
|
||||
float cost = powerCast.getCost(trains);
|
||||
float cost = getCost(powerCast, trains);
|
||||
if (bonus != null)
|
||||
cost *= (1 + bonus.getFloatPercentAll(mbEnums.ModType.PowerCost, mbEnums.SourceType.None));
|
||||
|
||||
@@ -266,7 +266,7 @@ public class WpakPowerManager {
|
||||
playerCharacter.cancelOnSpell();
|
||||
|
||||
// get cast time in ms.
|
||||
time = powerCast.getCastTime(trains);
|
||||
time = getCastTime(powerCast, trains);
|
||||
|
||||
// set player is casting for regens
|
||||
|
||||
@@ -381,4 +381,46 @@ public class WpakPowerManager {
|
||||
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getRecycleTime(Power power, int trains) { // returns cast time in ms
|
||||
if (power.curves.get("RECYCLETIME") != null)
|
||||
return (int) (((power.recycle_time + (power.curves.get("RECYCLETIME").getValue() * trains)) * 1000) + getCastTime(power, trains));
|
||||
else
|
||||
return (int) (((power.recycle_time * (1 + (power.curves.get("RECYCLETIME").getValue() * trains))) * 1000) + getCastTime(power, trains));
|
||||
}
|
||||
|
||||
public static int getCastTime(Power power, int trains) { // returns cast time in ms
|
||||
if (power.curves.get("INITTIME") != null)
|
||||
return (int) ((power.init_time + (power.curves.get("INITTIME").getValue() * trains)) * 1000);
|
||||
else
|
||||
return (int) ((power.init_time * (1 + (power.curves.get("INITTIME").getValue() * trains))) * 1000);
|
||||
}
|
||||
|
||||
public static float getCost(Power power, int trains) {
|
||||
if (power.curves.get("COSTAMT") != null)
|
||||
return power.cost + (float) (power.curves.get("COSTAMT").getValue() * trains);
|
||||
else
|
||||
return power.cost * (1 + (float) (power.curves.get("COSTAMT").getValue() * trains));
|
||||
|
||||
}
|
||||
|
||||
public static boolean allowedInCombat(Power power) {
|
||||
switch (power.castingMode.name()) {
|
||||
case "NONE":
|
||||
case "BOTH":
|
||||
case "COMBAT":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean allowedOutOfCombat(Power power) {
|
||||
switch (power.castingMode.name()) {
|
||||
case "NONE":
|
||||
case "BOTH":
|
||||
case "NONCOMBAT":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user