From 2407c9eeb8e5fde2f292fd1556950eb435e7398c Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Thu, 16 Jul 2015 12:56:26 -0500 Subject: [PATCH] feat(quests): Improve buy confirm dialog --- common/locales/en/quests.json | 8 +++++--- website/public/js/controllers/rootCtrl.js | 10 ++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/common/locales/en/quests.json b/common/locales/en/quests.json index 72cdbe3832..7fbc0d9fc9 100644 --- a/common/locales/en/quests.json +++ b/common/locales/en/quests.json @@ -44,12 +44,14 @@ "scrollsText1": "Quests require parties. If you want to quest solo,", "scrollsText2": "create an empty party", "scrollsPre": "You haven't unlocked this quest yet!", + "alreadyEarnedQuestLevel": "You already earned this quest by attaining Level <%= level %>. ", + "alreadyEarnedQuestReward": "You already earned this quest by completing <%= priorQuest %>. ", "completedQuests": "Completed the following quests", "mustComplete": "You must first complete <%= quest %>.", - "mustLevel": "You must be level <%= level %>.", + "mustLevel": "You must be level <%= level %> to begin this quest.", "mustLvlQuest": "You must be level <%= level %> to buy this quest!", - "mustInviteFriend": "To earn this Quest, invite a friend to your Party. Invite someone now?", - "unlockByQuesting": "To earn this Quest, complete <%= title %>.", + "mustInviteFriend": "To earn this quest, invite a friend to your Party. Invite someone now?", + "unlockByQuesting": "To earn this quest, complete <%= title %>.", "sureCancel": "Are you sure you want to cancel this quest? All invitation acceptances will be lost. The quest owner will retain possession of the quest scroll.", "sureAbort": "Are you sure you want to abort this mission? It will abort it for everyone in your party and all progress will be lost. The quest scroll will be returned to the quest owner.", "doubleSureAbort": "Are you double sure? Make sure they won't hate you forever!", diff --git a/website/public/js/controllers/rootCtrl.js b/website/public/js/controllers/rootCtrl.js index e999a0ef15..1c520879b8 100644 --- a/website/public/js/controllers/rootCtrl.js +++ b/website/public/js/controllers/rootCtrl.js @@ -226,6 +226,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ var gems = user.balance * 4; var price = item.value; + var message; var itemName = window.env.t(Content.itemList[type].localeKey) @@ -240,10 +241,15 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ if (gems < price) return $rootScope.openModal('buyGems'); - var message = window.env.t('buyThis', {text: itemName, price: price, gems: gems}); + if (type === 'quests') { + if (item.previous) {message = window.env.t('alreadyEarnedQuestReward', {priorQuest: Content.quests[item.previous].text()})} + else if (item.lvl) {message = window.env.t('alreadyEarnedQuestLevel', {level: item.lvl})} + } else message = ""; + + message += window.env.t('buyThis', {text: itemName, price: price, gems: gems}); if ($window.confirm(message)) user.ops.purchase({params:{type:type,key:item.key}}); - } + }; function _canBuyEquipment(itemKey) { if (user.items.gear.owned[itemKey]) {