diff --git a/app/core/utils.coffee b/app/core/utils.coffee index 18b20fa8b..572b3a3da 100644 --- a/app/core/utils.coffee +++ b/app/core/utils.coffee @@ -97,10 +97,15 @@ createQuadraticFunc = (params) -> createLogFunc = (params) -> (x) -> if x > 0 then (params.a or 1) * Math.log((params.b or 1) * (x + (params.c or 0))) + (params.d or 0) else 0 +# f(x) = ax^b + c +createPowFunc = (params) -> + (x) -> (params.a or 1) * Math.pow(x, params.b or 1) + (params.c or 0) + module.exports.functionCreators = linear: positify(createLinearFunc) quadratic: positify(createQuadraticFunc) logarithmic: positify(createLogFunc) + pow: positify(createPowFunc) # Call done with true to satisfy the 'until' goal and stop repeating func module.exports.keepDoingUntil = (func, wait=100, totalWait=5000) -> diff --git a/app/schemas/models/achievement.coffee b/app/schemas/models/achievement.coffee index 98d4767ad..fdf783754 100644 --- a/app/schemas/models/achievement.coffee +++ b/app/schemas/models/achievement.coffee @@ -66,7 +66,7 @@ _.extend AchievementSchema.properties, type: 'object' description: 'Function that gives total experience for X amount achieved' properties: - kind: {enum: ['linear', 'logarithmic', 'quadratic'] } + kind: {enum: ['linear', 'logarithmic', 'quadratic', 'pow'] } parameters: type: 'object' default: { a: 1, b: 0, c: 0 }