2013-12-11 16:30:07 +00:00
|
|
|
api = module.exports
|
2015-09-06 20:54:38 +00:00
|
|
|
|
|
|
|
|
_ = require 'lodash'
|
2013-12-20 18:03:16 +00:00
|
|
|
moment = require 'moment'
|
2015-09-17 22:40:59 +00:00
|
|
|
|
2015-09-21 22:35:27 +00:00
|
|
|
t = require('../../dist/scripts/content/helpers').translator
|
2015-09-17 13:03:33 +00:00
|
|
|
|
2013-11-22 19:35:27 +00:00
|
|
|
###
|
2014-03-24 02:18:09 +00:00
|
|
|
---------------------------------------------------------------
|
|
|
|
|
Gear (Weapons, Armor, Head, Shield)
|
|
|
|
|
Item definitions: {index, text, notes, value, str, def, int, per, classes, type}
|
|
|
|
|
---------------------------------------------------------------
|
2013-11-22 19:35:27 +00:00
|
|
|
###
|
|
|
|
|
|
2014-01-10 04:33:01 +00:00
|
|
|
classes = ['warrior', 'rogue', 'healer', 'wizard']
|
2014-08-29 08:49:37 +00:00
|
|
|
gearTypes = [ 'weapon', 'armor', 'head', 'shield', 'body', 'back', 'headAccessory', 'eyewear']
|
2014-01-10 04:33:01 +00:00
|
|
|
|
2015-09-20 00:37:40 +00:00
|
|
|
events = require('../../dist/scripts/content/events')
|
2013-12-11 16:30:07 +00:00
|
|
|
|
2015-09-20 00:37:40 +00:00
|
|
|
api.mystery = require('../../dist/scripts/content/mystery-sets')
|
2014-03-09 04:14:20 +00:00
|
|
|
|
2015-09-21 17:20:10 +00:00
|
|
|
api.itemList = require('../../dist/scripts/content/item-list')
|
2015-06-29 08:11:12 +00:00
|
|
|
|
2015-09-21 17:20:10 +00:00
|
|
|
gear = require('../../dist/scripts/content/gear/index')
|
2014-08-29 08:49:37 +00:00
|
|
|
|
2013-11-22 19:35:27 +00:00
|
|
|
###
|
2014-03-24 02:18:09 +00:00
|
|
|
The gear is exported as a tree (defined above), and a flat list (eg, {weapon_healer_1: .., shield_special_0: ...}) since
|
2015-07-23 17:05:13 +00:00
|
|
|
they are needed in different forms at different points in the app
|
2013-11-30 21:55:25 +00:00
|
|
|
###
|
2013-12-11 16:30:07 +00:00
|
|
|
api.gear =
|
2013-11-30 21:55:25 +00:00
|
|
|
tree: gear
|
|
|
|
|
flat: {}
|
2013-11-22 19:35:27 +00:00
|
|
|
|
2014-01-10 04:33:01 +00:00
|
|
|
_.each gearTypes, (type) ->
|
2015-05-26 21:06:04 +00:00
|
|
|
_.each classes.concat(['base', 'special', 'mystery', 'armoire']), (klass) ->
|
2013-11-22 19:35:27 +00:00
|
|
|
# add "type" to each item, so we can reference that as "weapon" or "armor" in the html
|
2013-12-05 22:48:13 +00:00
|
|
|
_.each gear[type][klass], (item, i) ->
|
|
|
|
|
key = "#{type}_#{klass}_#{i}"
|
|
|
|
|
_.defaults item, {type, key, klass, index: i, str:0, int:0, per:0, con:0}
|
2014-01-06 21:43:01 +00:00
|
|
|
|
|
|
|
|
if item.event
|
|
|
|
|
#? indicates null/undefined. true means they own currently, false means they once owned - and false is what we're
|
|
|
|
|
# after (they can buy back if they bought it during the event's timeframe)
|
|
|
|
|
_canOwn = item.canOwn or (->true)
|
|
|
|
|
item.canOwn = (u)->
|
2014-03-21 20:12:05 +00:00
|
|
|
_canOwn(u) and
|
|
|
|
|
(u.items.gear.owned[key]? or (moment().isAfter(item.event.start) and moment().isBefore(item.event.end))) and
|
|
|
|
|
(if item.specialClass then (u.stats.class is item.specialClass) else true)
|
2014-01-06 21:43:01 +00:00
|
|
|
|
2014-03-09 23:23:22 +00:00
|
|
|
if item.mystery
|
|
|
|
|
item.canOwn = (u)-> u.items.gear.owned[key]?
|
|
|
|
|
|
2013-12-11 16:30:07 +00:00
|
|
|
api.gear.flat[key] = item
|
2013-11-22 19:35:27 +00:00
|
|
|
|
2014-11-29 18:16:54 +00:00
|
|
|
###
|
|
|
|
|
Time Traveler Store, mystery sets need their items mapped in
|
|
|
|
|
###
|
|
|
|
|
_.each api.mystery, (v,k)-> v.items = _.where api.gear.flat, {mystery:k}
|
2015-09-15 17:40:01 +00:00
|
|
|
api.timeTravelerStore = (owned) ->
|
2014-11-29 18:16:54 +00:00
|
|
|
ownedKeys = _.keys owned.toObject?() or owned # mongoose workaround
|
2015-09-15 17:40:01 +00:00
|
|
|
_.reduce api.mystery, (m,v,k)->
|
|
|
|
|
return m if k=='wondercon' or ~ownedKeys.indexOf(v.items[0].key) # skip wondercon and already-owned sets
|
|
|
|
|
m[k] = v;m
|
|
|
|
|
, {}
|
2014-11-29 18:16:54 +00:00
|
|
|
|
2013-11-22 19:35:27 +00:00
|
|
|
###
|
2014-03-24 02:18:09 +00:00
|
|
|
---------------------------------------------------------------
|
2015-05-26 21:06:04 +00:00
|
|
|
Unique Rewards: Potion and Armoire
|
2014-03-24 02:18:09 +00:00
|
|
|
---------------------------------------------------------------
|
2013-11-22 19:35:27 +00:00
|
|
|
###
|
|
|
|
|
|
2015-08-14 11:41:10 +00:00
|
|
|
api.potion =
|
|
|
|
|
type: 'potion',
|
|
|
|
|
text: t('potionText'),
|
|
|
|
|
notes: t('potionNotes'),
|
|
|
|
|
value: 25,
|
|
|
|
|
key: 'potion'
|
|
|
|
|
|
|
|
|
|
api.armoire =
|
|
|
|
|
type: 'armoire',
|
|
|
|
|
text: t('armoireText'),
|
2015-08-14 11:59:23 +00:00
|
|
|
notes: ((user, count)->
|
|
|
|
|
return t('armoireNotesEmpty')() if (user.flags.armoireEmpty)
|
|
|
|
|
return t('armoireNotesFull')() + count
|
|
|
|
|
),
|
2015-08-14 11:41:10 +00:00
|
|
|
value: 100,
|
|
|
|
|
key: 'armoire',
|
|
|
|
|
canOwn: ((u)-> _.contains(u.achievements.ultimateGearSets, true))
|
2013-11-22 19:35:27 +00:00
|
|
|
|
2014-01-10 04:33:01 +00:00
|
|
|
###
|
2014-03-24 02:18:09 +00:00
|
|
|
---------------------------------------------------------------
|
|
|
|
|
Classes
|
|
|
|
|
---------------------------------------------------------------
|
2014-01-10 04:33:01 +00:00
|
|
|
###
|
|
|
|
|
|
|
|
|
|
api.classes = classes
|
|
|
|
|
|
|
|
|
|
###
|
2014-03-24 02:18:09 +00:00
|
|
|
---------------------------------------------------------------
|
|
|
|
|
Gear Types
|
|
|
|
|
---------------------------------------------------------------
|
2014-01-10 04:33:01 +00:00
|
|
|
###
|
|
|
|
|
|
|
|
|
|
api.gearTypes = gearTypes
|
|
|
|
|
|
2015-09-20 00:37:40 +00:00
|
|
|
api.spells = require('../../dist/scripts/content/spells/index')
|
2015-08-14 11:41:10 +00:00
|
|
|
|
2015-09-20 00:37:40 +00:00
|
|
|
api.cardTypes = require('../../dist/scripts/content/card-types')
|
2015-08-13 19:31:34 +00:00
|
|
|
|
2013-11-22 19:35:27 +00:00
|
|
|
# Intercept all spells to reduce user.stats.mp after casting the spell
|
2013-12-11 16:30:07 +00:00
|
|
|
_.each api.spells, (spellClass) ->
|
2013-12-20 19:42:31 +00:00
|
|
|
_.each spellClass, (spell, key) ->
|
|
|
|
|
spell.key = key
|
2013-11-22 19:35:27 +00:00
|
|
|
_cast = spell.cast
|
|
|
|
|
spell.cast = (user, target) ->
|
|
|
|
|
#return if spell.target and spell.target != (if target.type then 'task' else 'user')
|
|
|
|
|
_cast(user,target)
|
2013-12-17 23:43:10 +00:00
|
|
|
user.stats.mp -= spell.mana
|
2013-11-22 19:35:27 +00:00
|
|
|
|
2013-12-20 17:21:24 +00:00
|
|
|
api.special = api.spells.special
|
|
|
|
|
|
2013-11-22 19:35:27 +00:00
|
|
|
###
|
2014-03-24 02:18:09 +00:00
|
|
|
---------------------------------------------------------------
|
|
|
|
|
Drops
|
|
|
|
|
---------------------------------------------------------------
|
2013-11-22 19:35:27 +00:00
|
|
|
###
|
2013-05-19 17:01:01 +00:00
|
|
|
|
2015-09-20 00:37:40 +00:00
|
|
|
eggs = require('../../dist/scripts/content/eggs/index')
|
2015-09-17 13:42:21 +00:00
|
|
|
|
|
|
|
|
api.dropEggs = eggs.dropEggs
|
2014-02-09 00:56:07 +00:00
|
|
|
|
2015-09-21 13:57:35 +00:00
|
|
|
api.questEggs = eggs.questEggs
|
|
|
|
|
|
|
|
|
|
api.eggs = eggs.allEggs
|
|
|
|
|
|
|
|
|
|
pets_mounts = require('../../dist/scripts/content/pets-mounts/index')
|
|
|
|
|
|
|
|
|
|
api.specialPets = pets_mounts.specialPets
|
|
|
|
|
|
|
|
|
|
api.specialMounts = pets_mounts.specialMounts
|
2014-02-09 00:56:07 +00:00
|
|
|
|
2015-09-20 00:37:40 +00:00
|
|
|
api.timeTravelStable = require('../../dist/scripts/content/time-traveler-stable')
|
2015-09-01 21:17:50 +00:00
|
|
|
|
2015-09-20 12:46:30 +00:00
|
|
|
api.hatchingPotions = require('../../dist/scripts/content/hatching-potions')
|
2013-11-11 03:38:06 +00:00
|
|
|
|
2015-09-21 13:57:35 +00:00
|
|
|
api.pets = pets_mounts.dropPets
|
2014-02-09 00:56:07 +00:00
|
|
|
|
2015-09-21 13:57:35 +00:00
|
|
|
api.questPets = pets_mounts.questPets
|
2014-01-02 23:30:14 +00:00
|
|
|
|
2015-09-21 13:57:35 +00:00
|
|
|
api.mounts = pets_mounts.dropMounts
|
2014-10-30 19:35:14 +00:00
|
|
|
|
2015-09-21 13:57:35 +00:00
|
|
|
api.questMounts = pets_mounts.questMounts
|
2014-10-30 19:35:14 +00:00
|
|
|
|
2015-09-20 12:10:35 +00:00
|
|
|
api.food = require('../../dist/scripts/content/food/index')
|
2013-12-20 19:42:31 +00:00
|
|
|
|
2015-09-20 11:55:21 +00:00
|
|
|
quests = require('../../dist/scripts/content/quests/index')
|
2015-08-10 18:42:36 +00:00
|
|
|
|
2015-09-20 11:55:21 +00:00
|
|
|
api.userCanOwnQuestCategories = quests.canOwnCategories
|
2013-05-19 17:01:01 +00:00
|
|
|
|
2015-09-21 01:46:35 +00:00
|
|
|
api.quests = quests.allQuests
|
2015-09-20 11:55:21 +00:00
|
|
|
|
|
|
|
|
api.questsByLevel = quests.byLevel
|
2015-07-08 21:13:23 +00:00
|
|
|
|
2015-09-20 02:12:09 +00:00
|
|
|
api.backgrounds = require('../../dist/scripts/content/backgrounds')
|
2014-06-09 19:32:37 +00:00
|
|
|
|
2015-09-20 00:42:47 +00:00
|
|
|
api.subscriptionBlocks = require('../../dist/scripts/content/subscription-blocks')
|
2014-11-18 00:36:03 +00:00
|
|
|
|
2015-09-20 00:36:35 +00:00
|
|
|
api.userDefaults = require('../../dist/scripts/content/user-defaults')
|
2015-09-06 21:08:53 +00:00
|
|
|
|
2015-09-20 00:36:54 +00:00
|
|
|
api.faq = require('../../dist/scripts/content/faq')
|
2015-09-20 00:29:56 +00:00
|
|
|
|