tests passing for basic scoring
This commit is contained in:
+4
-2
@@ -206,10 +206,12 @@ score = function(taskId, direction, options) {
|
||||
}
|
||||
delta = 0;
|
||||
_.times(options.times, function(n) {
|
||||
delta = taskDeltaFormula(value, direction);
|
||||
var nextDelta;
|
||||
nextDelta = taskDeltaFormula(value, direction);
|
||||
if (adjustvalue) {
|
||||
return value += delta;
|
||||
value += nextDelta;
|
||||
}
|
||||
return delta += nextDelta;
|
||||
});
|
||||
if (type === 'habit') {
|
||||
if (taskObj.value !== value) {
|
||||
|
||||
@@ -164,8 +164,12 @@ score = (taskId, direction, options={cron:false, times:1}) ->
|
||||
# If multiple days have passed, multiply times days missed
|
||||
# TODO integrate this multiplier into the formula, so don't have to loop
|
||||
_.times options.times, (n) ->
|
||||
delta = taskDeltaFormula(value, direction)
|
||||
value += delta if adjustvalue
|
||||
# Each iteration calculate the delta (nextDelta), which is then accumulated in delta
|
||||
# (aka, the total delta). This weirdness won't be necessary when calculating mathematically
|
||||
# rather than iteratively
|
||||
nextDelta = taskDeltaFormula(value, direction)
|
||||
value += nextDelta if adjustvalue
|
||||
delta += nextDelta
|
||||
|
||||
if type == 'habit'
|
||||
# Add habit value to habit-history (if different)
|
||||
|
||||
@@ -125,7 +125,7 @@ describe 'User', ->
|
||||
## Trial 2
|
||||
freshTask {type: 'habit', text: 'Habit', completed: false}
|
||||
shouldBe = modificationsLookup({lvl:1,armor:0,weapon:0}, 'down', 10)
|
||||
_.times 10, -> scoring.score(uuid,'down', {times:10})
|
||||
scoring.score(uuid,'down', {times:10})
|
||||
[stats, task] = statsTask()
|
||||
expect(stats.hp).to.be.eql shouldBe.user.stats.hp
|
||||
expect(task.value).to.eql shouldBe.value
|
||||
|
||||
Reference in New Issue
Block a user