mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
Began refactor of stats page
This commit is contained in:
@@ -159,22 +159,26 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.controller("MemberModalCtrl", ['$scope', '$rootScope', 'Members', 'Shared', '$http', 'Notification', 'Groups', 'Chat', '$controller',
|
.controller("MemberModalCtrl", ['$scope', '$rootScope', 'Members', 'Shared', '$http', 'Notification', 'Groups', 'Chat', '$controller', 'Stats',
|
||||||
function($scope, $rootScope, Members, Shared, $http, Notification, Groups, Chat, $controller) {
|
function($scope, $rootScope, Members, Shared, $http, Notification, Groups, Chat, $controller, Stats) {
|
||||||
|
|
||||||
$controller('RootCtrl', {$scope: $scope});
|
$controller('RootCtrl', {$scope: $scope});
|
||||||
|
|
||||||
$scope.timestamp = function(timestamp){
|
$scope.timestamp = function(timestamp){
|
||||||
return moment(timestamp).format($rootScope.User.user.preferences.dateFormat.toUpperCase());
|
return moment(timestamp).format($rootScope.User.user.preferences.dateFormat.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.statCalc = Stats;
|
||||||
|
|
||||||
// We watch Members.selectedMember because it's asynchronously set, so would be a hassle to handle updates here
|
// We watch Members.selectedMember because it's asynchronously set, so would be a hassle to handle updates here
|
||||||
$scope.$watch( function() { return Members.selectedMember; }, function (member) {
|
$scope.$watch( function() { return Members.selectedMember; }, function (member) {
|
||||||
if(member)
|
if(member) {
|
||||||
member.petCount = Shared.countPets($rootScope.countExists(member.items.pets), member.items.pets);
|
member.petCount = Shared.countPets($rootScope.countExists(member.items.pets), member.items.pets);
|
||||||
member.mountCount = Shared.countMounts($rootScope.countExists(member.items.mounts), member.items.mounts);
|
member.mountCount = Shared.countMounts($rootScope.countExists(member.items.mounts), member.items.mounts);
|
||||||
$scope.profile = member;
|
$scope.profile = member;
|
||||||
$scope.e = member.items.gear.equipped;
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.sendPrivateMessage = function(uuid, message){
|
$scope.sendPrivateMessage = function(uuid, message){
|
||||||
// Don't do anything if the user somehow gets here without a message.
|
// Don't do anything if the user somehow gets here without a message.
|
||||||
if (!message) return;
|
if (!message) return;
|
||||||
@@ -184,27 +188,31 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
|||||||
$rootScope.User.sync();
|
$rootScope.User.sync();
|
||||||
$scope.$close();
|
$scope.$close();
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
$scope.gift = {
|
$scope.gift = {
|
||||||
type: 'gems',
|
type: 'gems',
|
||||||
gems: {amount:0, fromBalance:true},
|
gems: {amount:0, fromBalance:true},
|
||||||
subscription: {key:''},
|
subscription: {key:''},
|
||||||
message:''
|
message:''
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.sendGift = function(uuid, gift){
|
$scope.sendGift = function(uuid, gift){
|
||||||
$http.post('/api/v2/members/'+uuid+'/gift', gift).success(function(){
|
$http.post('/api/v2/members/'+uuid+'/gift', gift).success(function(){
|
||||||
Notification.text('Gift sent!')
|
Notification.text('Gift sent!')
|
||||||
$rootScope.User.sync();
|
$rootScope.User.sync();
|
||||||
$scope.$close();
|
$scope.$close();
|
||||||
})
|
})
|
||||||
}
|
};
|
||||||
|
|
||||||
$scope.reportAbuse = function(reporter, message, groupId) {
|
$scope.reportAbuse = function(reporter, message, groupId) {
|
||||||
message.flags[reporter._id] = true;
|
message.flags[reporter._id] = true;
|
||||||
Chat.utils.flagChatMessage({gid: groupId, messageId: message.id}, undefined, function(data){
|
Chat.utils.flagChatMessage({gid: groupId, messageId: message.id}, undefined, function(data){
|
||||||
Notification.text(window.env.t('abuseReported'));
|
Notification.text(window.env.t('abuseReported'));
|
||||||
$scope.$close();
|
$scope.$close();
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
$scope.clearFlagCount = function(message, groupId) {
|
$scope.clearFlagCount = function(message, groupId) {
|
||||||
Chat.utils.clearFlagCount({gid: groupId, messageId: message.id}, undefined, function(data){
|
Chat.utils.clearFlagCount({gid: groupId, messageId: message.id}, undefined, function(data){
|
||||||
message.flagCount = 0;
|
message.flagCount = 0;
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
habitrpg.controller("UserCtrl", ['$rootScope', '$scope', '$location', 'User', '$http', '$state', 'Guide', 'Shared',
|
habitrpg.controller("UserCtrl", ['$rootScope', '$scope', '$location', 'User', '$http', '$state', 'Guide', 'Shared', 'Content', 'Stats',
|
||||||
function($rootScope, $scope, $location, User, $http, $state, Guide, Shared) {
|
function($rootScope, $scope, $location, User, $http, $state, Guide, Shared, Content, Stats) {
|
||||||
$scope.profile = User.user;
|
$scope.profile = User.user;
|
||||||
$scope.profile.petCount = Shared.countPets($rootScope.countExists($scope.profile.items.pets), $scope.profile.items.pets);
|
$scope.profile.petCount = Shared.countPets($rootScope.countExists($scope.profile.items.pets), $scope.profile.items.pets);
|
||||||
$scope.profile.mountCount = Shared.countMounts($rootScope.countExists($scope.profile.items.mounts), $scope.profile.items.mounts);
|
$scope.profile.mountCount = Shared.countMounts($rootScope.countExists($scope.profile.items.mounts), $scope.profile.items.mounts);
|
||||||
|
|
||||||
|
$scope.statCalc = Stats;
|
||||||
|
|
||||||
$scope.hideUserAvatar = function() {
|
$scope.hideUserAvatar = function() {
|
||||||
$(".userAvatar").hide();
|
$(".userAvatar").hide();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,90 +1,71 @@
|
|||||||
|
mixin basicRow(label, value)
|
||||||
|
tr&attributes(attributes)
|
||||||
|
td
|
||||||
|
strong=env.t(label)
|
||||||
|
| : #{value}
|
||||||
|
|
||||||
|
mixin statList(calculatedStat, popover, text, useOneTimeBinding)
|
||||||
|
- var binding = useOneTimeBinding ? "::" : ""
|
||||||
|
li(ng-if=binding + '#{calculatedStat} > 0')
|
||||||
|
span.hint(popover-title=env.t('#{popover}'), popover-trigger='mouseenter',
|
||||||
|
popover-placement='top', popover=env.t('#{popover}Text'))
|
||||||
|
=env.t(text)
|
||||||
|
=': {{' + binding + calculatedStat + '}}'
|
||||||
|
|
||||||
h4(class=mobile?'item item-divider':'')=env.t('stats')
|
h4(class=mobile?'item item-divider':'')=env.t('stats')
|
||||||
table.table.table-striped
|
table.table.table-striped
|
||||||
tr
|
+basicRow('health', '{{::statCalc.hpDisplay(profile.stats.hp)}}')
|
||||||
td
|
+basicRow('mana', '{{statCalc.mpDisplay(profile)}}')(ng-if='profile.stats.lvl >= 10 && !profile.preferences.disableClasses')
|
||||||
strong=env.t('health')
|
+basicRow('gold', '{{::statCalc.goldDisplay(profile.stats.gp)}}')
|
||||||
| : {{Math.ceil(profile.stats.hp)}} / {{::Shared.maxHealth}}
|
+basicRow('level', '{{::profile.stats.lvl}}')
|
||||||
tr(ng-if='profile.stats.lvl >= 10 && !profile.preferences.disableClasses')
|
+basicRow('experience', '{{::statCalc.expDisplay(profile)}}')
|
||||||
td
|
|
||||||
strong=env.t('mana')
|
|
||||||
| : {{Math.floor(profile.stats.mp)}} / {{profile._statsComputed.maxMP}}
|
|
||||||
tr
|
|
||||||
td
|
|
||||||
strong=env.t('gold')
|
|
||||||
| : {{Math.floor(profile.stats.gp)}}
|
|
||||||
tr
|
|
||||||
td
|
|
||||||
strong=env.t('level')
|
|
||||||
| : {{profile.stats.lvl}}
|
|
||||||
tr
|
|
||||||
td
|
|
||||||
strong=env.t('experience')
|
|
||||||
| : {{Math.floor(profile.stats.exp)}} / {{Shared.tnl(profile.stats.lvl)}}
|
|
||||||
|
|
||||||
unless mobile
|
unless mobile
|
||||||
h4.stats-equipment(class=mobile?'item item-divider':'',ng-show='user.flags.itemsEnabled')=env.t('equipment')
|
h4.stats-equipment(class=mobile?'item item-divider':'',
|
||||||
|
ng-show='user.flags.itemsEnabled')=env.t('equipment')
|
||||||
table.table.table-striped(ng-show='user.flags.itemsEnabled')
|
table.table.table-striped(ng-show='user.flags.itemsEnabled')
|
||||||
tr(ng-repeat='(k,v) in profile.items.gear.equipped', ng-init='piece=Content.gear.flat[v]', ng-show='piece')
|
tr(ng-repeat='(itemType,gear) in profile.items.gear.equipped',
|
||||||
|
ng-init='piece=Content.gear.flat[gear]', ng-show='piece')
|
||||||
td
|
td
|
||||||
strong {{piece.text()}}:
|
strong {{piece.text()}}:
|
||||||
span(ng-repeat='stat in ["str","con","per","int"]', ng-show='piece[stat]') {{piece[stat]}} {{stat.toUpperCase()}}
|
span(ng-repeat='stat in ["str","con","per","int"]', ng-show='piece[stat]') {{piece[stat]}} {{stat.toUpperCase()}}
|
||||||
|
|
||||||
h4(class=mobile?'item item-divider':'')=env.t('attributes')
|
h4(class=mobile?'item item-divider':'')=env.t('attributes')
|
||||||
|
|
||||||
table.table.table-striped
|
table.table.table-striped
|
||||||
each v,k in { str: {title:"strength",popover:'strengthText'},int: {title:"intelligence",popover:'intText'},con: {title:"constitution",popover:'conText'},per: {title:"perception",popover:'perText'} }
|
each statInfo, stat in { str: {title:"strength",popover:'strengthText'},int: {title:"intelligence",popover:'intText'},con: {title:"constitution",popover:'conText'},per: {title:"perception",popover:'perText'} }
|
||||||
tr
|
tr
|
||||||
td
|
td
|
||||||
span.hint(popover-title=env.t(v.title), popover-placement='right', popover=env.t(v.popover), popover-trigger='mouseenter', style='margin-right:3px')
|
span.hint(popover-title=env.t(statInfo.title), popover-placement='right',
|
||||||
strong=env.t(v.title)
|
popover=env.t(statInfo.popover), popover-trigger='mouseenter')
|
||||||
span
|
strong=env.t(statInfo.title)
|
||||||
strong : {{profile._statsComputed.#{k}}}
|
strong : {{profile._statsComputed.#{stat}}}
|
||||||
td
|
|
||||||
ul.list-unstyled(ng-init='g=Content.gear.flat;e=profile.items.gear.equipped')
|
td: ul.list-unstyled
|
||||||
li(ng-show='profile.stats.lvl > 1')
|
+statList('statCalc.levelBonus(profile.stats.lvl)', 'levelBonus', 'level', true)
|
||||||
span.hint(popover-title=env.t('levelBonus'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('levelBonusText'))=env.t('level')
|
+statList('statCalc.equipmentStatBonus("' + stat + '", profile.items.gear.equipped)', 'equipmentBonus', 'equipment', true)
|
||||||
|: {{Math.ceil((Math.min(profile.stats.lvl - 1, 100)) / 2)}}
|
+statList('statCalc.classBonus(profile, "' + stat + '")', 'classBonus', 'classEquipBonus')
|
||||||
li(ng-show='g[e.weapon].#{k} + g[e.armor].#{k} + g[e.head].#{k} + g[e.shield].#{k} > 0')
|
+statList('profile.stats.' + stat, 'allocatedPoints', 'allocated')
|
||||||
span.hint(popover-title=env.t('equipment'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('equipmentBonusText'))=env.t('equipment')
|
+statList('profile.stats.buffs.' + stat, 'buffs', 'buffs', true)
|
||||||
|: {{g[e.weapon].#{k} + g[e.armor].#{k} + g[e.head].#{k} + g[e.shield].#{k} || 0}}
|
|
||||||
li(ng-show='profile._statsComputed.#{k} - profile.stats.buffs.#{k} - Math.ceil((Math.min(profile.stats.lvl - 1, 100)) / 2) - g[e.weapon].#{k} - g[e.armor].#{k} - g[e.head].#{k} - g[e.shield].#{k} - profile.stats.#{k} > 0')
|
|
||||||
span.hint(popover-title=env.t('classBonus'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('classBonusText'))=env.t('classEquipBonus')
|
|
||||||
|: {{profile._statsComputed.#{k} - profile.stats.buffs.#{k} - Math.ceil((Math.min(profile.stats.lvl - 1,100)) / 2) - g[e.weapon].#{k} - g[e.armor].#{k} - g[e.head].#{k} - g[e.shield].#{k} - profile.stats.#{k}}}
|
|
||||||
li(ng-show='profile.stats.#{k} > 0')
|
|
||||||
span.hint(popover-title=env.t('allocatedPoints'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('allocatedPointsText'))=env.t('allocated')
|
|
||||||
|: {{profile.stats.#{k} || 0}}
|
|
||||||
li(ng-show='profile.stats.buffs.#{k} > 0')
|
|
||||||
span.hint(popover-title=env.t('buffs'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('buffsText'))=env.t('buffs')
|
|
||||||
|: {{profile.stats.buffs.#{k} || 0}}
|
|
||||||
tr(ng-if='profile.stats.buffs.stealth')
|
tr(ng-if='profile.stats.buffs.stealth')
|
||||||
td
|
td(colspan='2')
|
||||||
span.hint(popover-title=env.t('stealth'), popover-trigger='mouseenter', popover-placement='right', popover=env.t('stealthNewDay'))
|
strong.hint(popover-title=env.t('stealth'), popover-trigger='mouseenter',
|
||||||
strong
|
popover-placement='right', popover=env.t('stealthNewDay'))
|
||||||
=env.t('stealth')
|
=env.t('stealth')
|
||||||
strong : {{profile.stats.buffs.stealth}}
|
strong : {{profile.stats.buffs.stealth}}
|
||||||
td
|
|
||||||
tr(ng-if='profile.stats.buffs.streaks')
|
tr(ng-if='profile.stats.buffs.streaks')
|
||||||
td
|
td(colspan='2')
|
||||||
strong.hint(popover-title=env.t('streaksFrozen'), popover-trigger='mouseenter', popover-placement='right', popover=env.t('streaksFrozenText'))=env.t('streaksFrozen')
|
strong.hint(popover-title=env.t('streaksFrozen'), popover-trigger='mouseenter',
|
||||||
td
|
popover-placement='right', popover=env.t('streaksFrozenText'))
|
||||||
|
=env.t('streaksFrozen')
|
||||||
|
|
||||||
h4(class=mobile?'item item-divider':'',ng-if='user.flags.dropsEnabled')=env.t('pets')
|
h4(class=mobile?'item item-divider':'',ng-if='user.flags.dropsEnabled')=env.t('pets')
|
||||||
table.table.table-striped(ng-if='user.flags.dropsEnabled')
|
table.table.table-striped(ng-if='user.flags.dropsEnabled')
|
||||||
tr
|
+basicRow('petsFound','{{_.size(profile.items.pets)}}')
|
||||||
td
|
+basicRow('beastMasterProgress','{{profile.petCount}}/90')
|
||||||
strong=env.t('petsFound')
|
|
||||||
| : {{_.size(profile.items.pets)}}
|
|
||||||
tr
|
|
||||||
td
|
|
||||||
strong=env.t('beastMasterProgress')
|
|
||||||
| : {{profile.petCount}}/90
|
|
||||||
|
|
||||||
h4(class=mobile?'item item-divider':'', ng-if='user.flags.dropsEnabled')=env.t('mounts')
|
h4(class=mobile?'item item-divider':'', ng-if='user.flags.dropsEnabled')=env.t('mounts')
|
||||||
table.table.table-striped(ng-if='user.flags.dropsEnabled')
|
table.table.table-striped(ng-if='user.flags.dropsEnabled')
|
||||||
tr
|
+basicRow('mountsTamed','{{_.size(profile.items.mounts)}}')
|
||||||
td
|
+basicRow('mountMasterProgress','{{profile.mountCount}}/90')
|
||||||
strong=env.t('mountsTamed')
|
|
||||||
| : {{_.size(profile.items.mounts)}}
|
|
||||||
tr
|
|
||||||
td
|
|
||||||
strong=env.t('mountMasterProgress')
|
|
||||||
| : {{profile.mountCount}}/90
|
|
||||||
|
|||||||
Reference in New Issue
Block a user