diff --git a/src/app/browser.coffee b/src/app/browser.coffee index e52e367bd6..0eb6c63767 100644 --- a/src/app/browser.coffee +++ b/src/app/browser.coffee @@ -97,17 +97,33 @@ module.exports.setupGrowlNotifications = (model) -> user.on 'set', 'items.itemsEnabled', (captures, args) -> return unless captures == true + message = "Congratulations, you have unlocked the Item Store! You can now buy weapons, armor, potions, etc. Read each item's comment for more information." $('ul.items').popover - title: content.items.unlockedMessage.title + title: "Item Store Unlocked" placement: 'left' trigger: 'manual' html: true content: "
- #{content.items.unlockedMessage.content} [Close] + #{message} [Close]
" $('ul.items').popover 'show' + user.on 'set', 'flags.partyEnabled', (captures, args) -> + return unless captures == true + message = "Congratulations, you have unlocked the Party System! You can now group with your friends by adding their User Ids." + $('#add-friend-button').popover + title: "Pary System Unlocked" + placement: 'bottom' + trigger: 'manual' + html: true + content: "
+ + #{message} [Close] +
" + $('#add-friend-button').popover 'show' + + # Setup listeners which trigger notifications user.on 'set', 'stats.hp', (captures, args) -> num = captures - args diff --git a/src/app/content.coffee b/src/app/content.coffee index 6750047ee1..00791b068e 100644 --- a/src/app/content.coffee +++ b/src/app/content.coffee @@ -55,9 +55,6 @@ module.exports = ] items: - unlockedMessage: - title: "Item Store Unlocked" - content: "Congratulations, you have unlocked the Item Store! You can now buy weapons, armor, potions, etc. Read each item's comment for more information." #TODO: figure out how to calculate index & type without having to store it in the JSON weapon: [ {type: 'weapon', index: 0, text: "Sword 1", icon: "item-sword1", notes:'Training weapon.', value:0} diff --git a/src/app/helpers.coffee b/src/app/helpers.coffee index 3122d47096..a287ed9b3b 100644 --- a/src/app/helpers.coffee +++ b/src/app/helpers.coffee @@ -65,4 +65,12 @@ module.exports.viewHelpers = (view) -> str += '_' + armorSet return "#{str}.png" else - return "armor#{armor}_m.png" \ No newline at end of file + return "armor#{armor}_m.png" + + view.fn "userName", (auth) -> + if auth?.facebook?.displayName? + auth.facebook.displayName + else if auth?.local? + auth.local.username + else + 'Anonymous' \ No newline at end of file diff --git a/src/app/index.coffee b/src/app/index.coffee index 144b7a9dda..3da1d42bc4 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -69,6 +69,7 @@ get '/', (page, model, next) -> setupListReferences(model) setupModelFns(model) + # Subscribe to friends if !_.isEmpty(userObj.friends) model.subscribe model.query('users').friends(userObj.friends), (err, friends) -> model.ref '_friends', friends @@ -307,10 +308,9 @@ ready (model) -> model.fetch query, (err, users) -> friend = users.get(0) if friend.id? - #TODO ensure unique user.push('friends', friendId) $('#add-friend-modal').modal('hide') - window.location.reload() #TODO break old subscript, setup new, then remove reload + window.location.reload() #TODO break old subscription, setup new subscript, remove this reload model.set '_newFriend', '' else model.set "_view.addFriendError", "User with id #{friendId} not found." diff --git a/src/app/schema.coffee b/src/app/schema.coffee index 93837269fe..1efdd0044c 100644 --- a/src/app/schema.coffee +++ b/src/app/schema.coffee @@ -12,6 +12,7 @@ module.exports.newUserObject = -> items: { itemsEnabled: false, armor: 0, weapon: 0 } notifications: { kickstarter: 'show' } preferences: { gender: 'm', armorSet: 'v1' } + flags: { partyEnabled: false } friends: [] tasks: {} habitIds: [] diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index c6f5dae618..4b7df92b2a 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -96,8 +96,10 @@ updateStats = (newStats, update) -> newStats.exp -= tnl userSet 'stats.lvl', userObj.stats.lvl + 1, update userSet 'stats.hp', 50, update - if !userObj.items?.itemsEnabled and newStats.exp >=15 + if !userObj.items?.itemsEnabled and newStats.lvl >= 2 user.set 'items.itemsEnabled', true #bit of trouble using userSet here + if !userObj.flags?.partyEnabled and newStats.lvl >= 3 + user.set 'flags.partyEnabled', true userSet 'stats.exp', newStats.exp, update if newStats.money? diff --git a/views/app/index.html b/views/app/index.html index f9a3939aef..6ea902659c 100644 --- a/views/app/index.html +++ b/views/app/index.html @@ -158,7 +158,7 @@
-
+
@@ -190,17 +190,18 @@ - - {#each _friends as :friend} - + {/} + {/} -
+ {#if _user.flags.partyEnabled} + {#each _friends as :friend} +
Lvl {:friend.stats.lvl}