mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-01 07:21:15 +00:00
convert armor model.fn to a view.fn, so we can use on party too
This commit is contained in:
parent
7f9ef40251
commit
fcadcb000f
4 changed files with 22 additions and 14 deletions
|
|
@ -54,4 +54,16 @@ module.exports.viewHelpers = (view) ->
|
|||
a < b
|
||||
|
||||
view.fn "tokens", (money) ->
|
||||
return money/0.25
|
||||
return money/0.25
|
||||
|
||||
view.fn 'currentArmor', (user) ->
|
||||
console.log user
|
||||
[gender, armor, armorSet] = [user.preferences.gender, user.items.armor, user.preferences.armorSet]
|
||||
if gender == 'f'
|
||||
str = "armor#{armor}_f"
|
||||
if parseInt(armor) > 1
|
||||
armorSet = if armorSet then armorSet else 'v1'
|
||||
str += '_' + armorSet
|
||||
return "#{str}.png"
|
||||
else
|
||||
return "armor#{armor}_m.png"
|
||||
|
|
@ -24,16 +24,6 @@ setupModelFns = (model) ->
|
|||
# also update in scoring.coffee. TODO create a function accessible in both locations
|
||||
(lvl*100)/5
|
||||
|
||||
model.fn '_user._armor', '_user.items.armor', '_user.preferences.armorSet', '_user.preferences.gender', (armor, armorSet, gender) ->
|
||||
if gender == 'f'
|
||||
str = "armor#{armor}_f"
|
||||
if parseInt(armor) > 1
|
||||
armorSet = if armorSet then armorSet else 'v1'
|
||||
str += '_' + armorSet
|
||||
return "#{str}.png"
|
||||
else
|
||||
"armor#{armor}_m.png"
|
||||
|
||||
# model.fn '_user._friends', '_user.friends', (friendIds) ->
|
||||
# model.fetch model.query('users').friends(friendIds), (err, friends) ->
|
||||
# model.set '_view.friends', friends
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ module.exports = (store) ->
|
|||
###
|
||||
store.query.expose "users", "friends", (ids) ->
|
||||
@where("id").within(ids)
|
||||
.only('stats', 'items', 'auth.local.username', 'auth.facebook.displayName')
|
||||
.only('stats', 'preferences.gender', 'preferences.armorSet', 'items', 'auth.local.username', 'auth.facebook.displayName')
|
||||
|
||||
store.queryAccess "users", "friends", (ids, next) ->
|
||||
next(true) # no harm in public user stats
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@
|
|||
<td id="avatar">
|
||||
<div class='avatar-sprites'>
|
||||
<img class='weapon weapon-{_user.items.weapon}' src="/img/BrowserQuest/habitrpg_mods/weapon{_user.items.weapon}.png" />
|
||||
<img class='armor armor-{_user.items.armor}' src="/img/BrowserQuest/habitrpg_mods/{_user._armor}" />
|
||||
<img class='armor armor-{_user.items.armor}' src="/img/BrowserQuest/habitrpg_mods/{currentArmor(_user)}" />
|
||||
</div>
|
||||
<div id="lvl"><span class="badge badge-info">Lvl {_user.stats.lvl}</span></div>
|
||||
</td>
|
||||
|
|
@ -195,7 +195,13 @@
|
|||
<ul>
|
||||
{#each _friends as :friend}
|
||||
<li>
|
||||
{:friend.id}
|
||||
<div class="friend-avatar">
|
||||
<div class='avatar-sprites'>
|
||||
<img class='weapon weapon-{:friend.items.weapon}' src="/img/BrowserQuest/habitrpg_mods/weapon{:friend.items.weapon}.png" />
|
||||
<img class='armor armor-{:friend.items.armor}' src="/img/BrowserQuest/habitrpg_mods/{currentArmor(:friend)}" />
|
||||
</div>
|
||||
<div id="lvl"><span class="badge badge-info">Lvl {_user.stats.lvl}</span></div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
{/}
|
||||
|
|
|
|||
Loading…
Reference in a new issue