diff --git a/lib/app/content.js b/lib/app/content.js
index a13f4a96f2..80dc1d2c78 100644
--- a/lib/app/content.js
+++ b/lib/app/content.js
@@ -1,78 +1,64 @@
// Generated by CoffeeScript 1.3.3
module.exports = {
- defaultTasks: {
- tasks: {
- '0': {
- type: 'habit',
- text: '1h Productive Work',
- notes: 'Habits: Constantly Track
For some habits, it only makes sense to gain points (like this one).',
- value: 0,
- up: true,
- down: false
- },
- '1': {
- type: 'habit',
- text: 'Eat Junk Food',
- notes: 'For others, it only makes sense to lose points',
- value: 0,
- up: false,
- down: true
- },
- '2': {
- type: 'habit',
- text: 'Take The Stairs',
- notes: 'For the rest, both + and - make sense (stairs = gain, elevator = lose)',
- value: 0,
- up: true,
- down: true
- },
- '3': {
- type: 'daily',
- text: '1h Personal Project',
- notes: 'Dailies: Complete Once a Day
At the end of each day, non-completed Dailies dock you points.',
- value: 0,
- completed: false
- },
- '4': {
- type: 'daily',
- text: 'Exercise',
- notes: "If you are doing well, they turn green and are less valuable (experience, gold) and less damaging (HP). This means you can ease up on them for a bit.",
- value: 3,
- completed: false
- },
- '5': {
- type: 'daily',
- text: '45m Reading',
- notes: 'But if you are doing poorly, they turn red. The worse you do, the more valuable (exp, gold) and more damaging (HP) these goals become. This encourages you to focus on your shortcomings, the reds.',
- value: -10,
- completed: false
- },
- '6': {
- type: 'todo',
- text: 'Call Mom',
- notes: "Todos: Complete Eventually
Non-completed Todos won't hurt you, but they will become more valuable over time. This will encourage you to wrap up stale Todos.",
- value: -3,
- completed: false
- },
- '7': {
- type: 'reward',
- text: '1 Episode of Game of Thrones',
- notes: 'Rewards: Treat Yourself!
As you complete goals, you earn gold to buy rewards. Buy them liberally - rewards are integral in forming good habits.',
- value: 20
- },
- '8': {
- type: 'reward',
- text: 'Cake',
- notes: 'But only buy if you have enough gold - you lose HP otherwise.',
- value: 10
- }
- },
- habitIds: ['0', '1', '2'],
- dailyIds: ['3', '4', '5'],
- todoIds: ['6'],
- rewardIds: ['7', '8']
- },
+ defaultTasks: [
+ {
+ type: 'habit',
+ text: '1h Productive Work',
+ notes: 'Habits: Constantly Track
For some habits, it only makes sense to gain points (like this one).',
+ value: 0,
+ up: true,
+ down: false
+ }, {
+ type: 'habit',
+ text: 'Eat Junk Food',
+ notes: 'For others, it only makes sense to lose points',
+ value: 0,
+ up: false,
+ down: true
+ }, {
+ type: 'habit',
+ text: 'Take The Stairs',
+ notes: 'For the rest, both + and - make sense (stairs = gain, elevator = lose)',
+ value: 0,
+ up: true,
+ down: true
+ }, {
+ type: 'daily',
+ text: '1h Personal Project',
+ notes: 'Dailies: Complete Once a Day
At the end of each day, non-completed Dailies dock you points.',
+ value: 0,
+ completed: false
+ }, {
+ type: 'daily',
+ text: 'Exercise',
+ notes: "If you are doing well, they turn green and are less valuable (experience, gold) and less damaging (HP). This means you can ease up on them for a bit.",
+ value: 3,
+ completed: false
+ }, {
+ type: 'daily',
+ text: '45m Reading',
+ notes: 'But if you are doing poorly, they turn red. The worse you do, the more valuable (exp, gold) and more damaging (HP) these goals become. This encourages you to focus on your shortcomings, the reds.',
+ value: -10,
+ completed: false
+ }, {
+ type: 'todo',
+ text: 'Call Mom',
+ notes: "Todos: Complete Eventually
Non-completed Todos won't hurt you, but they will become more valuable over time. This will encourage you to wrap up stale Todos.",
+ value: -3,
+ completed: false
+ }, {
+ type: 'reward',
+ text: '1 Episode of Game of Thrones',
+ notes: 'Rewards: Treat Yourself!
As you complete goals, you earn gold to buy rewards. Buy them liberally - rewards are integral in forming good habits.',
+ value: 20
+ }, {
+ type: 'reward',
+ text: 'Cake',
+ notes: 'But only buy if you have enough gold - you lose HP otherwise.',
+ value: 10
+ }
+ ],
tourSteps: [
{
element: "#avatar",
diff --git a/lib/app/index.js b/lib/app/index.js
index 451d783007..83f5556739 100644
--- a/lib/app/index.js
+++ b/lib/app/index.js
@@ -84,7 +84,7 @@ get('/:userId?', function(page, model, _arg) {
var userId;
userId = _arg.userId;
return model.subscribe("users", function(err, users) {
- var newUser, user;
+ var guid, newUser, task, user, _i, _len, _ref1;
userId = model.get('_userId');
debug(userId, 'model.get _userId');
if (model.get("users." + userId)) {
@@ -102,12 +102,31 @@ get('/:userId?', function(page, model, _arg) {
armor: 0,
weapon: 0
},
- tasks: content.defaultTasks.tasks,
- habitIds: content.defaultTasks.habitIds,
- dailyIds: content.defaultTasks.dailyIds,
- todoIds: content.defaultTasks.todoIds,
- rewardIds: content.defaultTasks.rewardIds
+ tasks: {},
+ habitIds: [],
+ dailyIds: [],
+ todoIds: [],
+ rewardIds: []
};
+ _ref1 = content.defaultTasks;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ task = _ref1[_i];
+ guid = Guid.raw();
+ newUser.tasks[guid] = task;
+ switch (task.type) {
+ case 'habit':
+ newUser.habitIds.push(guid);
+ break;
+ case 'daily':
+ newUser.dailyIds.push(guid);
+ break;
+ case 'todo':
+ newUser.todoIds.push(guid);
+ break;
+ case 'reward':
+ newUser.rewardIds.push(guid);
+ }
+ }
users.set(userId, newUser, function(err, path, value) {
return debug({
err: err,
diff --git a/src/app/content.coffee b/src/app/content.coffee
index 4c7486cec9..9e147138cd 100644
--- a/src/app/content.coffee
+++ b/src/app/content.coffee
@@ -1,20 +1,16 @@
module.exports = {
- defaultTasks:
- tasks:
- '0': {type: 'habit', text: '1h Productive Work', notes: 'Habits: Constantly Track
For some habits, it only makes sense to gain points (like this one).', value: 0, up: true, down: false }
- '1': {type: 'habit', text: 'Eat Junk Food', notes: 'For others, it only makes sense to lose points', value: 0, up: false, down: true}
- '2': {type: 'habit', text: 'Take The Stairs', notes: 'For the rest, both + and - make sense (stairs = gain, elevator = lose)', value: 0, up: true, down: true}
- '3': {type: 'daily', text: '1h Personal Project', notes: 'Dailies: Complete Once a Day
At the end of each day, non-completed Dailies dock you points.', value: 0, completed: false }
- '4': {type: 'daily', text: 'Exercise', notes: "If you are doing well, they turn green and are less valuable (experience, gold) and less damaging (HP). This means you can ease up on them for a bit.", value: 3, completed: false }
- '5': {type: 'daily', text: '45m Reading', notes: 'But if you are doing poorly, they turn red. The worse you do, the more valuable (exp, gold) and more damaging (HP) these goals become. This encourages you to focus on your shortcomings, the reds.', value: -10, completed: false }
- '6': {type: 'todo', text: 'Call Mom', notes: "Todos: Complete Eventually
Non-completed Todos won't hurt you, but they will become more valuable over time. This will encourage you to wrap up stale Todos.", value: -3, completed: false }
- '7': {type: 'reward', text: '1 Episode of Game of Thrones', notes: 'Rewards: Treat Yourself!
As you complete goals, you earn gold to buy rewards. Buy them liberally - rewards are integral in forming good habits.', value: 20 }
- '8': {type: 'reward', text: 'Cake', notes: 'But only buy if you have enough gold - you lose HP otherwise.', value: 10 }
- habitIds: ['0','1','2']
- dailyIds: ['3','4','5']
- todoIds: ['6']
- rewardIds: ['7','8']
-
+ defaultTasks: [
+ {type: 'habit', text: '1h Productive Work', notes: 'Habits: Constantly Track
For some habits, it only makes sense to gain points (like this one).', value: 0, up: true, down: false }
+ {type: 'habit', text: 'Eat Junk Food', notes: 'For others, it only makes sense to lose points', value: 0, up: false, down: true}
+ {type: 'habit', text: 'Take The Stairs', notes: 'For the rest, both + and - make sense (stairs = gain, elevator = lose)', value: 0, up: true, down: true}
+ {type: 'daily', text: '1h Personal Project', notes: 'Dailies: Complete Once a Day
At the end of each day, non-completed Dailies dock you points.', value: 0, completed: false }
+ {type: 'daily', text: 'Exercise', notes: "If you are doing well, they turn green and are less valuable (experience, gold) and less damaging (HP). This means you can ease up on them for a bit.", value: 3, completed: false }
+ {type: 'daily', text: '45m Reading', notes: 'But if you are doing poorly, they turn red. The worse you do, the more valuable (exp, gold) and more damaging (HP) these goals become. This encourages you to focus on your shortcomings, the reds.', value: -10, completed: false }
+ {type: 'todo', text: 'Call Mom', notes: "Todos: Complete Eventually
Non-completed Todos won't hurt you, but they will become more valuable over time. This will encourage you to wrap up stale Todos.", value: -3, completed: false }
+ {type: 'reward', text: '1 Episode of Game of Thrones', notes: 'Rewards: Treat Yourself!
As you complete goals, you earn gold to buy rewards. Buy them liberally - rewards are integral in forming good habits.', value: 20 }
+ {type: 'reward', text: 'Cake', notes: 'But only buy if you have enough gold - you lose HP otherwise.', value: 10 }
+ ]
+
tourSteps: [
{
element: "#avatar"
diff --git a/src/app/index.coffee b/src/app/index.coffee
index ae231f0228..035dfeeff7 100644
--- a/src/app/index.coffee
+++ b/src/app/index.coffee
@@ -70,13 +70,16 @@ get '/:userId?', (page, model, {userId}) ->
newUser = {
stats: { money: 0, exp: 0, lvl: 1, hp: 50 }
items: { itemsEnabled: false, armor: 0, weapon: 0 }
- tasks: content.defaultTasks.tasks
- habitIds: content.defaultTasks.habitIds
- dailyIds: content.defaultTasks.dailyIds
- todoIds: content.defaultTasks.todoIds
- rewardIds: content.defaultTasks.rewardIds
+ tasks: {}, habitIds: [], dailyIds: [], todoIds: [], rewardIds: []
}
-
+ for task in content.defaultTasks
+ guid = Guid.raw()
+ newUser.tasks[guid] = task
+ switch task.type
+ when 'habit' then newUser.habitIds.push guid
+ when 'daily' then newUser.dailyIds.push guid
+ when 'todo' then newUser.todoIds.push guid
+ when 'reward' then newUser.rewardIds.push guid
users.set userId, newUser, (err, path, value) ->
debug {err:err, path:path, value:value}, 'new user'