mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
@@ -202,8 +202,6 @@ api.updateStore = (user) ->
|
|||||||
# Add special items (contrib gear, backer gear, etc)
|
# Add special items (contrib gear, backer gear, etc)
|
||||||
changes = changes.concat _.filter content.gear.flat, (v) ->
|
changes = changes.concat _.filter content.gear.flat, (v) ->
|
||||||
v.klass in ['special','mystery','armoire'] and !user.items.gear.owned[v.key] and v.canOwn?(user)
|
v.klass in ['special','mystery','armoire'] and !user.items.gear.owned[v.key] and v.canOwn?(user)
|
||||||
changes.push content.potion
|
|
||||||
if user.flags.armoireEnabled then changes.push content.armoire
|
|
||||||
# Return sorted store (array)
|
# Return sorted store (array)
|
||||||
_.sortBy changes, (c)->sortOrder[c.type]
|
_.sortBy changes, (c)->sortOrder[c.type]
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('Tasks Controller', function() {
|
describe('Tasks Controller', function() {
|
||||||
var $rootScope, scope, user, ctrl;
|
var $rootScope, shared, scope, user, ctrl;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
user = specHelper.newUser();
|
user = specHelper.newUser();
|
||||||
@@ -10,10 +10,10 @@ describe('Tasks Controller', function() {
|
|||||||
$provide.value('Guide', {});
|
$provide.value('Guide', {});
|
||||||
});
|
});
|
||||||
|
|
||||||
inject(function($rootScope, $controller){
|
inject(function($rootScope, $controller, Shared){
|
||||||
|
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
|
shared = Shared;
|
||||||
$controller('RootCtrl', {$scope: scope, User: {user: user}});
|
$controller('RootCtrl', {$scope: scope, User: {user: user}});
|
||||||
|
|
||||||
ctrl = $controller('TasksCtrl', {$scope: scope, User: {user: user}});
|
ctrl = $controller('TasksCtrl', {$scope: scope, User: {user: user}});
|
||||||
@@ -28,4 +28,14 @@ describe('Tasks Controller', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('watch to updateStore', function() {
|
||||||
|
it('updates itemStore when user gear changes', function() {
|
||||||
|
sinon.stub(shared, 'updateStore').returns({item: true});
|
||||||
|
user.items.gear.owned.foo = true;
|
||||||
|
|
||||||
|
scope.$digest();
|
||||||
|
expect(scope.itemStore).to.eql({item: true});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','Notification', '$http', 'ApiUrl', '$timeout', 'Shared', 'Guide', 'Tasks', 'Analytics',
|
habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','Notification', '$http', 'ApiUrl', '$timeout', 'Content', 'Shared', 'Guide', 'Tasks', 'Analytics',
|
||||||
function($scope, $rootScope, $location, User, Notification, $http, ApiUrl, $timeout, Shared, Guide, Tasks, Analytics) {
|
function($scope, $rootScope, $location, User, Notification, $http, ApiUrl, $timeout, Content, Shared, Guide, Tasks, Analytics) {
|
||||||
$scope.obj = User.user; // used for task-lists
|
$scope.obj = User.user; // used for task-lists
|
||||||
$scope.user = User.user;
|
$scope.user = User.user;
|
||||||
|
|
||||||
@@ -212,10 +212,13 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
|||||||
------------------------
|
------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$scope.$watchGroup(['user.items.gear.owned', 'user.flags.armoireEnabled'], function(){
|
$scope.$watch('user.items.gear.owned', function(){
|
||||||
$scope.itemStore = Shared.updateStore(User.user);
|
$scope.itemStore = Shared.updateStore(User.user);
|
||||||
},true);
|
},true);
|
||||||
|
|
||||||
|
$scope.healthPotion = Content.potion;
|
||||||
|
$scope.armoire = Content.armoire;
|
||||||
|
|
||||||
$scope.buy = function(item) {
|
$scope.buy = function(item) {
|
||||||
User.user.ops.buy({params:{key:item.key}});
|
User.user.ops.buy({params:{key:item.key}});
|
||||||
$rootScope.playSound('Reward');
|
$rootScope.playSound('Reward');
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
ul.items.rewards(ng-if='main && list.type=="reward"')
|
mixin reward(item)
|
||||||
li.task.reward-item(ng-repeat='item in itemStore',popover-trigger='mouseenter', popover-placement='top', popover='{{item.key == "armoire" && !user.flags.armoireEmpty ? env.t("armoireNotesFull") + armoireCount(user.items.gear.owned) : item.notes()}}')
|
li.task.reward-item(popover-trigger='mouseenter', popover-placement='top', popover='{{::#{item}.notes()}}')&attributes(attributes)
|
||||||
// right-hand side control buttons
|
// right-hand side control buttons
|
||||||
.task-meta-controls
|
.task-meta-controls
|
||||||
span.task-notes
|
span.task-notes
|
||||||
span.glyphicon.glyphicon-comment
|
span.glyphicon.glyphicon-comment
|
||||||
//left-hand size commands
|
//left-hand size commands
|
||||||
.task-controls.task-primary
|
.task-controls.task-primary
|
||||||
input.visuallyhidden(
|
input.reward.visuallyhidden(
|
||||||
class="reward",
|
|
||||||
type='checkbox',
|
type='checkbox',
|
||||||
ui-keypress='{13:"buy(item)"}')
|
ui-keypress='{13:"buy(#{item})"}')
|
||||||
a.money.btn-buy.item-btn(ng-class='{highValue: item.value >= 1000}', ng-click='buy(item)')
|
a.money.btn-buy.item-btn(ng-class='::{highValue: #{item}.value >= 1000}', ng-click='::buy(#{item})')
|
||||||
span.shop_gold
|
span.shop_gold
|
||||||
span.reward-cost {{item.value}}
|
span.reward-cost {{::#{item}.value}}
|
||||||
// main content
|
// main content
|
||||||
span(ng-class='::{"shop_{{item.key}} shop-sprite item-img": true}').reward-img
|
span(ng-class='::{"shop_{{#{item}.key}} shop-sprite item-img": true}').reward-img
|
||||||
p.task-text {{item.text()}}
|
p.task-text {{::#{item}.text()}}
|
||||||
|
|
||||||
|
ul.items.rewards(ng-if='main && list.type=="reward"')
|
||||||
|
+reward('item')(ng-repeat='item in itemStore')
|
||||||
|
+reward('healthPotion')
|
||||||
|
+reward('armoire')(ng-if='user.flags.armoireEnabled')
|
||||||
|
|||||||
Reference in New Issue
Block a user