From c9aa04439dd8b2c1969b8e9f10b8dafc5dcb0ac1 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Fri, 3 May 2013 18:18:28 +0100 Subject: [PATCH 01/21] begin implementing streaks --- src/app/scoring.coffee | 6 ++++++ src/app/unlock.coffee | 20 +++++++++++--------- views/app/avatar.html | 4 +++- views/app/modals.html | 1 + views/app/tasks.html | 14 ++++++++++++++ 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index d487909e80..79bd5566c2 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -144,10 +144,16 @@ score = (model, taskId, direction, times, batch, cron) -> if cron? # cron calculateDelta() subtractPoints() + batch.set "#{taskPath}.streak", 0 else calculateDelta(false) if delta != 0 addPoints() # obviously for delta>0, but also a trick to undo accidental checkboxes + if direction is 'up' + taskObj.streak = if taskObj.streak then taskObj.streak + 1 else 1 + else + taskObj.streak = if taskObj.streak then taskObj.streak - 1 else 0 + batch.set "#{taskPath}.streak", taskObj.streak when 'todo' if cron? #cron diff --git a/src/app/unlock.coffee b/src/app/unlock.coffee index 742aa1436b..86a31787d0 100644 --- a/src/app/unlock.coffee +++ b/src/app/unlock.coffee @@ -68,20 +68,22 @@ module.exports.app = (appExports, model) -> user.on 'push', 'items.pets', (after, before) -> return if user.get('achievements.beastMaster') if before >= 90 # evidently before is the count? - dontPersist = model._dontPersist - model._dontPersist = false - user.set 'achievements.beastMaster', true, -> - model._dontPersist = dontPersist + dontPersist = model._dontPersist; model._dontPersist = false + user.set 'achievements.beastMaster', true, (-> model._dontPersist = dontPersist) $('#beastmaster-achievement-modal').modal('show') user.on 'set', 'items.*', (after, before) -> return if user.get('achievements.ultimateGear') items = user.get('items') if parseInt(items.weapon) == 6 and parseInt(items.armor) == 5 and parseInt(items.head) == 5 and parseInt(items.shield) == 5 - debugger - dontPersist = model._dontPersist - model._dontPersist = false - user.set 'achievements.ultimateGear', true, -> - model._dontPersist = dontPersist + dontPersist = model._dontPersist; model._dontPersist = false + user.set 'achievements.ultimateGear', true, (-> model._dontPersist = dontPersist) $('#max-gear-achievement-modal').modal('show') + user.on 'set', 'tasks.*.streak', (id, val) -> + # 21-day streak, as per the old philosophy of doign a thing 21-days in a row makes a habit + if (val % 21) is 0 + dontPersist = model._dontPersist; model._dontPersist = false + user.incr 'achievements.streak', 1, (-> model._dontPersist = dontPersist) + $('#streak-achievement-modal').modal('show') + diff --git a/views/app/avatar.html b/views/app/avatar.html index 975a50ddd1..ceec7399f5 100644 --- a/views/app/avatar.html +++ b/views/app/avatar.html @@ -179,9 +179,11 @@ - + {#if @profile.achievements.streak} +
{@profile.achievements.streak} Streak Achievement(s) + {/} {#if @profile.achievements.originalUser}
Original User
diff --git a/views/app/modals.html b/views/app/modals.html index 5122e562e9..0408125a87 100644 --- a/views/app/modals.html +++ b/views/app/modals.html @@ -5,6 +5,7 @@ +
diff --git a/views/app/tasks.html b/views/app/tasks.html index 86a6225bd9..bfa3c5cf29 100644 --- a/views/app/tasks.html +++ b/views/app/tasks.html @@ -1,3 +1,13 @@ + + +

+

You have stacked your "Streaker" Achievement! Every 21 days of streak, you gain 1 achievement point here. +

+ <@footer> + + +
+ {{#if and( _loggedIn, notEqual(_user.flags.ads,'hide') )}} @@ -98,6 +108,10 @@
+ + {#if :task.streak} + {:task.streak} + {/} From bcb2505a96a75cd3165a5e2dc825a51d16439d65 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Fri, 3 May 2013 18:36:21 +0100 Subject: [PATCH 02/21] add streak GP bonus & drop bonus (separately handled) --- src/app/algos.coffee | 5 +++-- src/app/scoring.coffee | 11 +++++++---- src/app/unlock.coffee | 2 +- views/app/avatar.html | 1 + views/app/tasks.html | 6 +++--- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/app/algos.coffee b/src/app/algos.coffee index 5a24d1b9a5..fe4d9d1c92 100644 --- a/src/app/algos.coffee +++ b/src/app/algos.coffee @@ -48,8 +48,9 @@ module.exports.hpModifier = (value, armorDef, helmDef, shieldDef, level, priorit Future use {priority} user-defined priority multiplier ### -module.exports.gpModifier = (value, modifier, priority='!') -> - return value * modifier * priorityValue(priority) +module.exports.gpModifier = (value, modifier, priority='!', streak=0) -> + streakBonus = streak / 100 + 1 # eg, 1-day streak is 1.1, 2-day is 1.2, etc + return value * modifier * priorityValue(priority) * streakBonus ### Calculates the next task.value based on direction diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index 79bd5566c2..d470654bcf 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -12,7 +12,7 @@ MODIFIER = algos.MODIFIER # each new level, armor, weapon add 2% modifier (this ### Drop System ### -randomDrop = (model, delta, priority) -> +randomDrop = (model, delta, priority, streak=0) -> user = model.at('_user') # limit drops to 2 / day @@ -27,7 +27,10 @@ randomDrop = (model, delta, priority) -> chanceMultiplier = if (model.flags.nodeEnv is 'development') then 50 else 1 # TODO temporary min cap of 1 so people still get rewarded for good habits. Will change once we have streaks deltaMultiplier = if Math.abs(delta) < 1 then 1 else Math.abs(delta) - chanceMultiplier = chanceMultiplier * deltaMultiplier * algos.priorityValue(priority) # multiply chance by reddness + chanceMultiplier *= deltaMultiplier + chanceMultiplier *= algos.priorityValue(priority) # multiply chance by reddness + chanceMultiplier += (streak+ 1) # streak bonus + console.log chanceMultiplier if user.get('flags.dropsEnabled') and Math.random() < (.05 * chanceMultiplier) # current breakdown - 3% (adjustable) chance on drop @@ -120,7 +123,7 @@ score = (model, taskId, direction, times, batch, cron) -> level = user.get('stats.lvl') weaponStrength = items.items.weapon[user.get('items.weapon')].strength exp += algos.expModifier(delta,weaponStrength,level, priority) / 2 # / 2 hack for now bcause people leveling too fast - gp += algos.gpModifier(delta, 1, priority) + gp += algos.gpModifier(delta, 1, priority, taskObj.streak) subtractPoints = -> level = user.get('stats.lvl') @@ -189,7 +192,7 @@ score = (model, taskId, direction, times, batch, cron) -> batch.commit() # Drop system - randomDrop(model, delta, priority) if direction is 'up' + randomDrop(model, delta, priority, taskObj.streak) if direction is 'up' return delta diff --git a/src/app/unlock.coffee b/src/app/unlock.coffee index 86a31787d0..8946eb94ec 100644 --- a/src/app/unlock.coffee +++ b/src/app/unlock.coffee @@ -82,7 +82,7 @@ module.exports.app = (appExports, model) -> user.on 'set', 'tasks.*.streak', (id, val) -> # 21-day streak, as per the old philosophy of doign a thing 21-days in a row makes a habit - if (val % 21) is 0 + if val > 0 and (val % 21) is 0 dontPersist = model._dontPersist; model._dontPersist = false user.incr 'achievements.streak', 1, (-> model._dontPersist = dontPersist) $('#streak-achievement-modal').modal('show') diff --git a/views/app/avatar.html b/views/app/avatar.html index ceec7399f5..29f4ef29c5 100644 --- a/views/app/avatar.html +++ b/views/app/avatar.html @@ -183,6 +183,7 @@ {#if @profile.achievements.streak}
{@profile.achievements.streak} Streak Achievement(s) +
{/} {#if @profile.achievements.originalUser}
Original User diff --git a/views/app/tasks.html b/views/app/tasks.html index bfa3c5cf29..8f326c3c16 100644 --- a/views/app/tasks.html +++ b/views/app/tasks.html @@ -109,9 +109,9 @@
- {#if :task.streak} - {:task.streak} - {/} + + {:task.streak} + From dd8935ec636851dfba67ae182dbd4131e5336a97 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 08:10:40 +0100 Subject: [PATCH 03/21] put popover back in for main herobox #890 --- views/app/avatar.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/app/avatar.html b/views/app/avatar.html index 975a50ddd1..f4d2747c6d 100644 --- a/views/app/avatar.html +++ b/views/app/avatar.html @@ -15,7 +15,7 @@ data-checkpet="{#if @profile.items.pet}hasPet{/}" data-checkuser="{{#if @main}}isUser{{/}}" data-uid="{{@profile.id}}" x-bind="click:clickAvatar" - rel="popover" data-placement="bottom" data-trigger="hover" data-html="true" data-content="{{#unless @main}} + rel="popover" data-placement="bottom" data-trigger="hover" data-html="true" data-content="
@@ -27,7 +27,7 @@
GP: {floor(@profile.stats.gp)}
{count(@profile.items.pets)} / 90 Pets Found
- {{/}}"> + ">
{#with @profile.preferences as :p} From 60b6c8a400138048e4b03ff30041fee4e001d5f3 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 08:56:44 +0100 Subject: [PATCH 04/21] fix missing username bug --- src/app/helpers.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/helpers.coffee b/src/app/helpers.coffee index 6e6911e1be..c3c1f13013 100644 --- a/src/app/helpers.coffee +++ b/src/app/helpers.coffee @@ -26,7 +26,7 @@ removeWhitespace = (str) -> username = (auth, override) -> #some people define custom profile name in Avatar -> Profile - return override if override? + return override if override if auth?.facebook?.displayName? auth.facebook.displayName From 5b6cf5c039ac5febfe3ab1c2b1c6b077e260afe1 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 09:38:10 +0100 Subject: [PATCH 05/21] remove the minimum of 1% drop-chance, now that we have streaks in --- src/app/scoring.coffee | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index d470654bcf..f9cf4351e8 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -23,11 +23,7 @@ randomDrop = (model, delta, priority, streak=0) -> return if reachedDropLimit and model.flags.nodeEnv != 'development' # % chance of getting a pet or meat - # debugging purpose - 50% chance during development, 3% chance on prod - chanceMultiplier = if (model.flags.nodeEnv is 'development') then 50 else 1 - # TODO temporary min cap of 1 so people still get rewarded for good habits. Will change once we have streaks - deltaMultiplier = if Math.abs(delta) < 1 then 1 else Math.abs(delta) - chanceMultiplier *= deltaMultiplier + chanceMultiplier = 1 chanceMultiplier *= algos.priorityValue(priority) # multiply chance by reddness chanceMultiplier += (streak+ 1) # streak bonus console.log chanceMultiplier From 381fb48c0304aa84f94e4346efe13d24bd4d042d Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 09:40:46 +0100 Subject: [PATCH 06/21] emit the streak bonus so we can display the growl notification. I'm not sure I like this approach, because (1) we can't set growl order, streak bonus comes first, and (2) I want to keep model-aware code to a minimum so we can weed out the mem leak --- src/app/algos.coffee | 7 +++++-- src/app/browser.coffee | 6 ++++++ src/app/scoring.coffee | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/algos.coffee b/src/app/algos.coffee index fe4d9d1c92..6ec2c97907 100644 --- a/src/app/algos.coffee +++ b/src/app/algos.coffee @@ -48,9 +48,12 @@ module.exports.hpModifier = (value, armorDef, helmDef, shieldDef, level, priorit Future use {priority} user-defined priority multiplier ### -module.exports.gpModifier = (value, modifier, priority='!', streak=0) -> +module.exports.gpModifier = (value, modifier, priority='!', streak=0, model) -> streakBonus = streak / 100 + 1 # eg, 1-day streak is 1.1, 2-day is 1.2, etc - return value * modifier * priorityValue(priority) * streakBonus + val = value * modifier * priorityValue(priority) + afterStreak = val * streakBonus + model.set('_streakBonus', afterStreak - val) if (model and streak and (val > 0)) # can we do this without model? just global emit? + return afterStreak ### Calculates the next task.value based on direction diff --git a/src/app/browser.coffee b/src/app/browser.coffee index 9256a4021f..38e5fcc935 100644 --- a/src/app/browser.coffee +++ b/src/app/browser.coffee @@ -157,6 +157,12 @@ setupGrowlNotifications = (model) -> else if num > 0 statsNotification " + #{rounded} XP", 'xp' + model.on 'set', '_streakBonus', (captures, args) -> + absolute = Math.abs(captures) + gold = Math.floor(absolute) + silver = Math.floor((absolute-gold)*100) + statsNotification "+ #{gold} #{silver} - Streak Bonus!", 'gp' + user.on 'set', 'stats.gp', (captures, args) -> num = captures - args absolute = Math.abs(num) diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index f9cf4351e8..e0fb4afeb3 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -119,7 +119,7 @@ score = (model, taskId, direction, times, batch, cron) -> level = user.get('stats.lvl') weaponStrength = items.items.weapon[user.get('items.weapon')].strength exp += algos.expModifier(delta,weaponStrength,level, priority) / 2 # / 2 hack for now bcause people leveling too fast - gp += algos.gpModifier(delta, 1, priority, taskObj.streak) + gp += algos.gpModifier(delta, 1, priority, taskObj.streak, model) subtractPoints = -> level = user.get('stats.lvl') From c389588965f30a166fc9923059d4284005a21c17 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 09:42:46 +0100 Subject: [PATCH 07/21] woops, chanceMultiplier should be delta, not 1 --- src/app/scoring.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index e0fb4afeb3..b26b53ea0d 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -23,7 +23,7 @@ randomDrop = (model, delta, priority, streak=0) -> return if reachedDropLimit and model.flags.nodeEnv != 'development' # % chance of getting a pet or meat - chanceMultiplier = 1 + chanceMultiplier = Math.abs(delta) chanceMultiplier *= algos.priorityValue(priority) # multiply chance by reddness chanceMultiplier += (streak+ 1) # streak bonus console.log chanceMultiplier From de810cc722334262226115efd74f86f80402c5b9 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 10:11:06 +0100 Subject: [PATCH 08/21] show streakBonus in gpModifier --- src/app/browser.coffee | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/app/browser.coffee b/src/app/browser.coffee index 38e5fcc935..cc74fdc197 100644 --- a/src/app/browser.coffee +++ b/src/app/browser.coffee @@ -157,24 +157,31 @@ setupGrowlNotifications = (model) -> else if num > 0 statsNotification " + #{rounded} XP", 'xp' - model.on 'set', '_streakBonus', (captures, args) -> - absolute = Math.abs(captures) + ### + Show "+ 5 {gold_coin} 3 {silver_coin}" + ### + showCoins = (money) -> + absolute = Math.abs(money) gold = Math.floor(absolute) silver = Math.floor((absolute-gold)*100) - statsNotification "+ #{gold} #{silver} - Streak Bonus!", 'gp' + if gold and silver > 0 + return "#{gold} #{silver} " + else if gold > 0 + return "#{gold} " + else if silver > 0 + return "#{silver} " user.on 'set', 'stats.gp', (captures, args) -> - num = captures - args - absolute = Math.abs(num) - gold = Math.floor(absolute) - silver = Math.floor((absolute-gold)*100) - sign = if num < 0 then '-' else '+' - if gold and silver > 0 - statsNotification "#{sign} #{gold} #{silver} ", 'gp' - else if gold > 0 - statsNotification "#{sign} #{gold} ", 'gp' - else if silver > 0 - statsNotification "#{sign} #{silver} ", 'gp' + money = captures - args + sign = if money < 0 then '-' else '+' + statsNotification "#{sign} #{showCoins(money)}", 'gp' + + # Append Bonus + bonus = model.get('_streakBonus') + if money > 0 and bonus + statsNotification "#{showCoins(bonus)} Streak Bonus!" + model.del('_streakBonus') + user.on 'set', 'stats.lvl', (captures, args) -> if captures > args From 7d22602b9aa3baf996dead6d23f77487fbb1f8c9 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 10:35:30 +0100 Subject: [PATCH 09/21] some streaks cleanup. set taskObj.streak AFTER model.set() so that we get before/after values in listeners. Take away streak achievement if they went 21, undo to 20 --- src/app/browser.coffee | 2 +- src/app/scoring.coffee | 14 ++++++++------ src/app/unlock.coffee | 18 ++++++++++++------ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/app/browser.coffee b/src/app/browser.coffee index cc74fdc197..44f603ee5f 100644 --- a/src/app/browser.coffee +++ b/src/app/browser.coffee @@ -179,7 +179,7 @@ setupGrowlNotifications = (model) -> # Append Bonus bonus = model.get('_streakBonus') if money > 0 and bonus - statsNotification "#{showCoins(bonus)} Streak Bonus!" + statsNotification "+ #{showCoins(bonus)} Streak Bonus!" model.del('_streakBonus') diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index b26b53ea0d..0ea45a7fa5 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -93,7 +93,7 @@ score = (model, taskId, direction, times, batch, cron) -> taskPath = "tasks.#{taskId}" taskObj = obj.tasks[taskId] - {type, value} = taskObj + {type, value, streak} = taskObj priority = taskObj.priority or '!' # If they're trying to purhcase a too-expensive reward, confirm they want to take a hit for it @@ -119,7 +119,7 @@ score = (model, taskId, direction, times, batch, cron) -> level = user.get('stats.lvl') weaponStrength = items.items.weapon[user.get('items.weapon')].strength exp += algos.expModifier(delta,weaponStrength,level, priority) / 2 # / 2 hack for now bcause people leveling too fast - gp += algos.gpModifier(delta, 1, priority, taskObj.streak, model) + gp += algos.gpModifier(delta, 1, priority, streak, model) subtractPoints = -> level = user.get('stats.lvl') @@ -149,10 +149,12 @@ score = (model, taskId, direction, times, batch, cron) -> if delta != 0 addPoints() # obviously for delta>0, but also a trick to undo accidental checkboxes if direction is 'up' - taskObj.streak = if taskObj.streak then taskObj.streak + 1 else 1 + streak = if streak then streak + 1 else 1 else - taskObj.streak = if taskObj.streak then taskObj.streak - 1 else 0 - batch.set "#{taskPath}.streak", taskObj.streak + streak = if streak then streak - 1 else 0 + batch.set "#{taskPath}.streak", streak + taskObj.streak = streak + when 'todo' if cron? #cron @@ -188,7 +190,7 @@ score = (model, taskId, direction, times, batch, cron) -> batch.commit() # Drop system - randomDrop(model, delta, priority, taskObj.streak) if direction is 'up' + randomDrop(model, delta, priority, streak) if direction is 'up' return delta diff --git a/src/app/unlock.coffee b/src/app/unlock.coffee index 8946eb94ec..f542fdbd70 100644 --- a/src/app/unlock.coffee +++ b/src/app/unlock.coffee @@ -80,10 +80,16 @@ module.exports.app = (appExports, model) -> user.set 'achievements.ultimateGear', true, (-> model._dontPersist = dontPersist) $('#max-gear-achievement-modal').modal('show') - user.on 'set', 'tasks.*.streak', (id, val) -> - # 21-day streak, as per the old philosophy of doign a thing 21-days in a row makes a habit - if val > 0 and (val % 21) is 0 - dontPersist = model._dontPersist; model._dontPersist = false - user.incr 'achievements.streak', 1, (-> model._dontPersist = dontPersist) - $('#streak-achievement-modal').modal('show') + user.on 'set', 'tasks.*.streak', (id, after, before) -> + if after > 0 + # 21-day streak, as per the old philosophy of doign a thing 21-days in a row makes a habit + if (after % 21) is 0 + dontPersist = model._dontPersist; model._dontPersist = false + user.incr 'achievements.streak', 1, (-> model._dontPersist = dontPersist) + $('#streak-achievement-modal').modal('show') + + # they're undoing a task at the 21 mark, take back their badge + if (before - after is 1) and (before % 21 is 0) + dontPersist = model._dontPersist; model._dontPersist = false + user.incr 'achievements.streak', -1, (-> model._dontPersist = dontPersist) From 344444904841a293b877a22d0c3e18406a255a0a Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 10:44:06 +0100 Subject: [PATCH 10/21] small chance --- src/app/unlock.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/unlock.coffee b/src/app/unlock.coffee index f542fdbd70..7a240aea7e 100644 --- a/src/app/unlock.coffee +++ b/src/app/unlock.coffee @@ -90,6 +90,6 @@ module.exports.app = (appExports, model) -> $('#streak-achievement-modal').modal('show') # they're undoing a task at the 21 mark, take back their badge - if (before - after is 1) and (before % 21 is 0) + else if (before - after is 1) and (before % 21 is 0) dontPersist = model._dontPersist; model._dontPersist = false user.incr 'achievements.streak', -1, (-> model._dontPersist = dontPersist) From fb9ca0af718a1839c1ef372c68375a6fe3a53883 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 11:04:30 +0100 Subject: [PATCH 11/21] was adding accidental extra % point --- src/app/scoring.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index 0ea45a7fa5..83ff56bd8f 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -25,7 +25,7 @@ randomDrop = (model, delta, priority, streak=0) -> # % chance of getting a pet or meat chanceMultiplier = Math.abs(delta) chanceMultiplier *= algos.priorityValue(priority) # multiply chance by reddness - chanceMultiplier += (streak+ 1) # streak bonus + chanceMultiplier += streak # streak bonus console.log chanceMultiplier if user.get('flags.dropsEnabled') and Math.random() < (.05 * chanceMultiplier) From 0b48c1ab25239ab5e450f5fbc934b8509df30061 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 11:26:26 +0100 Subject: [PATCH 12/21] minimum of 1 silver streak bonus --- src/app/browser.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/browser.coffee b/src/app/browser.coffee index 44f603ee5f..6c0bbb49dc 100644 --- a/src/app/browser.coffee +++ b/src/app/browser.coffee @@ -179,6 +179,7 @@ setupGrowlNotifications = (model) -> # Append Bonus bonus = model.get('_streakBonus') if money > 0 and bonus + bonus = 0.01 if bonus < 0.01 statsNotification "+ #{showCoins(bonus)} Streak Bonus!" model.del('_streakBonus') From 5232589678dfd7828bad835fa744fa4d758a233d Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 11:35:11 +0100 Subject: [PATCH 13/21] bailey alert for streaks --- views/app/alerts.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/views/app/alerts.html b/views/app/alerts.html index 2d54863a56..64a81f4f5e 100644 --- a/views/app/alerts.html +++ b/views/app/alerts.html @@ -13,10 +13,16 @@

+

5/4/2013

+
    +
  • Streaks. You get a GP & drop-% increase the longer you hold daily streaks (they stack). You also get a stacking badge 21-day streaks.
  • +
+

5/3/2013

  • Two new achievements: Beast Master & Ultimate Gear. Got ideas for more achievements? chime in here
+

5/2/2013

+

3/27/2013

  • Drop system + pets overhaul (Blog Post | Trello Card)
  • From 54ef864458f400327a26cabe1e74d3a3f5cb36b5 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 11:45:51 +0100 Subject: [PATCH 14/21] wording update --- views/app/alerts.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/app/alerts.html b/views/app/alerts.html index 64a81f4f5e..ee57e471b3 100644 --- a/views/app/alerts.html +++ b/views/app/alerts.html @@ -15,7 +15,7 @@

    5/4/2013

      -
    • Streaks. You get a GP & drop-% increase the longer you hold daily streaks (they stack). You also get a stacking badge 21-day streaks.
    • +
    • Streaks. You get a GP & drop-% increase the longer you hold daily streaks (they stack). You also get a stacking badge for each 21-day streak.

    5/3/2013

    From b468f052fd798faca22ddcd1b2c55c1f563836e5 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 12:10:34 +0100 Subject: [PATCH 15/21] remove "+ undefined" for (-)habit. Workaround, need to find why stats.gp is being set from (-)habit at all --- src/app/algos.coffee | 13 ++++++++----- src/app/browser.coffee | 4 +++- src/app/scoring.coffee | 5 ++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app/algos.coffee b/src/app/algos.coffee index 6ec2c97907..1e9ab67cdf 100644 --- a/src/app/algos.coffee +++ b/src/app/algos.coffee @@ -48,12 +48,15 @@ module.exports.hpModifier = (value, armorDef, helmDef, shieldDef, level, priorit Future use {priority} user-defined priority multiplier ### -module.exports.gpModifier = (value, modifier, priority='!', streak=0, model) -> - streakBonus = streak / 100 + 1 # eg, 1-day streak is 1.1, 2-day is 1.2, etc +module.exports.gpModifier = (value, modifier, priority='!', streak, model) -> val = value * modifier * priorityValue(priority) - afterStreak = val * streakBonus - model.set('_streakBonus', afterStreak - val) if (model and streak and (val > 0)) # can we do this without model? just global emit? - return afterStreak + if streak and model + streakBonus = streak / 100 + 1 # eg, 1-day streak is 1.1, 2-day is 1.2, etc + afterStreak = val * streakBonus + model.set('_streakBonus', afterStreak - val) if (val > 0) # can we do this without model? just global emit? + return afterStreak + else + return val ### Calculates the next task.value based on direction diff --git a/src/app/browser.coffee b/src/app/browser.coffee index 6c0bbb49dc..89368fd4ee 100644 --- a/src/app/browser.coffee +++ b/src/app/browser.coffee @@ -173,12 +173,14 @@ setupGrowlNotifications = (model) -> user.on 'set', 'stats.gp', (captures, args) -> money = captures - args + return unless !!money # why is this happening? gotta find where stats.gp is being set from (-)habit sign = if money < 0 then '-' else '+' statsNotification "#{sign} #{showCoins(money)}", 'gp' # Append Bonus bonus = model.get('_streakBonus') - if money > 0 and bonus + debugger + if (money > 0) and !!bonus bonus = 0.01 if bonus < 0.01 statsNotification "+ #{showCoins(bonus)} Streak Bonus!" model.del('_streakBonus') diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index 83ff56bd8f..8046d64c6d 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -119,7 +119,10 @@ score = (model, taskId, direction, times, batch, cron) -> level = user.get('stats.lvl') weaponStrength = items.items.weapon[user.get('items.weapon')].strength exp += algos.expModifier(delta,weaponStrength,level, priority) / 2 # / 2 hack for now bcause people leveling too fast - gp += algos.gpModifier(delta, 1, priority, streak, model) + if streak + gp += algos.gpModifier(delta, 1, priority, streak, model) + else + gp += algos.gpModifier(delta, 1, priority) subtractPoints = -> level = user.get('stats.lvl') From 3a259ae1c75f7460ba996dc3060b3ff05d84f97c Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 14:10:38 +0100 Subject: [PATCH 16/21] preparation for backer-gear setting by restricting sets to user.backer --- src/app/browser.coffee | 2 -- src/server/store.coffee | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/browser.coffee b/src/app/browser.coffee index 89368fd4ee..c954716d01 100644 --- a/src/app/browser.coffee +++ b/src/app/browser.coffee @@ -179,13 +179,11 @@ setupGrowlNotifications = (model) -> # Append Bonus bonus = model.get('_streakBonus') - debugger if (money > 0) and !!bonus bonus = 0.01 if bonus < 0.01 statsNotification "+ #{showCoins(bonus)} Streak Bonus!" model.del('_streakBonus') - user.on 'set', 'stats.lvl', (captures, args) -> if captures > args if captures is 1 and args is 0 diff --git a/src/server/store.coffee b/src/server/store.coffee index 7d26ec2ed7..af7f63d362 100644 --- a/src/server/store.coffee +++ b/src/server/store.coffee @@ -39,8 +39,11 @@ userAccess = (store) -> uid = captures.shift() attrPath = captures.join('.') # new array shifted left, after shift() was run + if attrPath is 'backer' + return accept(false) # we can only manually set this stuff in the database + # public access to users.*.party.invitation (TODO, lock down a bit more) - if (attrPath == 'party.invitation') + if attrPath is 'party.invitation' return accept(true) # Same session (user.id = this.session.userId) From c8e4386b4baff8ecfefcab2702e9a87d78595917 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 14:24:37 +0100 Subject: [PATCH 17/21] add backer, npc, and contributor achievements (still need to run database migrations for them) --- views/app/avatar.html | 17 +++++++++++++---- views/app/rewards.html | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/views/app/avatar.html b/views/app/avatar.html index 272695c3d4..c4e6e125c9 100644 --- a/views/app/avatar.html +++ b/views/app/avatar.html @@ -168,7 +168,6 @@ - @@ -177,10 +176,20 @@ - - + {{#if equal(@profile.backer.tier,800)}} +
    NPC +
    + {{/}} + {{#if @profile.backer.contributor}} +
    Contributor +
    + {{/}} + {{#if @profile.backer.tier}} +
    Kickstarter Backer (${{@profile.backer.tier}} Tier) +
    + {{/}} {#if @profile.achievements.streak}
    {@profile.achievements.streak} Streak Achievement(s)
    @@ -194,7 +203,7 @@
    {/} {#if @profile.achievements.ultimateGear} -
    Ultimate Gear +
    Ultimate Gear
    {/} diff --git a/views/app/rewards.html b/views/app/rewards.html index 76e1497f6d..f3be9ba7f1 100644 --- a/views/app/rewards.html +++ b/views/app/rewards.html @@ -1,7 +1,7 @@

    -

    You have earned the "Ultimate Gear" Achievement for upgrading to the maximum gear set! +
    You have earned the "Ultimate Gear" Achievement for upgrading to the maximum gear set!

    <@footer> From 0f1ec096efa970af408c79da7b894ca0444151f8 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 16:03:03 +0100 Subject: [PATCH 18/21] add backer.contributor & backer.npc for tavern & party chat --- src/app/party.coffee | 5 +++++ views/app/game-pane.html | 7 ++----- views/app/party.html | 16 +++++++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/app/party.coffee b/src/app/party.coffee index 87b091cb20..2c92cf873f 100644 --- a/src/app/party.coffee +++ b/src/app/party.coffee @@ -166,12 +166,17 @@ module.exports.app = (appExports, model, app) -> return unless /\S/.test text chat.unshift id: model.id() + contributor: user.get('backer.contributor') + npc: user.get('backer.npc') text: text user: helpers.username(model.get('_user.auth'), model.get('_user.profile.name')) timestamp: +new Date model.set(input, '') chat.remove 200 # keep a max messages cap + model.on 'unshift', '_party.chat', -> $('.chatroom [rel="tooltip"]').tooltip() + model.on 'unshift', '_tavern.chat.messages', -> $('.chatroom [rel="tooltip"]').tooltip() + appExports.partySendChat = -> sendChat('_party.chat', '_chatMessage') model.set '_user.party.lastMessageSeen', model.get('_party.chat')[0].id diff --git a/views/app/game-pane.html b/views/app/game-pane.html index 8bc8760a63..99a1e085a7 100644 --- a/views/app/game-pane.html +++ b/views/app/game-pane.html @@ -89,12 +89,9 @@
    -
      +
        {#each _tavern.chat.messages as :message} -
      • -
        - {:message.user} {:message.text} - {friendlyTimestamp(:message.timestamp)} -
      • +
      • {/}
diff --git a/views/app/party.html b/views/app/party.html index 75995c9ace..f56158561a 100644 --- a/views/app/party.html +++ b/views/app/party.html @@ -25,12 +25,9 @@
-
    +
      {#each _party.chat as :message} -
    • -
      - {:message.user} {:message.text} - {friendlyTimestamp(:message.timestamp)} -
    • +
    • {/}
@@ -58,3 +55,12 @@ {/} + + + +
+ + {@message.user} {@message.text} - {friendlyTimestamp(@message.timestamp)} + \ No newline at end of file From 7ebe61107857dee8aafec143b187863f8b289172 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 16:04:39 +0100 Subject: [PATCH 19/21] adjust achievement view logic for previous commit --- src/app/party.coffee | 5 +++-- src/server/store.coffee | 1 + views/app/avatar.html | 8 ++++---- views/app/game-pane.html | 2 +- views/app/party.html | 6 +++--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/app/party.coffee b/src/app/party.coffee index 2c92cf873f..5da19ece64 100644 --- a/src/app/party.coffee +++ b/src/app/party.coffee @@ -166,6 +166,7 @@ module.exports.app = (appExports, model, app) -> return unless /\S/.test text chat.unshift id: model.id() + uuid: user.get('id') contributor: user.get('backer.contributor') npc: user.get('backer.npc') text: text @@ -174,8 +175,8 @@ module.exports.app = (appExports, model, app) -> model.set(input, '') chat.remove 200 # keep a max messages cap - model.on 'unshift', '_party.chat', -> $('.chatroom [rel="tooltip"]').tooltip() - model.on 'unshift', '_tavern.chat.messages', -> $('.chatroom [rel="tooltip"]').tooltip() + model.on 'unshift', '_party.chat', -> $('.chat-message').tooltip() + model.on 'unshift', '_tavern.chat.messages', -> $('.chat-message').tooltip() appExports.partySendChat = -> sendChat('_party.chat', '_chatMessage') diff --git a/src/server/store.coffee b/src/server/store.coffee index af7f63d362..24e3b96828 100644 --- a/src/server/store.coffee +++ b/src/server/store.coffee @@ -94,6 +94,7 @@ partySystem = (store) -> 'party', 'profile', 'achievements', + 'backer', 'preferences', 'auth.local.username', 'auth.facebook.displayName') diff --git a/views/app/avatar.html b/views/app/avatar.html index c4e6e125c9..18fafba710 100644 --- a/views/app/avatar.html +++ b/views/app/avatar.html @@ -178,16 +178,16 @@ - {{#if equal(@profile.backer.tier,800)}} -
NPC + {{#if @profile.backer.npc}} +
{{@profile.backer.npc}} NPC
{{/}} {{#if @profile.backer.contributor}} -
Contributor +
{{@profile.backer.contributor}}
{{/}} {{#if @profile.backer.tier}} -
Kickstarter Backer (${{@profile.backer.tier}} Tier) +
Kickstarter Backer - ${{@profile.backer.tier}} Tier
{{/}} {#if @profile.achievements.streak} diff --git a/views/app/game-pane.html b/views/app/game-pane.html index 99a1e085a7..b3ebbb611e 100644 --- a/views/app/game-pane.html +++ b/views/app/game-pane.html @@ -89,7 +89,7 @@
-
    +
      {#each _tavern.chat.messages as :message}
    • {/} diff --git a/views/app/party.html b/views/app/party.html index f56158561a..25126ed950 100644 --- a/views/app/party.html +++ b/views/app/party.html @@ -25,7 +25,7 @@
      -
        +
          {#each _party.chat as :message}
        • {/} @@ -60,7 +60,7 @@
          - {@message.user} {@message.text} - {friendlyTimestamp(@message.timestamp)} + {{@message.user}} {{@message.text}} - {{friendlyTimestamp(@message.timestamp)}} \ No newline at end of file From 9b1bcb83670bc485121863ea89ac468b17f9da93 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sun, 5 May 2013 13:54:32 +0100 Subject: [PATCH 20/21] dynamic pets, fix #897 --- views/app/pets.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/app/pets.html b/views/app/pets.html index 9f73962b55..b65d8645af 100644 --- a/views/app/pets.html +++ b/views/app/pets.html @@ -124,9 +124,9 @@
          - {{#if ownsPet(@pet, _user.items.pets)}} + {#if ownsPet(@pet, _user.items.pets)} - {{else}} + {else} - {{/}} + {/}
          \ No newline at end of file From 671f843d30722a46f187efbfdf0707eaee5d8ec7 Mon Sep 17 00:00:00 2001 From: Stan Lindsey Date: Sun, 5 May 2013 17:00:59 +0100 Subject: [PATCH 21/21] csv export script --- migrations/csvexport.phy | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 migrations/csvexport.phy diff --git a/migrations/csvexport.phy b/migrations/csvexport.phy new file mode 100644 index 0000000000..f50799e73b --- /dev/null +++ b/migrations/csvexport.phy @@ -0,0 +1,10 @@ +import csv + +data = csv.reader(open('/home/slappybag/backrs/800dollar.csv', 'rb'), delimiter=",", quotechar='|') +column = [] + +for row in data: + column.append(row[9]) + +print "one:" +print column \ No newline at end of file