import {translator as t} from '../helpers'; import {each, defaults} from 'lodash'; import moment from 'moment'; //-------------------------------------------------- // Gear is structured by equipment type, but organized by set. Each set exports the equipment for each type that it has // // The class sets have numbered key values, as they are purchased sequentially // // : { // key: __, // type: , // klass: , // index: , // text: t(Text), // notes: t(Notes { // // }), // con: , // int: , // per: , // str: , // value: , // last: , // // event: , // canOwn: , // mystery: // } // // - What type of euqipment it is (armor, head, weapon, etc) // - What set this gear is a part of (special, mystery, warrior, etc) // - The order in this particular set // - CamelCased version of key // // - if gear has stat bonuses, they are automatically applied to notes // // - Boost to con, defaults to 0 // - Boost to int, defaults to 0 // - Boost to per, defaults to 0 // - Boost to str, defaults to 0 // // - Price in gold // - whether this is the last in a particular class set // // - the event key, present if gear is part of an event // - a function that determines whether or not gear can be purchased in the rewards column // - the mystery set key, present if item is a mystery item // //-------------------------------------------------- import classes from '../classes'; import weapon from './weapon'; import armor from './armor'; import head from './head'; import shield from './shield'; import back from './back'; import body from './body'; import headAccessory from './head-accessory'; import eyewear from './eyewear'; const GEAR_TYPES = [ 'weapon', 'armor', 'head', 'shield', 'body', 'back', 'headAccessory', 'eyewear'] let gear = { weapon: weapon, armor: armor, head: head, shield: shield, back: back, body: body, headAccessory: headAccessory, eyewear: eyewear, }; let flat = {}; // The gear is exported as a tree (defined above), and a flat list (eg, {weapon_healer_1: .., shield_special_0: ...}) since // they are needed in different forms at different points in the app each(GEAR_TYPES, (type) => { let classTypes = classes.concat(['base', 'special', 'mystery', 'armoire']); each(classTypes, (klass) => { each(gear[type][klass], (item, i) => { let key = type + "_" + klass + "_" + i; defaults(item, { type: type, key: key, klass: klass, index: i, str: 0, int: 0, per: 0, con: 0 }); if (item.event) { let _canOwn = item.canOwn || (() => { return true; }); item.canOwn = (u) => { return _canOwn(u) && ((u.items.gear.owned[key] != null) || (moment().isAfter(item.event.start) && moment().isBefore(item.event.end))) && (item.specialClass ? u.stats["class"] === item.specialClass : true); }; } if (item.mystery) { item.canOwn = (u) => { return u.items.gear.owned[key] != null; }; } flat[key] = item; }); }); }); export default { tree: gear, flat: flat, gearTypes: GEAR_TYPES };