mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-02 00:43:34 -04:00
Added new pow function for simulated ladder games achievement.
This commit is contained in:
parent
1a44b3ff5a
commit
1795891933
2 changed files with 6 additions and 1 deletions
app
|
@ -97,10 +97,15 @@ createQuadraticFunc = (params) ->
|
||||||
createLogFunc = (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
|
(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 =
|
module.exports.functionCreators =
|
||||||
linear: positify(createLinearFunc)
|
linear: positify(createLinearFunc)
|
||||||
quadratic: positify(createQuadraticFunc)
|
quadratic: positify(createQuadraticFunc)
|
||||||
logarithmic: positify(createLogFunc)
|
logarithmic: positify(createLogFunc)
|
||||||
|
pow: positify(createPowFunc)
|
||||||
|
|
||||||
# Call done with true to satisfy the 'until' goal and stop repeating func
|
# Call done with true to satisfy the 'until' goal and stop repeating func
|
||||||
module.exports.keepDoingUntil = (func, wait=100, totalWait=5000) ->
|
module.exports.keepDoingUntil = (func, wait=100, totalWait=5000) ->
|
||||||
|
|
|
@ -66,7 +66,7 @@ _.extend AchievementSchema.properties,
|
||||||
type: 'object'
|
type: 'object'
|
||||||
description: 'Function that gives total experience for X amount achieved'
|
description: 'Function that gives total experience for X amount achieved'
|
||||||
properties:
|
properties:
|
||||||
kind: {enum: ['linear', 'logarithmic', 'quadratic'] }
|
kind: {enum: ['linear', 'logarithmic', 'quadratic', 'pow'] }
|
||||||
parameters:
|
parameters:
|
||||||
type: 'object'
|
type: 'object'
|
||||||
default: { a: 1, b: 0, c: 0 }
|
default: { a: 1, b: 0, c: 0 }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue