From b9bbc3f1eaafa10ec27a2f9c61d9dc1859b1f5a9 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 6 Sep 2015 15:31:08 -0500 Subject: [PATCH 1/9] Move content to own directory --- common/script/{content.coffee => content/index.coffee} | 2 +- common/script/count.js | 2 +- common/script/index.coffee | 10 +++++----- test/common/user.fns.buy.test.js | 2 +- website/src/routes/apiv2.coffee | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) rename common/script/{content.coffee => content/index.coffee} (99%) diff --git a/common/script/content.coffee b/common/script/content/index.coffee similarity index 99% rename from common/script/content.coffee rename to common/script/content/index.coffee index f4bf479d1e..28d13f4c30 100644 --- a/common/script/content.coffee +++ b/common/script/content/index.coffee @@ -1,7 +1,7 @@ _ = require 'lodash' api = module.exports moment = require 'moment' -i18n = require './i18n.coffee' +i18n = require '../i18n.coffee' t = (string, vars) -> func = (lang) -> vars ?= {a: 'a'} diff --git a/common/script/count.js b/common/script/count.js index a48fcd42d9..de2bbf1227 100644 --- a/common/script/count.js +++ b/common/script/count.js @@ -2,7 +2,7 @@ require('coffee-script'); var _ = require('lodash'); -var content = require('./content.coffee'); +var content = require('./content/index.coffee'); var DROP_ANIMALS = _.keys(content.pets); diff --git a/common/script/index.coffee b/common/script/index.coffee index f0dd2536fa..8e5094b7f2 100644 --- a/common/script/index.coffee +++ b/common/script/index.coffee @@ -1,6 +1,6 @@ moment = require('moment') _ = require('lodash') -content = require('./content.coffee') +content = require('./content/index.coffee') i18n = require('./i18n.coffee') api = module.exports = {} @@ -923,7 +923,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/blob/develop/common/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/index.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) armoireResp = undefined @@ -980,8 +980,8 @@ api.wrap = (user, main=true) -> buyQuest: (req, cb, analytics) -> {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:404, message:"Quest '#{key} is not a Gold-purchasable quest (see https://github.com/HabitRPG/habitrpg/blob/develop/common/script/content.coffee)"}) unless item.category is 'gold' and item.goldValue + return cb?({code:404, message:"Quest '#{key} not found (see https://github.com/HabitRPG/habitrpg/blob/develop/common/script/content/index.coffee)"}) unless item + return cb?({code:404, message:"Quest '#{key} is not a Gold-purchasable quest (see https://github.com/HabitRPG/habitrpg/blob/develop/common/script/content/index.coffee)"}) unless item.category is 'gold' and item.goldValue return cb?({code:401, message: i18n.t('messageNotEnoughGold', req.language)}) if user.stats.gp < item.goldValue message = i18n.t('messageBought', {itemText: item.text(req.language)}, req.language) user.items.quests[item.key] ?= 0 @@ -1063,7 +1063,7 @@ api.wrap = (user, main=true) -> fullSet = ~path.indexOf(",") cost = # (Backgrounds) 15G per set, 7G per individual - if ~path.indexOf('background.') # FIXME, store prices of things in content.coffee instead of hard-coded here? + if ~path.indexOf('background.') # FIXME, store prices of things in content/index.coffee instead of hard-coded here? if fullSet then 3.75 else 1.75 # (Skin, hair, etc) 5G per set, 2G per individual else diff --git a/test/common/user.fns.buy.test.js b/test/common/user.fns.buy.test.js index be07d69a91..c79d5ea828 100644 --- a/test/common/user.fns.buy.test.js +++ b/test/common/user.fns.buy.test.js @@ -6,7 +6,7 @@ var _ = require('lodash'); require('coffee-script'); var shared = require('../../common/script/index.coffee'); -var Content = require('../../common/script/content.coffee'); +var Content = require('../../common/script/content/index.coffee'); describe('user.fns.buy', function() { var user; diff --git a/website/src/routes/apiv2.coffee b/website/src/routes/apiv2.coffee index 22babced8f..396747fcf4 100644 --- a/website/src/routes/apiv2.coffee +++ b/website/src/routes/apiv2.coffee @@ -302,7 +302,7 @@ module.exports = (swagger, v2) -> method: 'POST' description: "Casts a spell on a target." parameters: [ - path 'spell',"The key of the spell to cast (see ../../common#content.coffee)",'string' + path 'spell',"The key of the spell to cast (see ../../common#content/index.coffee)",'string' query 'targetType',"The type of object you're targeting",'string',['party','self','user','task'] query 'targetId',"The ID of the object you're targeting",'string' From 5045ce3b2f82612ddf7f3a632f3e2f5316bd673d Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 6 Sep 2015 15:31:20 -0500 Subject: [PATCH 2/9] Add FAQ --- common/locales/en/faq.json | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/common/locales/en/faq.json b/common/locales/en/faq.json index e98e6fc4d8..454f4a7ac5 100644 --- a/common/locales/en/faq.json +++ b/common/locales/en/faq.json @@ -1,4 +1,29 @@ { - "wiki": "Wiki" + "wiki": "Wiki", + "mobileFaqQuestion1": "I'm confused. Where do I get an overview?", + "iosFaqAnswer1": "First, you'll set up tasks that you want to do in your everyday life. Then, as you complete the tasks in real life and check them off, you'll earn experience and gold. Gold is used to buy equipment and some items, as well as custom rewards. Experience causes your character to level up and unlock content such as Pets, Skills, and Quests! You can customize your character under Menu > Customize Avatar.\n\n Some basic ways to interact: click the (+) in the upper-right-hand corner to add a new task. Tap on an existing task to edit it, and swipe left on a task to delete it. You can sort tasks using Tags in the upper-left-hand corner, and expand and contract checklists by clicking on the checklist bubble.", + "mobileFaqQuestion2": "How do I set up my tasks?", + "iosFaqAnswer2": "Good Habits (the ones with a +) are tasks that you can do many times a day, such as eating vegetables. Bad Habits (the ones with a -) are tasks that you should avoid, like biting nails. Habits with a + and a - have a good choice and a bad choice, like taking the stairs vs. taking the elevator. Good Habits award experience and gold. Bad Habits subtract health.\n\n Dailies are tasks that you have to do every day, like brushing your teeth or checking your email. You can adjust the days that a Daily is due by tapping to edit it. If you skip a Daily that is due, your avatar will take damage overnight. Be careful not to add too many Dailies at once!\n\n To-Dos are your To-Do list. Completing a To-Do earns you gold and experience. You never lose health from To-Dos. You can add a due date to a To-Do by tapping to edit.", + "mobileFaqQuestion3": "What are some sample tasks?", + "iosFaqAnswer3": "The wiki has four lists of sample tasks to use as inspiration:\n\n [Sample Habits](http://habitica.wikia.com/wiki/Sample_Habits)\n\n [Sample Dailies](http://habitica.wikia.com/wiki/Sample_Dailies)\n\n [Sample To-Dos](http://habitica.wikia.com/wiki/Sample_To-Dos)\n\n [Sample Custom Rewards](http://habitica.wikia.com/wiki/Sample_Custom_Rewards)", + "mobileFaqQuestion4": "Why do my tasks change color?", + "iosFaqAnswer4": "Your tasks change color based on how well you are currently accomplishing them! Each new task starts out as a neutral yellow. Perform Dailies or positive Habits more frequently and they move toward blue. Miss a Daily or give in to a bad Habit and the task moves toward red. The redder a task, the more rewards it will give you, but if it's a Daily or bad Habit, the more it will hurt you! This helps motivate you to complete the tasks that are giving you trouble.", + "mobileFaqQuestion5": "Why did my avatar lose health, and how do I regain it?", + "iosFaqAnswer5": "There are several things that can cause you to take damage. First, if you left Dailies incomplete overnight, they will damage you. Second, if you tap a bad Habit, it will damage you. Finally, if you are in a Boss Battle with your Party and one of your Party mates did not complete all their Dailies, the Boss will attack you.\n\n The main way to heal is to gain a level, which restores all your health. You can also buy a Health Potion with gold from the Rewards column. Plus, at level 10 or above, you can choose to become a Healer, and then you will learn healing skills. If you are in a Party with a Healer, they can heal you as well.", + "mobileFaqQuestion6": "How do I play Habitica with my friends?", + "iosFaqAnswer6": "The best way is to invite them to a Party with you, via the [website](https://habitica.com/#/options/groups/party)! We'll add the ability to create a Party from this app soon, but in the meantime you can use the [website](https://habitica.com/#/options/groups/party). Parties can go on quests, battle monsters, and cast skills to support each other. On the website, you and your friends can also join Guilds, which are public chat rooms. Guilds will be added to the app in a future update!", + "mobileFaqQuestion7": "How do I get a Pet or Mount?", + "iosFaqAnswer7": "At level 3, you will unlock the Drop System. Every time you complete a task, you'll have a random chance at receiving an egg, a hatching potion, or a piece of food. They will be stored in Menu > Items.\n\n To hatch a Pet, you'll need an egg and a hatching potion. Tap on the egg to determine the species you want to hatch, and select \"Hatch Egg.\" Then choose a hatching potion to determine its color! Go to Menu > Pets to equip your new Pet to your avatar by clicking on it. \n\n You can also grow your Pets into Mounts by feeding them under Menu > Pets. Tap on a Pet, and then select \"Feed Pet\"! You'll have to feed a pet many times before it becomes a Mount, but if you can figure out its favorite food, it will grow more quickly. Use trial and error, or [see the spoilers here](http://habitica.wikia.com/wiki/Food#Food_Preferences). Once you have a Mount, go to Menu > Mounts and tap on it to equip it to your avatar.\n\n You can also get eggs for Quest Pets by completing certain Quests. (See below to learn more about Quests.)", + "mobileFaqQuestion8": "How do I become a Warrior, Mage, Rogue, or Healer?", + "iosFaqAnswer8": "At level 10, you can choose to become a Warrior, Mage, Rogue, or Healer. (All players start as Warriors by default.) Each Class has different equipment options, different Skills that they can cast after level 11, and different advantages. Warriors can easily damage Bosses, withstand more damage from their tasks, and help make their Party tougher. Mages can also easily damage Bosses, as well as level up quickly and restore Mana for their party. Rogues earn the most gold and find the most item drops, and they can help their Party do the same. Finally, Healers can heal themselves and their Party members.\n\n If you don't want to choose a Class immediately -- for example, if you are still working to buy all the gear of your current class -- you can click “Decide Later” and choose later under Menu > Choose Class.", + "mobileFaqQuestion9": "What is the blue stat bar that appears in the Header after level 10?", + "iosFaqAnswer9": "The blue bar that appeared when you hit level 10 and chose a Class is your Mana bar. As you continue to level up, you will unlock special Skills that cost Mana to use. Each Class has different Skills, which appear after level 11 under Menu > Use Skills. Unlike your health bar, your Mana bar does not reset when you gain a level. Instead, Mana is gained when you complete Good Habits, Dailies, and To-Dos, and lost when you indulge bad Habits. You'll also regain some Mana overnight -- the more Dailies you completed, the more you will gain.", + "mobileFaqQuestion10": "How do I fight monsters and go on Quests?", + "iosFaqAnswer10": "First, you need to join or start a Party (see above). Although you can battle monsters alone, we recommend playing in a group, because this will make Quests much easier. Plus, having a friend to cheer you on as you accomplish your tasks is very motivating!\n\n Next, you need a Quest Scroll, which are stored under Menu > Items. There are three ways to get a scroll:\n\n - At level 15, you get a Quest-line, aka three linked quests. More Quest-lines unlock at levels 30, 40, and 60 respectively. \n\n - When you invite people to your Party on the [website](https://habitica.com/#/options/groups/party), you'll be rewarded with the Basi-List Scroll! (We will add this feature to the app in a future update.)\n\n - You can buy Quests from the Quests Page on the [website](https://habitica.com/#/options/inventory/quests) for gold and gems. (We will add this feature to the app in a future update.)\n\n To battle the Boss or collect items for a Collection Quest, simply complete your tasks normally, and they will be tallied into damage overnight. (Reloading by pulling down on the screen may be required to see the Boss's health bar go down.) If you are fighting a Boss and you missed any Dailies, the Boss will damage your Party at the same time that you damage the Boss. \n\n After level 11 Mages and Warriors will gain Skills that allow them to deal additional damage to the Boss, so these are excellent classes to choose at level 10 if you want to be a heavy hitter.", + "mobileFaqQuestion11": "What are gems, and how do I get them?", + "iosFaqAnswer11": "Gems are [purchased with real money](link) by tapping on the gem icon in the header. When people buy gems, they are helping us to keep the site running. We're very grateful for their support!\n\n In addition to buying gems directly, there are three other ways players can gain gems:\n\n 1. Win a Challenge on the [website](link) that has been set up by another player under Social > Challenges. (We will be adding Challenges to the app in a future update!)\n\n 2. Subscribe on the [website](link) and unlock the ability to buy a certain number of gems per month.\n\n 3. Contribute your skills to the Habitica project. See this wiki page for more details: [Contributing to Habitica](http://habitica.wikia.com/wiki/Contributing_to_Habitica).\n\n Keep in mind that items purchased with gems do not offer any statistical advantages, so players can still make use of the app without them!", + "mobileFaqQuestion12": "How do I report a bug or request a feature?", + "iosFaqAnswer12": "You can report a bug, request a feature, or send feedback under Menu > Report a Bug and Menu > Send Feedback! We'll do everything we can to assist you.", + "iosStillNeedHelp": "If you have a question that isn't on this list, come ask in the Tavern chat under Menu > Tavern! We're happy to help." } From 8a06514c723cbf0deef887ab36f1ad995dc07f21 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 6 Sep 2015 15:54:38 -0500 Subject: [PATCH 3/9] Move translation function to separate module --- common/script/content/index.coffee | 11 +++-------- common/script/content/translation.coffee | 9 +++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 common/script/content/translation.coffee diff --git a/common/script/content/index.coffee b/common/script/content/index.coffee index 28d13f4c30..44607837c0 100644 --- a/common/script/content/index.coffee +++ b/common/script/content/index.coffee @@ -1,13 +1,8 @@ -_ = require 'lodash' api = module.exports + +_ = require 'lodash' moment = require 'moment' -i18n = require '../i18n.coffee' -t = (string, vars) -> - func = (lang) -> - vars ?= {a: 'a'} - i18n.t(string, vars, lang) - func.i18nLangFunc = true #Trick to recognize this type of function - func +t = require './translation.coffee' ### --------------------------------------------------------------- diff --git a/common/script/content/translation.coffee b/common/script/content/translation.coffee new file mode 100644 index 0000000000..e668933f35 --- /dev/null +++ b/common/script/content/translation.coffee @@ -0,0 +1,9 @@ +i18n = require '../i18n.coffee' +t = (string, vars) -> + func = (lang) -> + vars ?= {a: 'a'} + i18n.t(string, vars, lang) + func.i18nLangFunc = true #Trick to recognize this type of function + func + +module.exports = t From 6bad9623d80355cd5fee849abc4e6c48e1cd8bf2 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 6 Sep 2015 16:08:22 -0500 Subject: [PATCH 4/9] Remove link --- common/locales/en/faq.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/locales/en/faq.json b/common/locales/en/faq.json index 454f4a7ac5..05ec5a7dc0 100644 --- a/common/locales/en/faq.json +++ b/common/locales/en/faq.json @@ -21,7 +21,7 @@ "mobileFaqQuestion10": "How do I fight monsters and go on Quests?", "iosFaqAnswer10": "First, you need to join or start a Party (see above). Although you can battle monsters alone, we recommend playing in a group, because this will make Quests much easier. Plus, having a friend to cheer you on as you accomplish your tasks is very motivating!\n\n Next, you need a Quest Scroll, which are stored under Menu > Items. There are three ways to get a scroll:\n\n - At level 15, you get a Quest-line, aka three linked quests. More Quest-lines unlock at levels 30, 40, and 60 respectively. \n\n - When you invite people to your Party on the [website](https://habitica.com/#/options/groups/party), you'll be rewarded with the Basi-List Scroll! (We will add this feature to the app in a future update.)\n\n - You can buy Quests from the Quests Page on the [website](https://habitica.com/#/options/inventory/quests) for gold and gems. (We will add this feature to the app in a future update.)\n\n To battle the Boss or collect items for a Collection Quest, simply complete your tasks normally, and they will be tallied into damage overnight. (Reloading by pulling down on the screen may be required to see the Boss's health bar go down.) If you are fighting a Boss and you missed any Dailies, the Boss will damage your Party at the same time that you damage the Boss. \n\n After level 11 Mages and Warriors will gain Skills that allow them to deal additional damage to the Boss, so these are excellent classes to choose at level 10 if you want to be a heavy hitter.", "mobileFaqQuestion11": "What are gems, and how do I get them?", - "iosFaqAnswer11": "Gems are [purchased with real money](link) by tapping on the gem icon in the header. When people buy gems, they are helping us to keep the site running. We're very grateful for their support!\n\n In addition to buying gems directly, there are three other ways players can gain gems:\n\n 1. Win a Challenge on the [website](link) that has been set up by another player under Social > Challenges. (We will be adding Challenges to the app in a future update!)\n\n 2. Subscribe on the [website](link) and unlock the ability to buy a certain number of gems per month.\n\n 3. Contribute your skills to the Habitica project. See this wiki page for more details: [Contributing to Habitica](http://habitica.wikia.com/wiki/Contributing_to_Habitica).\n\n Keep in mind that items purchased with gems do not offer any statistical advantages, so players can still make use of the app without them!", + "iosFaqAnswer11": "Gems are purchased with real money by tapping on the gem icon in the header. When people buy gems, they are helping us to keep the site running. We're very grateful for their support!\n\n In addition to buying gems directly, there are three other ways players can gain gems:\n\n 1. Win a Challenge on the [website](link) that has been set up by another player under Social > Challenges. (We will be adding Challenges to the app in a future update!)\n\n 2. Subscribe on the [website](link) and unlock the ability to buy a certain number of gems per month.\n\n 3. Contribute your skills to the Habitica project. See this wiki page for more details: [Contributing to Habitica](http://habitica.wikia.com/wiki/Contributing_to_Habitica).\n\n Keep in mind that items purchased with gems do not offer any statistical advantages, so players can still make use of the app without them!", "mobileFaqQuestion12": "How do I report a bug or request a feature?", "iosFaqAnswer12": "You can report a bug, request a feature, or send feedback under Menu > Report a Bug and Menu > Send Feedback! We'll do everything we can to assist you.", "iosStillNeedHelp": "If you have a question that isn't on this list, come ask in the Tavern chat under Menu > Tavern! We're happy to help." From 4081a9a62ae46e66ce94d4dd32e4a727ae3c1092 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 6 Sep 2015 16:08:53 -0500 Subject: [PATCH 5/9] Add faq to content --- common/script/content/faq.js | 64 ++++++++++++++++++++++++++++++ common/script/content/index.coffee | 2 + 2 files changed, 66 insertions(+) create mode 100644 common/script/content/faq.js diff --git a/common/script/content/faq.js b/common/script/content/faq.js new file mode 100644 index 0000000000..24904d33ac --- /dev/null +++ b/common/script/content/faq.js @@ -0,0 +1,64 @@ +'use strict'; + +require('coffee-script'); + +var t = require('./translation.coffee'); + +var faq = {}; + +faq.questions = [ + { + question: t('mobileFaqQuestion1'), + ios: t('iosFaqAnswer1') + }, + { + question: t('mobileFaqQuestion2'), + ios: t('iosFaqAnswer2') + }, + { + question: t('mobileFaqQuestion3'), + ios: t('iosFaqAnswer3') + }, + { + question: t('mobileFaqQuestion4'), + ios: t('iosFaqAnswer4') + }, + { + question: t('mobileFaqQuestion5'), + ios: t('iosFaqAnswer5') + }, + { + question: t('mobileFaqQuestion6'), + ios: t('iosFaqAnswer6') + }, + { + question: t('mobileFaqQuestion7'), + ios: t('iosFaqAnswer7') + }, + { + question: t('mobileFaqQuestion8'), + ios: t('iosFaqAnswer8') + }, + { + question: t('mobileFaqQuestion9'), + ios: t('iosFaqAnswer9') + }, + { + question: t('mobileFaqQuestion10'), + ios: t('iosFaqAnswer10') + }, + { + question: t('mobileFaqQuestion11'), + ios: t('iosFaqAnswer11') + }, + { + question: t('mobileFaqQuestion12'), + ios: t('iosFaqAnswer12') + } +]; + +faq.stillNeedHelp = { + ios: t('iosStillNeedHelp') +}; + +module.exports = faq; diff --git a/common/script/content/index.coffee b/common/script/content/index.coffee index 44607837c0..7ab290c95b 100644 --- a/common/script/content/index.coffee +++ b/common/script/content/index.coffee @@ -2268,3 +2268,5 @@ api.userDefaults = {name: t('defaultTag2')} {name: t('defaultTag3')} ] + +api.faq = require './faq.js' From 245c7d48c8d9c5faaff0317d84a3083a14d4d26a Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 6 Sep 2015 16:11:53 -0500 Subject: [PATCH 6/9] Simplify faq logic --- common/script/content/faq.js | 60 ++++++------------------------------ 1 file changed, 10 insertions(+), 50 deletions(-) diff --git a/common/script/content/faq.js b/common/script/content/faq.js index 24904d33ac..ecba374767 100644 --- a/common/script/content/faq.js +++ b/common/script/content/faq.js @@ -6,56 +6,16 @@ var t = require('./translation.coffee'); var faq = {}; -faq.questions = [ - { - question: t('mobileFaqQuestion1'), - ios: t('iosFaqAnswer1') - }, - { - question: t('mobileFaqQuestion2'), - ios: t('iosFaqAnswer2') - }, - { - question: t('mobileFaqQuestion3'), - ios: t('iosFaqAnswer3') - }, - { - question: t('mobileFaqQuestion4'), - ios: t('iosFaqAnswer4') - }, - { - question: t('mobileFaqQuestion5'), - ios: t('iosFaqAnswer5') - }, - { - question: t('mobileFaqQuestion6'), - ios: t('iosFaqAnswer6') - }, - { - question: t('mobileFaqQuestion7'), - ios: t('iosFaqAnswer7') - }, - { - question: t('mobileFaqQuestion8'), - ios: t('iosFaqAnswer8') - }, - { - question: t('mobileFaqQuestion9'), - ios: t('iosFaqAnswer9') - }, - { - question: t('mobileFaqQuestion10'), - ios: t('iosFaqAnswer10') - }, - { - question: t('mobileFaqQuestion11'), - ios: t('iosFaqAnswer11') - }, - { - question: t('mobileFaqQuestion12'), - ios: t('iosFaqAnswer12') - } -]; +faq.questions = []; + +for (var i = 1; i <= 12; i++) { + var question = { + question: t('mobileFaqQuestion' + i), + ios: t('iosFaqAnswer' + i) + }; + + faq.questions.push(question); +} faq.stillNeedHelp = { ios: t('iosStillNeedHelp') From 898ea845b3420ebc9f700293d328ae880854c658 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 6 Sep 2015 16:20:14 -0500 Subject: [PATCH 7/9] Convert translation function to js --- common/script/content/faq.js | 2 +- common/script/content/index.coffee | 2 +- common/script/content/translation.coffee | 9 --------- common/script/content/translation.js | 21 +++++++++++++++++++++ 4 files changed, 23 insertions(+), 11 deletions(-) delete mode 100644 common/script/content/translation.coffee create mode 100644 common/script/content/translation.js diff --git a/common/script/content/faq.js b/common/script/content/faq.js index ecba374767..4bfd15b846 100644 --- a/common/script/content/faq.js +++ b/common/script/content/faq.js @@ -2,7 +2,7 @@ require('coffee-script'); -var t = require('./translation.coffee'); +var t = require('./translation.js'); var faq = {}; diff --git a/common/script/content/index.coffee b/common/script/content/index.coffee index 7ab290c95b..e4d6ff5dd9 100644 --- a/common/script/content/index.coffee +++ b/common/script/content/index.coffee @@ -2,7 +2,7 @@ api = module.exports _ = require 'lodash' moment = require 'moment' -t = require './translation.coffee' +t = require './translation.js' ### --------------------------------------------------------------- diff --git a/common/script/content/translation.coffee b/common/script/content/translation.coffee deleted file mode 100644 index e668933f35..0000000000 --- a/common/script/content/translation.coffee +++ /dev/null @@ -1,9 +0,0 @@ -i18n = require '../i18n.coffee' -t = (string, vars) -> - func = (lang) -> - vars ?= {a: 'a'} - i18n.t(string, vars, lang) - func.i18nLangFunc = true #Trick to recognize this type of function - func - -module.exports = t diff --git a/common/script/content/translation.js b/common/script/content/translation.js new file mode 100644 index 0000000000..e0e26450c5 --- /dev/null +++ b/common/script/content/translation.js @@ -0,0 +1,21 @@ +'use strict'; + +require('coffee-script'); +var i18n = require('../i18n.coffee'); + +var t = function(string, vars) { + var func = function(lang) { + if (vars == null) { + vars = { + a: 'a' + }; + } + return i18n.t(string, vars, lang); + }; + + func.i18nLangFunc = true; // Trick to recognize this type of function + + return func; +}; + +module.exports = t; From 1bce23c12bb8aa2ec1e15d25248b46114cc67885 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 6 Sep 2015 16:22:06 -0500 Subject: [PATCH 8/9] Transform magic number to constant --- common/script/content/faq.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/script/content/faq.js b/common/script/content/faq.js index 4bfd15b846..a9ffdea038 100644 --- a/common/script/content/faq.js +++ b/common/script/content/faq.js @@ -1,14 +1,15 @@ 'use strict'; require('coffee-script'); - var t = require('./translation.js'); +var NUMBER_OF_QUESTIONS = 12; + var faq = {}; faq.questions = []; -for (var i = 1; i <= 12; i++) { +for (var i = 1; i <= NUMBER_OF_QUESTIONS; i++) { var question = { question: t('mobileFaqQuestion' + i), ios: t('iosFaqAnswer' + i) From 2fcc7df2184fae51294b77abc602fb51193009ea Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 6 Sep 2015 16:36:21 -0500 Subject: [PATCH 9/9] Change name of locales keys --- common/locales/en/faq.json | 26 +++++++++++++------------- common/script/content/faq.js | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/common/locales/en/faq.json b/common/locales/en/faq.json index 05ec5a7dc0..546ec40db7 100644 --- a/common/locales/en/faq.json +++ b/common/locales/en/faq.json @@ -1,29 +1,29 @@ { "wiki": "Wiki", - "mobileFaqQuestion1": "I'm confused. Where do I get an overview?", + "faqQuestion1": "I'm confused. Where do I get an overview?", "iosFaqAnswer1": "First, you'll set up tasks that you want to do in your everyday life. Then, as you complete the tasks in real life and check them off, you'll earn experience and gold. Gold is used to buy equipment and some items, as well as custom rewards. Experience causes your character to level up and unlock content such as Pets, Skills, and Quests! You can customize your character under Menu > Customize Avatar.\n\n Some basic ways to interact: click the (+) in the upper-right-hand corner to add a new task. Tap on an existing task to edit it, and swipe left on a task to delete it. You can sort tasks using Tags in the upper-left-hand corner, and expand and contract checklists by clicking on the checklist bubble.", - "mobileFaqQuestion2": "How do I set up my tasks?", + "faqQuestion2": "How do I set up my tasks?", "iosFaqAnswer2": "Good Habits (the ones with a +) are tasks that you can do many times a day, such as eating vegetables. Bad Habits (the ones with a -) are tasks that you should avoid, like biting nails. Habits with a + and a - have a good choice and a bad choice, like taking the stairs vs. taking the elevator. Good Habits award experience and gold. Bad Habits subtract health.\n\n Dailies are tasks that you have to do every day, like brushing your teeth or checking your email. You can adjust the days that a Daily is due by tapping to edit it. If you skip a Daily that is due, your avatar will take damage overnight. Be careful not to add too many Dailies at once!\n\n To-Dos are your To-Do list. Completing a To-Do earns you gold and experience. You never lose health from To-Dos. You can add a due date to a To-Do by tapping to edit.", - "mobileFaqQuestion3": "What are some sample tasks?", + "faqQuestion3": "What are some sample tasks?", "iosFaqAnswer3": "The wiki has four lists of sample tasks to use as inspiration:\n\n [Sample Habits](http://habitica.wikia.com/wiki/Sample_Habits)\n\n [Sample Dailies](http://habitica.wikia.com/wiki/Sample_Dailies)\n\n [Sample To-Dos](http://habitica.wikia.com/wiki/Sample_To-Dos)\n\n [Sample Custom Rewards](http://habitica.wikia.com/wiki/Sample_Custom_Rewards)", - "mobileFaqQuestion4": "Why do my tasks change color?", + "faqQuestion4": "Why do my tasks change color?", "iosFaqAnswer4": "Your tasks change color based on how well you are currently accomplishing them! Each new task starts out as a neutral yellow. Perform Dailies or positive Habits more frequently and they move toward blue. Miss a Daily or give in to a bad Habit and the task moves toward red. The redder a task, the more rewards it will give you, but if it's a Daily or bad Habit, the more it will hurt you! This helps motivate you to complete the tasks that are giving you trouble.", - "mobileFaqQuestion5": "Why did my avatar lose health, and how do I regain it?", + "faqQuestion5": "Why did my avatar lose health, and how do I regain it?", "iosFaqAnswer5": "There are several things that can cause you to take damage. First, if you left Dailies incomplete overnight, they will damage you. Second, if you tap a bad Habit, it will damage you. Finally, if you are in a Boss Battle with your Party and one of your Party mates did not complete all their Dailies, the Boss will attack you.\n\n The main way to heal is to gain a level, which restores all your health. You can also buy a Health Potion with gold from the Rewards column. Plus, at level 10 or above, you can choose to become a Healer, and then you will learn healing skills. If you are in a Party with a Healer, they can heal you as well.", - "mobileFaqQuestion6": "How do I play Habitica with my friends?", + "faqQuestion6": "How do I play Habitica with my friends?", "iosFaqAnswer6": "The best way is to invite them to a Party with you, via the [website](https://habitica.com/#/options/groups/party)! We'll add the ability to create a Party from this app soon, but in the meantime you can use the [website](https://habitica.com/#/options/groups/party). Parties can go on quests, battle monsters, and cast skills to support each other. On the website, you and your friends can also join Guilds, which are public chat rooms. Guilds will be added to the app in a future update!", - "mobileFaqQuestion7": "How do I get a Pet or Mount?", + "faqQuestion7": "How do I get a Pet or Mount?", "iosFaqAnswer7": "At level 3, you will unlock the Drop System. Every time you complete a task, you'll have a random chance at receiving an egg, a hatching potion, or a piece of food. They will be stored in Menu > Items.\n\n To hatch a Pet, you'll need an egg and a hatching potion. Tap on the egg to determine the species you want to hatch, and select \"Hatch Egg.\" Then choose a hatching potion to determine its color! Go to Menu > Pets to equip your new Pet to your avatar by clicking on it. \n\n You can also grow your Pets into Mounts by feeding them under Menu > Pets. Tap on a Pet, and then select \"Feed Pet\"! You'll have to feed a pet many times before it becomes a Mount, but if you can figure out its favorite food, it will grow more quickly. Use trial and error, or [see the spoilers here](http://habitica.wikia.com/wiki/Food#Food_Preferences). Once you have a Mount, go to Menu > Mounts and tap on it to equip it to your avatar.\n\n You can also get eggs for Quest Pets by completing certain Quests. (See below to learn more about Quests.)", - "mobileFaqQuestion8": "How do I become a Warrior, Mage, Rogue, or Healer?", + "faqQuestion8": "How do I become a Warrior, Mage, Rogue, or Healer?", "iosFaqAnswer8": "At level 10, you can choose to become a Warrior, Mage, Rogue, or Healer. (All players start as Warriors by default.) Each Class has different equipment options, different Skills that they can cast after level 11, and different advantages. Warriors can easily damage Bosses, withstand more damage from their tasks, and help make their Party tougher. Mages can also easily damage Bosses, as well as level up quickly and restore Mana for their party. Rogues earn the most gold and find the most item drops, and they can help their Party do the same. Finally, Healers can heal themselves and their Party members.\n\n If you don't want to choose a Class immediately -- for example, if you are still working to buy all the gear of your current class -- you can click “Decide Later” and choose later under Menu > Choose Class.", - "mobileFaqQuestion9": "What is the blue stat bar that appears in the Header after level 10?", + "faqQuestion9": "What is the blue stat bar that appears in the Header after level 10?", "iosFaqAnswer9": "The blue bar that appeared when you hit level 10 and chose a Class is your Mana bar. As you continue to level up, you will unlock special Skills that cost Mana to use. Each Class has different Skills, which appear after level 11 under Menu > Use Skills. Unlike your health bar, your Mana bar does not reset when you gain a level. Instead, Mana is gained when you complete Good Habits, Dailies, and To-Dos, and lost when you indulge bad Habits. You'll also regain some Mana overnight -- the more Dailies you completed, the more you will gain.", - "mobileFaqQuestion10": "How do I fight monsters and go on Quests?", + "faqQuestion10": "How do I fight monsters and go on Quests?", "iosFaqAnswer10": "First, you need to join or start a Party (see above). Although you can battle monsters alone, we recommend playing in a group, because this will make Quests much easier. Plus, having a friend to cheer you on as you accomplish your tasks is very motivating!\n\n Next, you need a Quest Scroll, which are stored under Menu > Items. There are three ways to get a scroll:\n\n - At level 15, you get a Quest-line, aka three linked quests. More Quest-lines unlock at levels 30, 40, and 60 respectively. \n\n - When you invite people to your Party on the [website](https://habitica.com/#/options/groups/party), you'll be rewarded with the Basi-List Scroll! (We will add this feature to the app in a future update.)\n\n - You can buy Quests from the Quests Page on the [website](https://habitica.com/#/options/inventory/quests) for gold and gems. (We will add this feature to the app in a future update.)\n\n To battle the Boss or collect items for a Collection Quest, simply complete your tasks normally, and they will be tallied into damage overnight. (Reloading by pulling down on the screen may be required to see the Boss's health bar go down.) If you are fighting a Boss and you missed any Dailies, the Boss will damage your Party at the same time that you damage the Boss. \n\n After level 11 Mages and Warriors will gain Skills that allow them to deal additional damage to the Boss, so these are excellent classes to choose at level 10 if you want to be a heavy hitter.", - "mobileFaqQuestion11": "What are gems, and how do I get them?", + "faqQuestion11": "What are gems, and how do I get them?", "iosFaqAnswer11": "Gems are purchased with real money by tapping on the gem icon in the header. When people buy gems, they are helping us to keep the site running. We're very grateful for their support!\n\n In addition to buying gems directly, there are three other ways players can gain gems:\n\n 1. Win a Challenge on the [website](link) that has been set up by another player under Social > Challenges. (We will be adding Challenges to the app in a future update!)\n\n 2. Subscribe on the [website](link) and unlock the ability to buy a certain number of gems per month.\n\n 3. Contribute your skills to the Habitica project. See this wiki page for more details: [Contributing to Habitica](http://habitica.wikia.com/wiki/Contributing_to_Habitica).\n\n Keep in mind that items purchased with gems do not offer any statistical advantages, so players can still make use of the app without them!", - "mobileFaqQuestion12": "How do I report a bug or request a feature?", + "faqQuestion12": "How do I report a bug or request a feature?", "iosFaqAnswer12": "You can report a bug, request a feature, or send feedback under Menu > Report a Bug and Menu > Send Feedback! We'll do everything we can to assist you.", - "iosStillNeedHelp": "If you have a question that isn't on this list, come ask in the Tavern chat under Menu > Tavern! We're happy to help." + "faqStillNeedHelp": "If you have a question that isn't on this list, come ask in the Tavern chat under Menu > Tavern! We're happy to help." } diff --git a/common/script/content/faq.js b/common/script/content/faq.js index a9ffdea038..ba41910159 100644 --- a/common/script/content/faq.js +++ b/common/script/content/faq.js @@ -11,7 +11,7 @@ faq.questions = []; for (var i = 1; i <= NUMBER_OF_QUESTIONS; i++) { var question = { - question: t('mobileFaqQuestion' + i), + question: t('faqQuestion' + i), ios: t('iosFaqAnswer' + i) }; @@ -19,7 +19,7 @@ for (var i = 1; i <= NUMBER_OF_QUESTIONS; i++) { } faq.stillNeedHelp = { - ios: t('iosStillNeedHelp') + ios: t('faqStillNeedHelp') }; module.exports = faq;