mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-01 11:40:25 +00:00
Save eggs as object so we can grab text easily
This commit is contained in:
parent
aece4b1a41
commit
ab332d5f23
5 changed files with 15 additions and 16 deletions
|
|
@ -1,11 +1,11 @@
|
|||
moment = require('moment')
|
||||
moment = require 'moment'
|
||||
|
||||
# Absolute diff between two dates
|
||||
module.exports.daysBetween = (yesterday, now, dayStart) ->
|
||||
#sanity-check reset-time (is it 24h time?)
|
||||
dayStart = 0 unless (dayStart? and (dayStart = parseInt(dayStart)) and dayStart >= 0 and dayStart <= 24)
|
||||
Math.abs moment(yesterday).startOf('day').add('h', dayStart).diff(moment(now), 'days')
|
||||
|
||||
|
||||
module.exports.dayMapping = dayMapping = {0:'su',1:'m',2:'t',3:'w',4:'th',5:'f',6:'s',7:'su'}
|
||||
|
||||
# http://stackoverflow.com/questions/2532218/pick-random-property-from-a-javascript-object
|
||||
|
|
@ -23,7 +23,7 @@ module.exports.viewHelpers = (view) ->
|
|||
view.fn "percent", (x, y) ->
|
||||
x=1 if x==0
|
||||
Math.round(x/y*100)
|
||||
|
||||
|
||||
view.fn "round", (num) ->
|
||||
Math.round num
|
||||
|
||||
|
|
@ -32,11 +32,11 @@ module.exports.viewHelpers = (view) ->
|
|||
|
||||
view.fn "ceil", (num) ->
|
||||
Math.ceil num
|
||||
|
||||
|
||||
view.fn "lt", (a, b) ->
|
||||
a < b
|
||||
view.fn 'gt', (a, b) -> a > b
|
||||
|
||||
|
||||
view.fn "tokens", (gp) ->
|
||||
return gp/0.25
|
||||
|
||||
|
|
@ -46,5 +46,3 @@ module.exports.viewHelpers = (view) ->
|
|||
view.fn "encodeiCalLink", (uid, apiToken) ->
|
||||
loc = window?.location.host or process.env.BASE_URL
|
||||
encodeURIComponent "http://#{loc}/v1/users/#{uid}/calendar.ics?apiToken=#{apiToken}"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ items = module.exports.items =
|
|||
{text: 'Tiger Cub', name: 'TigerCub', value: 3}
|
||||
#{text: 'Polar Bear Cub', name: 'PolarBearCub', value: 3} #commented out because there are no polarbear modifiers yet, special drop?
|
||||
{text: 'Panda Cub', name: 'PandaCub', value: 3}
|
||||
{text: 'Lion Cub', id: 'LionCub', value: 3}
|
||||
{text: 'Lion Cub', name: 'LionCub', value: 3}
|
||||
{text: 'Fox', name: 'Fox', value: 3}
|
||||
{text: 'Flying Pig', name: 'FlyingPig', value: 3}
|
||||
{text: 'Dragon', name: 'Dragon', value: 3}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ module.exports.app = (appExports, model) ->
|
|||
user.on 'set', 'flags.dropsEnabled', (captures, args) ->
|
||||
return unless captures == true
|
||||
|
||||
droppedEgg = randomProp pets
|
||||
droppedFood = randomProp pets
|
||||
egg = randomProp pets
|
||||
|
||||
user.push 'items.eggs', droppedEgg.name
|
||||
user.push 'items.food', droppedFood.name
|
||||
dontPersist = model._dontPersist
|
||||
|
||||
model._dontPersist = false if dontPersist
|
||||
user.push 'items.eggs', egg
|
||||
model._dontPersist = true if dontPersist
|
||||
|
||||
# do drops enabled stuff
|
||||
$('#dropsEnabled-modal').show()
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@
|
|||
<p>You don't have any eggs yet.</p>
|
||||
{/if}
|
||||
{#each _user.items.eggs as :egg}
|
||||
{:egg}
|
||||
<p>{:egg.text}</p>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
<modals:>
|
||||
<app:modals:modal modalId='dropsEnabled-modal' header="Drops Enabled!">
|
||||
<app:userTokens/>
|
||||
<p>You've unlocked the drop system.</p>
|
||||
<p>Here's your first egg! {_user.items.eggs.0}</p>
|
||||
<p>Here's your first egg! {_user.items.eggs.0.text}</p>
|
||||
<p>Feed it some meat to get it to hatch.</p>
|
||||
<@footer>
|
||||
<button data-dismiss="modal" class="btn btn-success">Ok</button>
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
</@footer>
|
||||
</app:modals:modal>
|
||||
Loading…
Reference in a new issue