feat(quests): Invite party button

This commit is contained in:
Sabe Jones
2015-07-21 15:25:34 -05:00
parent 632faafa4f
commit 0313170921
5 changed files with 25 additions and 16 deletions

View File

@@ -512,12 +512,14 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
}
])
.controller("PartyCtrl", ['$rootScope','$scope', 'Groups', 'Chat', 'User', 'Challenges', '$state', '$compile', 'Analytics',
function($rootScope,$scope, Groups, Chat, User, Challenges, $state, $compile, Analytics) {
.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','Challenges','$state','$compile','Analytics','Quests',
function($rootScope,$scope,Groups,Chat,User,Challenges,$state,$compile,Analytics,Quests) {
$scope.type = 'party';
$scope.text = window.env.t('party');
$scope.group = $rootScope.party = Groups.party();
$scope.newGroup = new Groups.Group({type:'party'});
$scope.inviteOrStartParty = Groups.inviteOrStartParty;
$scope.questInit = Quests.questInit;
if ($state.is('options.social.party')) {
$scope.group.$syncParty(); // Sync party automatically when navigating to party page

View File

@@ -17,6 +17,7 @@ habitrpg.controller("InventoryCtrl",
$scope.questPopover = Quests.questPopover;
$scope.showQuest = Quests.showQuest;
$scope.closeQuest = Quests.closeQuest;
$scope.questInit = Quests.questInit;
// count egg, food, hatchingPotion stack totals
var countStacks = function(items) { return _.reduce(items,function(m,v){return m+v;},0);}
@@ -146,14 +147,6 @@ habitrpg.controller("InventoryCtrl",
User.user.ops.equip({params:{type: 'mount', key: egg + '-' + potion}});
}
$scope.questInit = function(){
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'quest','owner':true,'response':'accept','questName':$scope.selectedQuest.key});
$rootScope.party.$questAccept({key:$scope.selectedQuest.key}, function(){
$rootScope.party.$get();
});
$scope.closeQuest();
}
$scope.getSeasonalShopArray = function(set){
var flatGearArray = _.toArray(Content.gear.flat);

View File

@@ -67,7 +67,9 @@ habitrpg.controller('NotificationCtrl',
type = 'food';
} else if (after.type === 'HatchingPotion') {
type = 'hatchingPotions';
} else type = after.type.toLowerCase() + 's';
} else {
type = after.type.toLowerCase() + 's';
}
if(!User.user.items[type][after.key]){
User.user.items[type][after.key] = 0;
}
@@ -88,7 +90,7 @@ habitrpg.controller('NotificationCtrl',
Notification.drop(env.t('messageDropFood', {dropArticle: after.article, dropText: text, dropNotes: notes}), after);
} else if (after.type === 'Quest') {
$rootScope.selectedQuest = Content.quests[after.key];
$rootScope.openModal('questDrop');
$rootScope.openModal('questDrop', {controller:'PartyCtrl'});
} else {
// Keep support for another type of drops that might be added
Notification.drop(User.user._tmp.drop.dialog);

View File

@@ -10,10 +10,11 @@
'$rootScope',
'Content',
'Groups',
'User'
'User',
'Analytics'
];
function questsFactory($rootScope,Content,Groups,User) {
function questsFactory($rootScope,Content,Groups,User,Analytics) {
var user = User.user;
@@ -84,12 +85,22 @@
$rootScope.selectedQuest = undefined;
}
function questInit(){
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'quest','owner':true,'response':'accept','questName':$rootScope.selectedQuest.key});
$rootScope.party.$questAccept({key:$rootScope.selectedQuest.key}, function(){
$rootScope.party.$get();
});
$rootScope.$state.go('options.social.party');
closeQuest();
}
return {
lockQuest: lockQuest,
buyQuest: buyQuest,
questPopover: questPopover,
showQuest: showQuest,
closeQuest: closeQuest
closeQuest: closeQuest,
questInit: questInit
}
}
}());

View File

@@ -90,4 +90,5 @@ script(type='text/ng-template', id='modals/questDrop.html')
p=env.t('dropQuestCongrats')
.modal-footer
button.btn.btn-default(ng-click='closeQuest(); $close()')=env.t('questLater')
button.btn.btn-primary(ng-click='questInit(); $close()')=env.t('inviteParty')
button.btn.btn-primary(ng-click='inviteOrStartParty(group); $close()', ng-if='!party.members')=env.t('startAParty')
button.btn.btn-primary(ng-click='questInit(); $close()', ng-if='party.members')=env.t('inviteParty')