diff --git a/src/app/content.coffee b/src/app/content.coffee index eb3429c1bb..863fee9550 100644 --- a/src/app/content.coffee +++ b/src/app/content.coffee @@ -119,27 +119,24 @@ module.exports = { title: "Item Store Unlocked" content: "Congradulations, you have unlocked the Item Store! You can now buy weapons, armor, potions, etc. Read each item's comment for more information." weapon: [ - {text: "Sword 1", icon: "item-sword1", notes:'', value:0} - {text: "Sword 2", icon:'item-sword2', notes:'', value:100} - {text: "Blue Sword", icon:'item-bluesword', notes:'', value:200} - {text: "Axe", icon:'item-axe', notes:'', value:300} - {text: "Morningstar", icon:'item-morningstar', notes:'', value:400} - {text: "Red Sword", icon:'item-redsword', notes:'', value:500} - {text: "Gold Sword", icon:'item-goldsword', notes:'', value:600} + {type: 'weapon', index: 0, text: "Sword 1", icon: "item-sword1", notes:'', value:0} + {type: 'weapon', index: 1, text: "Sword 2", icon:'item-sword2', notes:'', value:100} + {type: 'weapon', index: 2, text: "Blue Sword", icon:'item-bluesword', notes:'', value:200} + {type: 'weapon', index: 3, text: "Axe", icon:'item-axe', notes:'', value:300} + {type: 'weapon', index: 4, text: "Morningstar", icon:'item-morningstar', notes:'', value:400} + {type: 'weapon', index: 5, text: "Red Sword", icon:'item-redsword', notes:'', value:500} + {type: 'weapon', index: 6, text: "Gold Sword", icon:'item-goldsword', notes:'', value:600} ] armor: [ - {text: "Cloth Armor", icon: 'item-clotharmor', notes:'', value:0} - {text: "Leather Armor", icon: 'item-leatherarmor', notes:'', value:100} - {text: "Chain Mail", icon: 'item-mailarmor', notes:'', value:200} - {text: "Plate Mail", icon: 'item-platearmor', notes:'', value:200} - {text: "Red Armor", icon: 'item-redarmor', notes:'', value:200} - {text: "Golden Armor", icon: 'item-goldenarmor', notes:'', value:200} + {type: 'armor', index: 0, text: "Cloth Armor", icon: 'item-clotharmor', notes:'', value:0} + {type: 'armor', index: 1, text: "Leather Armor", icon: 'item-leatherarmor', notes:'', value:100} + {type: 'armor', index: 2, text: "Chain Mail", icon: 'item-mailarmor', notes:'', value:200} + {type: 'armor', index: 3, text: "Plate Mail", icon: 'item-platearmor', notes:'', value:200} + {type: 'armor', index: 4, text: "Red Armor", icon: 'item-redarmor', notes:'', value:200} + {type: 'armor', index: 5, text: "Golden Armor", icon: 'item-goldenarmor', notes:'', value:200} ] - potion: {text: "Potion", notes: "Recover 15 HP", value: 100, icon: 'item-flask'} - reroll: - text: "Re-Roll" - icon: 'chest' - notes: "Reset your task values to 0. Do this only if you're floundering." + potion: {type: 'potion', text: "Potion", notes: "Recover 15 HP", value: 100, icon: 'item-flask'} + reroll: {type: 'reroll', text: "Re-Roll", icon: 'chest', notes: "Reset your task values to 0. Do this only if you're floundering."} } } diff --git a/src/app/index.coffee b/src/app/index.coffee index 81da5d9eef..64583d6977 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -30,10 +30,16 @@ view.fn "round", (num) -> Math.round num view.fn "gold", (num) -> - num.toFixed(1).split('.')[0] if num + if num + return num.toFixed(1).split('.')[0] + else + return "0" view.fn "silver", (num) -> - num.toFixed(1).split('.')[1] if num + if num + num.toFixed(1).split('.')[1] + else + return "0" ## ROUTES ## @@ -106,6 +112,7 @@ ready (model) -> $('ul.items').popover title: content.items.unlockedMessage.title placement: 'left' + trigger: 'manual' html: true content: "
\ \ @@ -116,7 +123,8 @@ ready (model) -> user.set 'stats.exp', stats.exp if stats.money? - user.set 'money', stats.money + money = 0.0 if (!money? or money<0) + user.set 'stats.money', stats.money # Note: Set 12am daily cron for this # At end of day, add value to all incomplete Daily & Todo tasks (further incentive) @@ -257,8 +265,8 @@ ready (model) -> task = model.at(e.target) #TODO bug where I have to delete from _users.tasks AND _{type}List, # fix when query subscriptions implemented properly - console.log model.del('_user.tasks.'+task.get('id')) - console.log task.remove() + model.del('_user.tasks.'+task.get('id')) + task.remove() exports.toggleTaskEdit = (e, el) -> task = model.at $(el).parents('li')[0] @@ -288,7 +296,27 @@ ready (model) -> chart = new google.visualization.LineChart(document.getElementById( chartSelector )) chart.draw(data, options) - exports.buyItem = (e, el) -> + exports.buyItem = (e, el, next) -> + user = model.at '_user' + item = model.at e.target + money = user.get 'stats.money' + [type, value] = [item.get('type'), item.get('value')] + return if money < value + + user.set 'stats.money', money - value + if type == 'armor' + user.set 'items.armor', item.get('index') + model.set '_items.0', content.items.armor[item.get('index') + 1] + else if type == 'weapon' + user.set 'items.weapon', item.get('index') + model.set '_items.1', content.items.weapon[item.get('index') + 1] + else if type == 'potion' + hp = user.get 'stats.hp' + hp += 15 + hp = 50 if hp > 50 + user.set 'stats.hp', hp + else if type == 'reroll' + console.log 'reroll' exports.vote = (e, el, next) -> diff --git a/views/app/index.html b/views/app/index.html index 9ab98f3a83..14453dc3cd 100644 --- a/views/app/index.html +++ b/views/app/index.html @@ -217,7 +217,8 @@
- {:item.value} + + {:item.value}
{:item.text}