mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-01 19:50:37 +00:00
59 lines
1.7 KiB
CoffeeScript
59 lines
1.7 KiB
CoffeeScript
|
|
_ = require 'underscore'
|
||
|
|
algos = require './algos'
|
||
|
|
items = require('habitrpg-shared/script/items').items
|
||
|
|
helpers = require('habitrpg-shared/script/helpers')
|
||
|
|
|
||
|
|
module.exports.setup = (view) ->
|
||
|
|
|
||
|
|
#misc
|
||
|
|
view.fn "percent", (x, y) ->
|
||
|
|
x=1 if x==0
|
||
|
|
Math.round(x/y*100)
|
||
|
|
view.fn 'indexOf', (str1, str2) ->
|
||
|
|
return false unless str1 && str2
|
||
|
|
str1.indexOf(str2) != -1
|
||
|
|
view.fn "round", Math.round
|
||
|
|
view.fn "floor", Math.floor
|
||
|
|
view.fn "ceil", Math.ceil
|
||
|
|
view.fn "lt", (a, b) -> a < b
|
||
|
|
view.fn 'gt', (a, b) -> a > b
|
||
|
|
view.fn "mod", (a, b) -> parseInt(a) % parseInt(b) == 0
|
||
|
|
view.fn "notEqual", (a, b) -> (a != b)
|
||
|
|
view.fn "and", -> _.reduce arguments, (cumm, curr) -> cumm && curr
|
||
|
|
view.fn "or", -> _.reduce arguments, (cumm, curr) -> cumm || curr
|
||
|
|
view.fn "truarr", (num) -> num-1
|
||
|
|
view.fn 'count', (arr) -> arr?.length or 0
|
||
|
|
|
||
|
|
#iCal
|
||
|
|
view.fn "encodeiCalLink", helpers.encodeiCalLink
|
||
|
|
|
||
|
|
#User
|
||
|
|
view.fn "gems", (balance) -> return balance/0.25
|
||
|
|
view.fn "username", helpers.username
|
||
|
|
view.fn "tnl", algos.tnl
|
||
|
|
view.fn 'equipped', helpers.equipped
|
||
|
|
view.fn "gold", helpers.gold
|
||
|
|
view.fn "silver", helpers.silver
|
||
|
|
|
||
|
|
#Stats
|
||
|
|
view.fn 'userStr', helpers.userStr
|
||
|
|
view.fn 'totalStr', helpers.totalStr
|
||
|
|
view.fn 'userDef', helpers.userDef
|
||
|
|
view.fn 'totalDef', helpers.totalDef
|
||
|
|
view.fn 'itemText', helpers.itemText
|
||
|
|
view.fn 'itemStat', helpers.itemStat
|
||
|
|
|
||
|
|
#Pets
|
||
|
|
view.fn 'ownsPet', helpers.ownsPet
|
||
|
|
|
||
|
|
#Tasks
|
||
|
|
view.fn 'taskClasses', helpers.taskClasses
|
||
|
|
|
||
|
|
#Chat
|
||
|
|
view.fn 'friendlyTimestamp',helpers.friendlyTimestamp
|
||
|
|
view.fn 'newChatMessages', helpers.newChatMessages
|
||
|
|
view.fn 'relativeDate', helpers.relativeDate
|
||
|
|
|
||
|
|
#Tags
|
||
|
|
view.fn 'noTags', helpers.noTags
|
||
|
|
view.fn 'appliedTags', helpers.appliedTags
|