23 lines
1.0 KiB
C#
23 lines
1.0 KiB
C#
namespace Model;
|
|
|
|
public static class UnitEfficiency
|
|
{
|
|
public static double CalculateDpsPerHexite(int damagePerSecond, int hexite) => CalculateEfficiency(damagePerSecond, hexite);
|
|
public static double CalculateDpsPerFlux(int damagePerSecond, int flux) => CalculateEfficiency(damagePerSecond, flux);
|
|
public static double CalculateDpsPerTotalCost(int damagePerSecond, int hexite, int flux) => CalculateEfficiency(damagePerSecond, hexite + flux);
|
|
|
|
public static double CalculateHealthPerHexite(int health, int hexite) => CalculateEfficiency(health, hexite);
|
|
public static double CalculateHealthPerFlux(int health, int flux) => CalculateEfficiency(health, flux);
|
|
public static double CalculateHealthPerTotalCost(int health, int hexite, int flux) => CalculateEfficiency(health, hexite + flux);
|
|
|
|
private static double CalculateEfficiency(int value, int cost)
|
|
{
|
|
if (cost <= 0)
|
|
{
|
|
return value > 0 ? double.PositiveInfinity : 0;
|
|
}
|
|
|
|
return (double)value / cost;
|
|
}
|
|
}
|