mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-21 13:24:16 +00:00
feat(premium): mystery items
This commit is contained in:
parent
7651dbee58
commit
a8e890a6df
4 changed files with 25 additions and 16 deletions
|
|
@ -53,13 +53,15 @@ habitrpg.controller('NotificationCtrl',
|
|||
$rootScope.$watch('user._tmp.drop', function(after, before){
|
||||
// won't work when getting the same item twice?
|
||||
if (after == before || !after) return;
|
||||
var type = (after.type == 'Food') ? 'food' :
|
||||
(after.type == 'HatchingPotion') ? 'hatchingPotions' : // can we use camelcase and remove this line?
|
||||
(after.type.toLowerCase() + 's');
|
||||
if(!User.user.items[type][after.key]){
|
||||
User.user.items[type][after.key] = 0;
|
||||
if (after.type !== 'gear') {
|
||||
var type = (after.type == 'Food') ? 'food' :
|
||||
(after.type == 'HatchingPotion') ? 'hatchingPotions' : // can we use camelcase and remove this line?
|
||||
(after.type.toLowerCase() + 's');
|
||||
if(!User.user.items[type][after.key]){
|
||||
User.user.items[type][after.key] = 0;
|
||||
}
|
||||
User.user.items[type][after.key]++;
|
||||
}
|
||||
User.user.items[type][after.key]++;
|
||||
Notification.drop(User.user._tmp.drop.dialog);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -310,13 +310,18 @@ api.buyGems = function(req, res, next) {
|
|||
function(response, cb) {
|
||||
//user.purchased.ads = true;
|
||||
if (req.query.plan) {
|
||||
user.purchased.plan = {
|
||||
planId:'basic_earned',
|
||||
customerId: response.id,
|
||||
dateCreated: new Date,
|
||||
dateUpdated: new Date,
|
||||
gemsBought: 0
|
||||
};
|
||||
if (!user.purchased.plan) user.purchased.plan = {}
|
||||
_(user.purchased.plan)
|
||||
.merge({ // override with these values
|
||||
planId:'basic_earned',
|
||||
customerId: response.id,
|
||||
dateUpdated: new Date,
|
||||
gemsBought: 0
|
||||
})
|
||||
.defaults({ // allow non-override if a plan was previously used
|
||||
dateCreated: new Date,
|
||||
mysteryItems: []
|
||||
});
|
||||
ga.event('subscribe', 'Stripe').send()
|
||||
ga.transaction(response.id, 5).item(5, 1, "stripe-subscription", "Subscription > Stripe").send()
|
||||
} else {
|
||||
|
|
@ -345,7 +350,7 @@ api.cancelSubscription = function(req, res, next) {
|
|||
stripe.customers.del(user.purchased.plan.customerId, cb);
|
||||
},
|
||||
function(response, cb) {
|
||||
user.purchased.plan = {};
|
||||
_.merge(user.purchased.plan, {planId:null, customerId:null});
|
||||
user.markModified('purchased.plan');
|
||||
user.save(cb);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,8 @@ var UserSchema = new Schema({
|
|||
customerId: String,
|
||||
dateCreated: Date,
|
||||
dateUpdated: Date,
|
||||
gemsBought: {type: Number, 'default': 0}
|
||||
gemsBought: {type: Number, 'default': 0},
|
||||
mysteryItems: {type: Array, 'default': []}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ script(type='text/ng-template', id='partials/options.inventory.drops.html')
|
|||
li.customize-menu(ng-if='user.purchased.plan.customerId')
|
||||
menu.pets-menu(label=env.t('subscriberItem'))
|
||||
div
|
||||
button.customize-option(popover=env.t('subscriberItemText'), popover-trigger='mouseenter', popover-placement='right', class='inventory_present')
|
||||
button.customize-option(popover=env.t('subscriberItemText'), popover-trigger='mouseenter', popover-placement='right', class='inventory_present', ng-click="user.ops.openMysteryItem({})")
|
||||
.badge.badge-info.stack-count {{user.purchased.plan.mysteryItems.length}}
|
||||
|
||||
.col-md-6
|
||||
h2=env.t('market')
|
||||
|
|
|
|||
Loading…
Reference in a new issue