mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 12:02:13 +00:00
checklists WIP
This commit is contained in:
parent
bb5fe9c6e5
commit
bb80176920
2 changed files with 23 additions and 4 deletions
18
dist/habitrpg-shared.js
vendored
18
dist/habitrpg-shared.js
vendored
|
|
@ -11300,7 +11300,10 @@ var process=require("__browserify_process");(function() {
|
|||
if (!(task = user.tasks[(_ref = req.params) != null ? _ref.id : void 0])) {
|
||||
return typeof cb === "function" ? cb("Task not found") : void 0;
|
||||
}
|
||||
_.merge(task, req.body);
|
||||
_.merge(task, _.omit(req.body, 'checklist'));
|
||||
if (req.body.checklist) {
|
||||
task.checklist = req.body.checklist;
|
||||
}
|
||||
if (typeof task.markModified === "function") {
|
||||
task.markModified('tags');
|
||||
}
|
||||
|
|
@ -11684,15 +11687,24 @@ var process=require("__browserify_process");(function() {
|
|||
delta = 0;
|
||||
calculateDelta = function() {
|
||||
return _.times(options.times, function() {
|
||||
var adjustAmt, currVal, nextDelta, _ref1;
|
||||
var adjustAmt, currVal, nextDelta, _ref1, _ref2;
|
||||
currVal = task.value < -47.27 ? -47.27 : task.value > 21.27 ? 21.27 : task.value;
|
||||
nextDelta = Math.pow(0.9747, currVal) * (direction === 'down' ? -1 : 1);
|
||||
if (direction === 'down' && task.type === 'daily' && options.cron && ((_ref1 = task.checklist) != null ? _ref1.length : void 0) > 0) {
|
||||
nextDelta *= 1 - _.reduce(task.checklist, (function(m, i) {
|
||||
return m + (i.completed ? 1 : 0);
|
||||
}), 0) / task.checklist.length;
|
||||
_.each(task.checklist, (function(i) {
|
||||
i.completed = false;
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
if (task.type !== 'reward') {
|
||||
adjustAmt = nextDelta;
|
||||
if (direction === 'up' && task.type !== 'reward' && !(task.type === 'habit' && !task.down)) {
|
||||
adjustAmt = nextDelta * (1 + user._statsComputed.str * .004);
|
||||
user.party.quest.progress.up = user.party.quest.progress.up || 0;
|
||||
if ((_ref1 = task.type) === 'daily' || _ref1 === 'todo') {
|
||||
if ((_ref2 = task.type) === 'daily' || _ref2 === 'todo') {
|
||||
user.party.quest.progress.up += adjustAmt;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -426,7 +426,8 @@ api.wrap = (user) ->
|
|||
|
||||
updateTask: (req, cb) ->
|
||||
return cb?("Task not found") unless task = user.tasks[req.params?.id]
|
||||
_.merge task, req.body
|
||||
_.merge task, _.omit(req.body,'checklist')
|
||||
task.checklist = req.body.checklist if req.body.checklist
|
||||
task.markModified? 'tags'
|
||||
cb? null, task
|
||||
|
||||
|
|
@ -686,6 +687,12 @@ api.wrap = (user) ->
|
|||
else if task.value > 21.27 then 21.27
|
||||
else task.value
|
||||
nextDelta = Math.pow(0.9747, currVal) * (if direction is 'down' then -1 else 1)
|
||||
|
||||
# If the Daily has a checklist, only dock them them a portion based on their checklist completion
|
||||
if direction is 'down' and task.type is 'daily' and options.cron and task.checklist?.length > 0
|
||||
nextDelta *= (1 - _.reduce(task.checklist,((m,i)->m+(if i.completed then 1 else 0)),0) / task.checklist.length)
|
||||
_.each task.checklist, ((i)->i.completed=false;true)
|
||||
|
||||
unless task.type is 'reward'
|
||||
adjustAmt = nextDelta
|
||||
# ===== STRENGTH =====
|
||||
|
|
|
|||
Loading…
Reference in a new issue