Add natural log to level-calc formula parsing

Relates to #274
This commit is contained in:
tastybento 2023-01-16 14:16:14 -08:00
parent 93869cb34a
commit ac6bead52e
3 changed files with 5 additions and 2 deletions

View File

@ -135,6 +135,9 @@ public class IslandLevelCalculator {
case "tan":
x = Math.tan(Math.toRadians(x));
break;
case "log":
x = Math.log(x);
break;
default:
throw new RuntimeException("Unknown function: " + func);
}

View File

@ -90,7 +90,7 @@ public class ConfigSettings implements ConfigObject {
@ConfigComment("Island level calculation formula")
@ConfigComment("blocks - the sum total of all block values, less any death penalty")
@ConfigComment("level_cost - in a linear equation, the value of one level")
@ConfigComment("This formula can include +,=,*,/,sqrt,^,sin,cos,tan. Result will always be rounded to a long integer")
@ConfigComment("This formula can include +,=,*,/,sqrt,^,sin,cos,tan,log (natural log). Result will always be rounded to a long integer")
@ConfigComment("for example, an alternative non-linear option could be: 3 * sqrt(blocks / level_cost)")
@ConfigEntry(path = "level-calc")
private String levelCalc = "blocks / level_cost";

View File

@ -53,7 +53,7 @@ levelcost: 100
# Island level calculation formula
# blocks - the sum total of all block values, less any death penalty
# level_cost - in a linear equation, the value of one level
# This formula can include +,=,*,/,sqrt,^,sin,cos,tan. Result will always be rounded to a long integer
# This formula can include +,=,*,/,sqrt,^,sin,cos,tan,log (natural log). Result will always be rounded to a long integer
# for example, an alternative non-linear option could be: 3 * sqrt(blocks / level_cost)
level-calc: blocks / level_cost
#