Merge branch 'master' into classes
Conflicts: dist/habitrpg-shared.js dist/spritesheets.css script/items.coffee
This commit is contained in:
+8
-5
@@ -372,11 +372,14 @@ updateStats = (user, newStats, options={}) ->
|
||||
obj.cron = (user, options={}) ->
|
||||
[paths, now] = [options.paths || {}, +options.now || +new Date]
|
||||
|
||||
# New user (!lastCron, lastCron==new) or it got busted somehow, maybe they went to a different timezone
|
||||
# FIXME move this to pre-save in mongoose
|
||||
if !user.lastCron? or user.lastCron is 'new' or moment(user.lastCron).isAfter(now)
|
||||
user.lastCron = now; paths['lastCron'] = true
|
||||
return
|
||||
# They went to a different timezone
|
||||
# FIXME:
|
||||
# (1) This exit-early code isn't taking timezone into consideration!!
|
||||
# (2) Won't switching timezones be handled automatically client-side anyway? (aka, can we just remove this code?)
|
||||
# (3) And if not, is this the correct way to handle switching timezones
|
||||
# if moment(user.lastCron).isAfter(now)
|
||||
# user.lastCron = now
|
||||
# return
|
||||
|
||||
daysMissed = helpers.daysSince user.lastCron, _.defaults({now}, user.preferences)
|
||||
return unless daysMissed > 0
|
||||
|
||||
@@ -8,7 +8,7 @@ items = require('./items.coffee')
|
||||
{now} is also passed in for various purposes, one example being the test scripts scripts testing different "now" times
|
||||
###
|
||||
sanitizeOptions = (o) ->
|
||||
dayStart = if (o.dayStart and 0 <= +o.dayStart <= 24) then +o.dayStart else 0
|
||||
dayStart = if (!_.isNaN(+o.dayStart) and 0 <= +o.dayStart <= 24) then +o.dayStart else 0
|
||||
timezoneOffset = if o.timezoneOffset then +(o.timezoneOffset) else +moment().zone()
|
||||
now = if o.now then moment(o.now).zone(timezoneOffset) else moment(+new Date).zone(timezoneOffset)
|
||||
# return a new object, we don't want to add "now" to user object
|
||||
@@ -20,7 +20,7 @@ startOfWeek = (options={}) ->
|
||||
|
||||
startOfDay = (options={}) ->
|
||||
o = sanitizeOptions(options)
|
||||
moment(o.now).startOf('day').add('h', options.dayStart)
|
||||
moment(o.now).startOf('day').add('h', o.dayStart)
|
||||
|
||||
dayMapping = {0:'su',1:'m',2:'t',3:'w',4:'th',5:'f',6:'s'}
|
||||
|
||||
@@ -113,7 +113,7 @@ module.exports =
|
||||
showWeapon: true
|
||||
showShield: true
|
||||
apiToken: uuid() # set in newUserObject below
|
||||
lastCron: +new Date #this will be replaced with `+new Date` on first run
|
||||
lastCron: +new Date
|
||||
balance: 0
|
||||
flags:
|
||||
partyEnabled: false
|
||||
@@ -363,9 +363,8 @@ module.exports =
|
||||
|
||||
countPets: (originalCount, pets) ->
|
||||
count = if originalCount? then originalCount else _.size(pets)
|
||||
count-- if pets["Wolf-Veteran"]
|
||||
count-- if pets["Wolf-Cerberus"]
|
||||
count-- if pets["Dragon-Hydra"]
|
||||
for pet of items.items.specialPets
|
||||
count-- if pets[pet]
|
||||
count
|
||||
|
||||
###
|
||||
|
||||
+7
-1
@@ -360,6 +360,12 @@ _.each items.eggs, (egg,k) ->
|
||||
notes: "Find a hatching potion to pour on this egg, and it will hatch into a #{egg.adjective} #{egg.text}."
|
||||
mountText: egg.text
|
||||
|
||||
items.specialPets =
|
||||
'Wolf-Veteran': true
|
||||
'Wolf-Cerberus': true
|
||||
'Dragon-Hydra': true
|
||||
'Turkey-Base': true
|
||||
|
||||
items.hatchingPotions =
|
||||
Base: value: 2, text: 'Base'
|
||||
White: value: 2, text: 'White'
|
||||
@@ -442,4 +448,4 @@ module.exports.updateStore = (user) ->
|
||||
module.exports.getItem = getItem = (user, type) ->
|
||||
item = items.gear.flat[user.items.gear.current[type]]
|
||||
return items.gear.flat["#{type}_#{_class(user)}_0"] unless item
|
||||
item
|
||||
item
|
||||
|
||||
Reference in New Issue
Block a user