mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
* feat(incentives): login bennies WIP * feat(content): incentive prize content WIP * fix(content): placeholders pass tests * WIP(content): Bard instrument placeholder * feat(content): Incentives build * chore(sprites): compile and fix some strings * WIP(incentives): quests and backgrounds * fix(quests): correct buy/launch handling * [WIP] Incentives rewarding (#8226) * Added login incentive rewards * Updated incentive rewards * Added incentive modal and updated notification structure * Added analytics to sleeping * Added login incentives to user analytics * Fixed unit tests and ensured that prizes are incremented and not replaced * Updated style of daily login incentive modal * Added rewards modal * Added translations * Added loigin incentive ui elements to profile * Updated login incentives structure and abstracted to common.content * Added dynamic display for login incentives on profile * Added purple potion image * Updated daily login modal * Fixed progress calculation * Added bard gear * Updated login incentive rewards * Fixed styles and text * Added multiple read for notifications * Fixed lint issues * Fixed styles and added 50 limit * Updated quest keys * Added login incentives reward page * Fixed tests * Fixed linting and tests * Read named notifications route. Add image for backgrounds * Fixed style issues and added tranlsations to login incentive notification * Hided abiltiy to purchase incentive backgrounds and added message to detail how to unlock * Updated awarded message * Fixed text and updated progress counter to display better * Fixed purple potion reward text * Fixed check in backgrouns reward text * fix(quest): pass tests * Added display of multiple rewards * Updated modal styles * Fixed neagtive 50 issue * Remvoed total count from daily login incentives modal * Fixed magic paw display * fix(awards): give bunnies again * WIP(incentives): more progress on BG shop * fix(incentives): actually award backgrounds * fix(incentives): more BG fixy * fix(backgrounds): don't gem-buy checkin bgs * Added dust bunny notification * fix(incentives): don't redisplay bunny award * chore(news): Bailey and different promo sprite
108 lines
4.0 KiB
JavaScript
108 lines
4.0 KiB
JavaScript
"use strict";
|
|
|
|
habitrpg.controller("UserCtrl", ['$rootScope', '$scope', '$location', 'User', '$http', '$state', 'Guide', 'Shared', 'Content', 'Stats', 'Social', 'Costume',
|
|
function($rootScope, $scope, $location, User, $http, $state, Guide, Shared, Content, Stats, Social, Costume) {
|
|
$scope.profile = User.user;
|
|
|
|
$scope.statCalc = Stats;
|
|
|
|
$scope.loadWidgets = Social.loadWidgets;
|
|
|
|
$scope.hideUserAvatar = function() {
|
|
$(".userAvatar").hide();
|
|
};
|
|
|
|
$scope.$watch('_editing.profile', function(value){
|
|
if(value === true) $scope.editingProfile = angular.copy(User.user.profile);
|
|
});
|
|
|
|
$scope.costume = Costume;
|
|
|
|
$scope.allocate = function(stat){
|
|
User.allocate({query:{stat:stat}});
|
|
}
|
|
|
|
$scope.changeClass = function(klass){
|
|
if (!klass) {
|
|
if (!confirm(window.env.t('sureReset')))
|
|
return;
|
|
return User.changeClass({});
|
|
}
|
|
|
|
User.changeClass({query:{class:klass}});
|
|
$scope.selectedClass = undefined;
|
|
Shared.updateStore(User.user);
|
|
Guide.goto('classes', 0,true);
|
|
}
|
|
|
|
$scope.save = function(){
|
|
var values = {};
|
|
_.each($scope.editingProfile, function(value, key){
|
|
// Using toString because we need to compare two arrays (websites)
|
|
var curVal = $scope.profile.profile[key];
|
|
if(!curVal || $scope.editingProfile[key].toString() !== curVal.toString())
|
|
values['profile.' + key] = value;
|
|
});
|
|
User.set(values);
|
|
$scope._editing.profile = false;
|
|
}
|
|
|
|
$scope.acknowledgeHealthWarning = function(){
|
|
User.set({'flags.warnedLowHealth':true});
|
|
}
|
|
|
|
$scope.backgroundShopSets = Shared.shops.getBackgroundShopSets();
|
|
|
|
/**
|
|
* For gem-unlockable preferences, (a) if owned, select preference (b) else, purchase
|
|
* @param path: User.preferences <-> User.purchased maps like User.preferences.skin=abc <-> User.purchased.skin.abc.
|
|
* Pass in this paramater as "skin.abc". Alternatively, pass as an array ["skin.abc", "skin.xyz"] to unlock sets
|
|
*/
|
|
$scope.unlock = function(path){
|
|
var fullSet = ~path.indexOf(',');
|
|
var cost =
|
|
~path.indexOf('background.') ?
|
|
(fullSet ? 3.75 : 1.75) : // (Backgrounds) 15G per set, 7G per individual
|
|
(fullSet ? 1.25 : 0.5); // (Hair, skin, etc) 5G per set, 2G per individual
|
|
|
|
if (path.indexOf('background.blue') === -1 && path.indexOf('background.green') === -1 && path.indexOf('background.red') === -1 && path.indexOf('background.purple') === -1 && path.indexOf('background.yellow') === -1) {
|
|
if (fullSet) {
|
|
if (confirm(window.env.t('purchaseFor',{cost:cost*4})) !== true) return;
|
|
if (User.user.balance < cost) return $rootScope.openModal('buyGems');
|
|
} else if (!_.get(User.user, 'purchased.' + path)) {
|
|
if (confirm(window.env.t('purchaseFor',{cost:cost*4})) !== true) return;
|
|
if (User.user.balance < cost) return $rootScope.openModal('buyGems');
|
|
}
|
|
}
|
|
User.unlock({query:{path:path}})
|
|
}
|
|
|
|
$scope.ownsSet = function(type, _set) {
|
|
return !_.find(_set,function(v,k) {
|
|
if (type === 'background') k = v.key;
|
|
return !User.user.purchased[type][k];
|
|
});
|
|
};
|
|
|
|
$scope.setKeys = function(type, _set) {
|
|
return _.map(_set, function(v,k) {
|
|
if (type === 'background') k = v.key;
|
|
return type+'.'+k;
|
|
}).join(',');
|
|
};
|
|
|
|
$scope.getProgressDisplay = function () {
|
|
var currentLoginDay = Content.loginIncentives[$scope.profile.loginIncentives];
|
|
var nextRewardAt = currentLoginDay.nextRewardAt;
|
|
return ' ' + ($scope.profile.loginIncentives - currentLoginDay.prevRewardKey) + '/' + (nextRewardAt - currentLoginDay.prevRewardKey);
|
|
};
|
|
|
|
$scope.incentivesProgress = function () {
|
|
var currentLoginDay = Content.loginIncentives[$scope.profile.loginIncentives];
|
|
var previousRewardDay = currentLoginDay.prevRewardKey;
|
|
var nextRewardAt = currentLoginDay.nextRewardAt;
|
|
return ($scope.profile.loginIncentives - previousRewardDay)/(nextRewardAt - previousRewardDay) * 100;
|
|
};
|
|
}
|
|
]);
|