Added new pow function for simulated ladder games achievement.

This commit is contained in:
Nick Winter 2015-02-18 09:06:32 -08:00
parent 1a44b3ff5a
commit 1795891933
2 changed files with 6 additions and 1 deletions

View file

@ -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) ->

View file

@ -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 }