From 9b8e6534d0d7037314a42deb344508cc46134fc1 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Mon, 21 Sep 2015 08:57:35 -0500 Subject: [PATCH] Add pets and egss as modules --- common/locales/en/content.json | 20 ++++++ common/script/content/index.coffee | 72 +++---------------- common/script/src/content/eggs/drops.js | 14 +++- common/script/src/content/eggs/index.js | 28 +++----- common/script/src/content/eggs/quest.js | 50 +++++++++++++ .../script/src/content/pets-mounts/index.js | 29 ++++++++ .../src/content/pets-mounts/special-mounts.js | 13 ++++ .../src/content/pets-mounts/special-pets.js | 15 ++++ 8 files changed, 159 insertions(+), 82 deletions(-) create mode 100644 common/script/src/content/eggs/quest.js create mode 100644 common/script/src/content/pets-mounts/index.js create mode 100644 common/script/src/content/pets-mounts/special-mounts.js create mode 100644 common/script/src/content/pets-mounts/special-pets.js diff --git a/common/locales/en/content.json b/common/locales/en/content.json index ef9240cd91..73a8dac125 100644 --- a/common/locales/en/content.json +++ b/common/locales/en/content.json @@ -44,12 +44,15 @@ "dropEggBearCubAdjective": "cuddly", "questEggGryphonText": "Gryphon", + "questEggGryphonMountText": "Gryphon", "questEggGryphonAdjective": "proud", "questEggHedgehogText": "Hedgehog", + "questEggHedgehogMountText": "Hedgehog", "questEggHedgehogAdjective": "spiky", "questEggDeerText": "Deer", + "questEggDeerMountText": "Deer", "questEggDeerAdjective": "elegant", "questEggEggText": "Egg", @@ -57,54 +60,71 @@ "questEggEggAdjective": "colorful", "questEggRatText": "Rat", + "questEggRatMountText": "Rat", "questEggRatAdjective": "dirty", "questEggOctopusText": "Octopus", + "questEggOctopusMountText": "Octopus", "questEggOctopusAdjective": "slippery", "questEggSeahorseText": "Seahorse", + "questEggSeahorseMountText": "Seahorse", "questEggSeahorseAdjective": "prize", "questEggParrotText": "Parrot", + "questEggParrotMountText": "Parrot", "questEggParrotAdjective": "vibrant", "questEggRoosterText": "Rooster", + "questEggRoosterMountText": "Rooster", "questEggRoosterAdjective": "strutting", "questEggSpiderText": "Spider", + "questEggSpiderMountText": "Spider", "questEggSpiderAdjective": "creepy", "questEggOwlText": "Owl", + "questEggOwlMountText": "Owl", "questEggOwlAdjective": "wise", "questEggPenguinText": "Penguin", + "questEggPenguinMountText": "Penguin", "questEggPenguinAdjective": "perspicacious", "questEggTRexText": "Tyrannosaur", + "questEggTRexMountText": "Tyrannosaur", "questEggTRexAdjective": "tiny-armed", "questEggRockText": "Rock", + "questEggRockMountText": "Rock", "questEggRockAdjective": "lively", "questEggBunnyText": "Bunny", + "questEggBunnyMountText": "Bunny", "questEggBunnyAdjective": "snuggly", "questEggSlimeText": "Marshmallow Slime", + "questEggSlimeMountText": "Marshmallow Slime", "questEggSlimeAdjective": "sweet", "questEggSheepText": "Sheep", + "questEggSheepMountText": "Sheep", "questEggSheepAdjective": "woolly", "questEggCuttlefishText": "Cuttlefish", + "questEggCuttlefishMountText": "Cuttlefish", "questEggCuttlefishAdjective": "cuddly", "questEggWhaleText": "Whale", + "questEggWhaleMountText": "Whale", "questEggWhaleAdjective": "splashy", "questEggCheetahText": "Cheetah", + "questEggCheetahMountText": "Cheetah", "questEggCheetahAdjective": "honest", "questEggHorseText": "Horse", + "questEggHorseMountText": "Horse", "questEggHorseAdjective": "galloping", "eggNotes": "Find a hatching potion to pour on this egg, and it will hatch into a <%= eggAdjective(locale) %> <%= eggText(locale) %>.", diff --git a/common/script/content/index.coffee b/common/script/content/index.coffee index 6ed54553d3..dea517d178 100644 --- a/common/script/content/index.coffee +++ b/common/script/content/index.coffee @@ -572,81 +572,27 @@ eggs = require('../../dist/scripts/content/eggs/index') api.dropEggs = eggs.dropEggs -api.questEggs = - # value & other defaults set below - Gryphon: text: t('questEggGryphonText'), adjective: t('questEggGryphonAdjective'), canBuy: false - Hedgehog: text: t('questEggHedgehogText'), adjective: t('questEggHedgehogAdjective'), canBuy: false - Deer: text: t('questEggDeerText'), adjective: t('questEggDeerAdjective'), canBuy: false - Egg: text: t('questEggEggText'), adjective: t('questEggEggAdjective'), canBuy: false, mountText: t('questEggEggMountText') - Rat: text: t('questEggRatText'), adjective: t('questEggRatAdjective'), canBuy: false - Octopus: text: t('questEggOctopusText'), adjective: t('questEggOctopusAdjective'), canBuy: false - Seahorse: text: t('questEggSeahorseText'), adjective: t('questEggSeahorseAdjective'), canBuy: false - Parrot: text: t('questEggParrotText'), adjective: t('questEggParrotAdjective'), canBuy: false - Rooster: text: t('questEggRoosterText'), adjective: t('questEggRoosterAdjective'), canBuy: false - Spider: text: t('questEggSpiderText'), adjective: t('questEggSpiderAdjective'), canBuy: false - Owl: text: t('questEggOwlText'), adjective: t('questEggOwlAdjective'), canBuy: false - Penguin: text: t('questEggPenguinText'), adjective: t('questEggPenguinAdjective'), canBuy: false - TRex: text: t('questEggTRexText'), adjective: t('questEggTRexAdjective'), canBuy: false - Rock: text: t('questEggRockText'), adjective: t('questEggRockAdjective'), canBuy: false - Bunny: text: t('questEggBunnyText'), adjective: t('questEggBunnyAdjective'), canBuy: false - Slime: text: t('questEggSlimeText'), adjective: t('questEggSlimeAdjective'), canBuy: false - Sheep: text: t('questEggSheepText'), adjective: t('questEggSheepAdjective'), canBuy: false - Cuttlefish: text: t('questEggCuttlefishText'), adjective: t('questEggCuttlefishAdjective'), canBuy: false - Whale: text: t('questEggWhaleText'), adjective: t('questEggWhaleAdjective'), canBuy: false - Cheetah: text: t('questEggCheetahText'), adjective: t('questEggCheetahAdjective'), canBuy: false - Horse: text: t('questEggHorseText'), adjective: t('questEggHorseAdjective'), canBuy: false +api.questEggs = eggs.questEggs -_.each api.questEggs, (egg,key) -> - _.defaults egg, - canBuy:false - value: 3 - key: key - notes: t('eggNotes', {eggText: egg.text, eggAdjective: egg.adjective}) - mountText: egg.text +api.eggs = eggs.allEggs -api.eggs = _.assign(_.cloneDeep(api.dropEggs), api.questEggs) +pets_mounts = require('../../dist/scripts/content/pets-mounts/index') -# special pets & mounts are {key:i18n} -api.specialPets = - 'Wolf-Veteran': 'veteranWolf' - 'Wolf-Cerberus': 'cerberusPup' - 'Dragon-Hydra': 'hydra' - 'Turkey-Base': 'turkey' - 'BearCub-Polar': 'polarBearPup' - 'MantisShrimp-Base': 'mantisShrimp' - 'JackOLantern-Base': 'jackolantern' - 'Mammoth-Base': 'mammoth' - 'Tiger-Veteran': 'veteranTiger' +api.specialPets = pets_mounts.specialPets -api.specialMounts = - 'BearCub-Polar': 'polarBear' - 'LionCub-Ethereal': 'etherealLion' - 'MantisShrimp-Base': 'mantisShrimp' - 'Turkey-Base': 'turkey' - 'Mammoth-Base': 'mammoth' - 'Orca-Base': 'orca' - 'Gryphon-RoyalPurple': 'royalPurpleGryphon' +api.specialMounts = pets_mounts.specialMounts api.timeTravelStable = require('../../dist/scripts/content/time-traveler-stable') api.hatchingPotions = require('../../dist/scripts/content/hatching-potions') -api.pets = _.transform api.dropEggs, (m, egg) -> - _.defaults m, _.transform api.hatchingPotions, (m2, pot) -> - m2[egg.key + "-" + pot.key] = true +api.pets = pets_mounts.dropPets -api.questPets = _.transform api.questEggs, (m, egg) -> - _.defaults m, _.transform api.hatchingPotions, (m2, pot) -> - m2[egg.key + "-" + pot.key] = true +api.questPets = pets_mounts.questPets -## added for mountmaster -- yes, the transforms are correct, since the same strings are used for both pets and mounts -api.mounts = _.transform api.dropEggs, (m, egg) -> - _.defaults m, _.transform api.hatchingPotions, (m2, pot) -> - m2[egg.key + "-" + pot.key] = true +api.mounts = pets_mounts.dropMounts -api.questMounts = _.transform api.questEggs, (m, egg) -> - _.defaults m, _.transform api.hatchingPotions, (m2, pot) -> - m2[egg.key + "-" + pot.key] = true +api.questMounts = pets_mounts.questMounts api.food = require('../../dist/scripts/content/food/index') diff --git a/common/script/src/content/eggs/drops.js b/common/script/src/content/eggs/drops.js index 3f20232956..8e3ead1f9b 100644 --- a/common/script/src/content/eggs/drops.js +++ b/common/script/src/content/eggs/drops.js @@ -1,4 +1,4 @@ -import {each} from 'lodash'; +import {each, defaults} from 'lodash'; import t from '../helpers/translator'; const DROP_EGGS = [ @@ -23,4 +23,16 @@ each(DROP_EGGS, (pet) => { } }); +each(eggs, (egg, key) => { + return defaults(egg, { + canBuy: true, + value: 3, + key: key, + notes: t('eggNotes', { + eggText: egg.text, + eggAdjective: egg.adjective + }), + }); +}); + export default eggs; diff --git a/common/script/src/content/eggs/index.js b/common/script/src/content/eggs/index.js index b0fbc08458..e6ea746eab 100644 --- a/common/script/src/content/eggs/index.js +++ b/common/script/src/content/eggs/index.js @@ -1,23 +1,15 @@ -// value & other defaults set below -let each = require('lodash').each; -let defaults = require('lodash').defaults; -let t = require('../helpers/translator'); +import {assign} from 'lodash'; -let dropEggs = require('./drops'); +import dropEggs from './drops'; +import questEggs from './quest'; -each(dropEggs, (egg, key) => { - return defaults(egg, { - canBuy: true, - value: 3, - key: key, - notes: t('eggNotes', { - eggText: egg.text, - eggAdjective: egg.adjective - }), - mountText: egg.text - }); -}); +let allEggs = {}; + +assign(allEggs, dropEggs); +assign(allEggs, questEggs); export default { - dropEggs: dropEggs + allEggs: allEggs, + dropEggs: dropEggs, + questEggs: questEggs, } diff --git a/common/script/src/content/eggs/quest.js b/common/script/src/content/eggs/quest.js new file mode 100644 index 0000000000..28c9ec0af1 --- /dev/null +++ b/common/script/src/content/eggs/quest.js @@ -0,0 +1,50 @@ +import {each, defaults} from 'lodash'; +import t from '../helpers/translator'; + +const QUEST_EGGS = [ + 'Gryphon', + 'Hedgehog', + 'Deer', + 'Egg', + 'Rat', + 'Octopus', + 'Seahorse', + 'Parrot', + 'Rooster', + 'Spider', + 'Owl', + 'Penguin', + 'TRex', + 'Rock', + 'Bunny', + 'Slime', + 'Sheep', + 'Cuttlefish', + 'Whale', + 'Cheetah', + 'Horse', +]; + +let eggs = { }; + +each(QUEST_EGGS, (pet) => { + eggs[pet] = { + text: t(`questEgg${pet}Text`), + mountText: t(`questEgg${pet}MountText`), + adjective: t(`questEgg${pet}Adjective`), + } +}); + +each(eggs, (egg, key) => { + return defaults(egg, { + canBuy: false, + value: 3, + key: key, + notes: t('eggNotes', { + eggText: egg.text, + eggAdjective: egg.adjective + }), + }); +}); + +export default eggs; diff --git a/common/script/src/content/pets-mounts/index.js b/common/script/src/content/pets-mounts/index.js new file mode 100644 index 0000000000..17fffccaf6 --- /dev/null +++ b/common/script/src/content/pets-mounts/index.js @@ -0,0 +1,29 @@ +import {transform, defaults} from 'lodash'; +import hatchingPotions from '../hatching-potions'; +import dropEggs from '../eggs/drops'; +import questEggs from '../eggs/quest'; + +import specialPets from './special-pets'; +import specialMounts from './special-mounts'; + +let dropPets = generateAnimalSet(dropEggs); +let questPets = generateAnimalSet(questEggs); +let dropMounts = generateAnimalSet(dropEggs); +let questMounts = generateAnimalSet(questEggs); + +function generateAnimalSet(set) { + return transform(set, function(m, egg) { + defaults(m, transform(hatchingPotions, function(m2, pot) { + return m2[egg.key + "-" + pot.key] = true; + })); + }); +} + +export default { + dropPets: dropPets, + dropMounts: dropMounts, + questPets: questPets, + questMounts: questMounts, + specialPets: specialPets, + specialMounts: specialMounts, +} diff --git a/common/script/src/content/pets-mounts/special-mounts.js b/common/script/src/content/pets-mounts/special-mounts.js new file mode 100644 index 0000000000..e2410e0945 --- /dev/null +++ b/common/script/src/content/pets-mounts/special-mounts.js @@ -0,0 +1,13 @@ +// special mounts are {key:i18n} + +let specialMounts = { + 'BearCub-Polar': 'polarBear', + 'LionCub-Ethereal': 'etherealLion', + 'MantisShrimp-Base': 'mantisShrimp', + 'Turkey-Base': 'turkey', + 'Mammoth-Base': 'mammoth', + 'Orca-Base': 'orca', + 'Gryphon-RoyalPurple': 'royalPurpleGryphon', +} + +export default specialMounts; diff --git a/common/script/src/content/pets-mounts/special-pets.js b/common/script/src/content/pets-mounts/special-pets.js new file mode 100644 index 0000000000..5097631c0e --- /dev/null +++ b/common/script/src/content/pets-mounts/special-pets.js @@ -0,0 +1,15 @@ +// special mounts are {key:i18n} + +let specialPets = { + 'Wolf-Veteran': 'veteranWolf', + 'Wolf-Cerberus': 'cerberusPup', + 'Dragon-Hydra': 'hydra', + 'Turkey-Base': 'turkey', + 'BearCub-Polar': 'polarBearPup', + 'MantisShrimp-Base': 'mantisShrimp', + 'JackOLantern-Base': 'jackolantern', + 'Mammoth-Base': 'mammoth', + 'Tiger-Veteran': 'veteranTiger', +} + +export default specialPets;