16 lines
424 B
Go

package helpers
// ClampPct divides two floats and clamps them to the given limits. Provides
// divide-by-zero protection by just returning 0.
func ClampPct(num, denom, minimum, maximum float64) float64 {
if denom == 0 {
return 0
}
return max(minimum, min(maximum, (num/denom)*100))
}
// ExpAtLevel calculates the needed total EXP for the given level.
func ExpAtLevel(level int) int {
return level * level * level
}