mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
feat(customize): Animal skins and ears
Implements a base-pet-themed set of avatar skins and head accessories, the latter of which has additional handling for the user to purchase them from the Avatar Customization page.
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
/* Make user and settings available for everyone through root scope.
|
||||
*/
|
||||
|
||||
habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout', 'ApiUrl', 'Payments','$sce',
|
||||
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout, ApiUrl, Payments,$sce) {
|
||||
habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout', 'ApiUrl', 'Payments','$sce','$window',
|
||||
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout, ApiUrl, Payments, $sce, $window) {
|
||||
var user = User.user;
|
||||
|
||||
var initSticky = _.once(function(){
|
||||
@@ -201,7 +201,40 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
||||
chart.draw(data, options);
|
||||
};
|
||||
|
||||
$rootScope.getGearArray = function(set){
|
||||
var flatGearArray = _.toArray(Content.gear.flat);
|
||||
|
||||
var filteredArray = _.where(flatGearArray, {gearSet: set});
|
||||
|
||||
return filteredArray;
|
||||
}
|
||||
|
||||
$rootScope.purchase = function(type, item){
|
||||
if (type == 'special') return User.user.ops.buySpecialSpell({params:{key:item.key}});
|
||||
|
||||
var gems = User.user.balance * 4;
|
||||
|
||||
var string = (type == 'weapon') ? window.env.t('weapon') : (type == 'armor') ? window.env.t('armor') : (type == 'head') ? window.env.t('headgear') : (type == 'shield') ? window.env.t('offhand') : (type == 'headAccessory') ? window.env.t('headAccessory') : (type == 'hatchingPotions') ? window.env.t('hatchingPotion') : (type == 'eggs') ? window.env.t('eggSingular') : (type == 'quests') ? window.env.t('quest') : (item.key == 'Saddle') ? window.env.t('foodSaddleText').toLowerCase() : type; // FIXME this is ugly but temporary, once the purchase modal is done this will be removed
|
||||
var price = ((((item.specialClass == "wizard") && (item.type == "weapon")) || item.gearSet == "animal") + 1);
|
||||
if (type == 'weapon' || type == 'armor' || type == 'head' || type == 'shield' || type == 'headAccessory') {
|
||||
if (User.user.items.gear.owned[item.key]) {
|
||||
if (User.user.preferences.costume) return User.user.ops.equip({params:{type: 'costume', key: item.key}});
|
||||
else {
|
||||
return User.user.ops.equip({params:{type: 'equipped', key: item.key}})
|
||||
}
|
||||
}
|
||||
if (gems < price) return $rootScope.openModal('buyGems');
|
||||
var message = window.env.t('buyThis', {text: string, price: price, gems: gems})
|
||||
if($window.confirm(message))
|
||||
User.user.ops.purchase({params:{type:"gear",key:item.key}});
|
||||
} else {
|
||||
if(gems < item.value) return $rootScope.openModal('buyGems');
|
||||
var message = window.env.t('buyThis', {text: string, price: item.value, gems: gems})
|
||||
if($window.confirm(message))
|
||||
User.user.ops.purchase({params:{type:type,key:item.key}});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
------------------------
|
||||
|
||||
Reference in New Issue
Block a user