mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
WIP(quests): Quests page cont'd
Test fixes and addition of function for buying Quests with Gold
This commit is contained in:
@@ -875,7 +875,7 @@ api.wrap = (user, main=true) ->
|
||||
item = if key is 'potion' then content.potion
|
||||
else if key is 'armoire' then content.armoire
|
||||
else content.gear.flat[key]
|
||||
return cb?({code:404, message:"Item '#{key} not found (see https://github.com/HabitRPG/habitrpg-shared/blob/develop/script/content.coffee)"}) unless item
|
||||
return cb?({code:404, message:"Item '#{key} not found (see https://github.com/HabitRPG/habitrpg/blob/develop/common/script/content.coffee)"}) unless item
|
||||
return cb?({code:401, message: i18n.t('messageNotEnoughGold', req.language)}) if user.stats.gp < item.value
|
||||
return cb?({code:401, message: "You can't buy this item"}) if item.canOwn? and !item.canOwn(user)
|
||||
if item.key is 'potion'
|
||||
@@ -913,6 +913,17 @@ api.wrap = (user, main=true) ->
|
||||
mixpanel?.track("Acquire Item",{'itemName':key,'acquireMethod':'Gold','goldCost':item.value})
|
||||
cb? {code:200, message}, _.pick(user,$w 'items achievements stats flags')
|
||||
|
||||
buyQuest: (req, cb) ->
|
||||
{key} = req.params
|
||||
item = content.quests[key]
|
||||
return cb?({code:404, message:"Quest '#{key} not found (see https://github.com/HabitRPG/habitrpg/blob/develop/common/script/content.coffee)"}) unless item
|
||||
return cb?({code:401, message: i18n.t('messageNotEnoughGold', req.language)}) if user.stats.gp < item.value
|
||||
message = i18n.t('messageBought', {itemText: item.text(req.language)}, req.language)
|
||||
user.items.quests[item.key] ?= 0
|
||||
user.items.quests[item.key] += 1
|
||||
user.stats.gp -= item.value
|
||||
cb? {code:200, message}, user.items.quests
|
||||
|
||||
buyMysterySet: (req, cb)->
|
||||
return cb?({code:401, message:"You don't have enough Mystic Hourglasses"}) unless user.purchased.plan.consecutive.trinkets>0
|
||||
mysterySet = content.timeTravelerStore(user.items.gear.owned)?[req.params.key]
|
||||
|
||||
@@ -54,6 +54,7 @@ module.exports = function(config) {
|
||||
"website/public/js/services/challengeServices.js",
|
||||
"website/public/js/services/taskServices.js",
|
||||
"website/public/js/services/paymentServices.js",
|
||||
"website/public/js/services/questServices.js",
|
||||
|
||||
"website/public/js/filters/money.js",
|
||||
"website/public/js/filters/roundLargeNumbers.js",
|
||||
|
||||
@@ -574,7 +574,7 @@ describe 'User', ->
|
||||
expect(quest.value).to.be.greaterThan 0 if quest.canBuy
|
||||
expect(quest.drop.gp).to.not.be.lessThan 0
|
||||
expect(quest.drop.exp).to.not.be.lessThan 0
|
||||
expect(quest.category).to.match('pet|unlockable|gold|world')
|
||||
expect(quest.category).to.match(/pet|unlockable|gold|world/)
|
||||
if quest.drop.items
|
||||
expect(quest.drop.items).to.be.an(Array)
|
||||
if quest.boss
|
||||
|
||||
@@ -219,7 +219,6 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
$scope.buy = function(item) {
|
||||
User.user.ops.buy({params:{key:item.key}});
|
||||
$rootScope.playSound('Reward');
|
||||
Guide.goto('intro', 4);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
if (item.lvl && item.lvl > user.stats.lvl) {
|
||||
return alert(window.env.t('mustLvlQuest', {level: item.lvl}));
|
||||
}
|
||||
if (item.category === 'gold') {
|
||||
return User.user.ops.buyQuest({params:{key:item.key}});
|
||||
}
|
||||
$rootScope.selectedQuest = item;
|
||||
$rootScope.openModal('buyQuest', {controller:'InventoryCtrl'});
|
||||
}
|
||||
|
||||
@@ -31,8 +31,11 @@ script(type='text/ng-template', id='partials/options.inventory.quests.html')
|
||||
button.customize-option(data-popover-html="{{::lockQuest(quest,true) ? env.t('scrollsPre') : questPopover(quest) | markdown}}", popover-title='{{::quest.text()}}', popover-append-to-body="true", popover-trigger='mouseenter', ng-click='buyQuest(quest.key)', ng-class='lockQuest(quest) ? "inventory_quest_scroll_locked inventory_quest_scroll_{{::quest.key}}_locked locked" : "inventory_quest_scroll inventory_quest_scroll_{{::quest.key}}"')
|
||||
p(ng-if='quest.unlockCondition')
|
||||
| {{::quest.unlockCondition.text()}}
|
||||
p(ng-if='quest.value && !lockQuest(quest)')
|
||||
p(ng-if='quest.value && quest.category !== "gold" && !lockQuest(quest)')
|
||||
| {{::quest.value}}
|
||||
span.Pet_Currency_Gem1x.inline-gems
|
||||
p(ng-if='quest.value && quest.category === "gold" && !lockQuest(quest)')
|
||||
| {{::quest.value}}
|
||||
span.shop_gold
|
||||
p(ng-if='quest.lvl && lockQuest(quest)')=env.t('level')
|
||||
| {{::quest.lvl}}
|
||||
Reference in New Issue
Block a user