feat(plans): time traveler - by full sets

This commit is contained in:
Tyler Renelle 2014-11-29 11:16:54 -07:00
parent d81badde69
commit bf7e1e66ed
3 changed files with 213 additions and 140 deletions

View file

@ -9793,7 +9793,7 @@ process.chdir = function (dir) {
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],5:[function(require,module,exports){
var api, classes, diminishingReturns, events, gear, gearTypes, i18n, moment, mystery, repeat, t, _;
var api, classes, diminishingReturns, events, gear, gearTypes, i18n, moment, repeat, t, _;
_ = require('lodash');
@ -9856,54 +9856,66 @@ events = {
}
};
mystery = {
api.mystery = {
201402: {
start: '2014-02-22',
end: '2014-02-28'
end: '2014-02-28',
text: 'Winged Messenger Set'
},
201403: {
start: '2014-03-24',
end: '2014-04-02'
end: '2014-04-02',
text: 'Forest Walker Set'
},
201404: {
start: '2014-04-24',
end: '2014-05-02'
end: '2014-05-02',
text: 'Twilight Butterfly Set'
},
201405: {
start: '2014-05-21',
end: '2014-06-02'
end: '2014-06-02',
text: 'Flame Wielder Set'
},
201406: {
start: '2014-06-23',
end: '2014-07-02'
end: '2014-07-02',
text: 'Octomage Set'
},
201407: {
start: '2014-07-23',
end: '2014-08-02'
end: '2014-08-02',
text: 'Undersea Explorer Set'
},
201408: {
start: '2014-08-23',
end: '2014-09-02'
end: '2014-09-02',
text: 'Sun Sorcerer Set'
},
201409: {
start: '2014-09-24',
end: '2014-10-02'
end: '2014-10-02',
text: 'Autumn Strider Item Set'
},
201410: {
start: '2014-10-24',
end: '2014-11-02'
end: '2014-11-02',
text: 'Winged Goblin Set'
},
201411: {
start: '2014-11-24',
end: '2014-12-02'
end: '2014-12-02',
text: 'Feast and Fun Set'
},
301404: {
start: '3014-03-24',
end: '3014-04-02'
end: '3014-04-02',
text: 'Steampunk Standard Set'
},
301405: {
start: '3014-04-24',
end: '3014-05-02'
end: '3014-05-02',
text: 'Steampunk Accessories Set'
},
wondercon: {
start: '2014-03-24',
@ -9911,6 +9923,10 @@ mystery = {
}
};
_.each(api.mystery, function(v, k) {
return v.key = k;
});
gear = {
weapon: {
base: {
@ -10409,13 +10425,13 @@ gear = {
201411: {
text: t('weaponMystery201411Text'),
notes: t('weaponMystery201411Notes'),
mystery: mystery['201411'],
mystery: '201411',
value: 0
},
301404: {
text: t('weaponMystery301404Text'),
notes: t('weaponMystery301404Notes'),
mystery: mystery['301404'],
mystery: '301404',
value: 0
}
}
@ -10818,55 +10834,55 @@ gear = {
201402: {
text: t('armorMystery201402Text'),
notes: t('armorMystery201402Notes'),
mystery: mystery['201402'],
mystery: '201402',
value: 0
},
201403: {
text: t('armorMystery201403Text'),
notes: t('armorMystery201403Notes'),
mystery: mystery['201403'],
mystery: '201403',
value: 0
},
201405: {
text: t('armorMystery201405Text'),
notes: t('armorMystery201405Notes'),
mystery: mystery['201405'],
mystery: '201405',
value: 0
},
201406: {
text: t('armorMystery201406Text'),
notes: t('armorMystery201406Notes'),
mystery: mystery['201406'],
mystery: '201406',
value: 0
},
201407: {
text: t('armorMystery201407Text'),
notes: t('armorMystery201407Notes'),
mystery: mystery['201407'],
mystery: '201407',
value: 0
},
201408: {
text: t('armorMystery201408Text'),
notes: t('armorMystery201408Notes'),
mystery: mystery['201408'],
mystery: '201408',
value: 0
},
201409: {
text: t('armorMystery201409Text'),
notes: t('armorMystery201409Notes'),
mystery: mystery['201409'],
mystery: '201409',
value: 0
},
201410: {
text: t('armorMystery201410Text'),
notes: t('armorMystery201410Notes'),
mystery: mystery['201410'],
mystery: '201410',
value: 0
},
301404: {
text: t('armorMystery301404Text'),
notes: t('armorMystery301404Notes'),
mystery: mystery['301404'],
mystery: '301404',
value: 0
}
}
@ -11269,49 +11285,49 @@ gear = {
201402: {
text: t('headMystery201402Text'),
notes: t('headMystery201402Notes'),
mystery: mystery['201402'],
mystery: '201402',
value: 0
},
201405: {
text: t('headMystery201405Text'),
notes: t('headMystery201405Notes'),
mystery: mystery['201405'],
mystery: '201405',
value: 0
},
201406: {
text: t('headMystery201406Text'),
notes: t('headMystery201406Notes'),
mystery: mystery['201406'],
mystery: '201406',
value: 0
},
201407: {
text: t('headMystery201407Text'),
notes: t('headMystery201407Notes'),
mystery: mystery['201407'],
mystery: '201407',
value: 0
},
201408: {
text: t('headMystery201408Text'),
notes: t('headMystery201408Notes'),
mystery: mystery['201408'],
mystery: '201408',
value: 0
},
201411: {
text: t('headMystery201411Text'),
notes: t('headMystery201411Notes'),
mystery: mystery['201411'],
mystery: '201411',
value: 0
},
301404: {
text: t('headMystery301404Text'),
notes: t('headMystery301404Notes'),
mystery: mystery['301404'],
mystery: '301404',
value: 0
},
301405: {
text: t('headMystery301405Text'),
notes: t('headMystery301405Notes'),
mystery: mystery['301405'],
mystery: '301405',
value: 0
}
}
@ -11633,7 +11649,7 @@ gear = {
301405: {
text: t('shieldMystery301405Text'),
notes: t('shieldMystery301405Notes'),
mystery: mystery['301405'],
mystery: '301405',
value: 0
}
}
@ -11650,19 +11666,19 @@ gear = {
201402: {
text: t('backMystery201402Text'),
notes: t('backMystery201402Notes'),
mystery: mystery['201402'],
mystery: '201402',
value: 0
},
201404: {
text: t('backMystery201404Text'),
notes: t('backMystery201404Notes'),
mystery: mystery['201404'],
mystery: '201404',
value: 0
},
201410: {
text: t('backMystery201410Text'),
notes: t('backMystery201410Notes'),
mystery: mystery['201410'],
mystery: '201410',
value: 0
}
},
@ -11671,13 +11687,13 @@ gear = {
text: t('backSpecialWonderconRedText'),
notes: t('backSpecialWonderconRedNotes'),
value: 0,
mystery: mystery.wondercon
mystery: 'wondercon'
},
wondercon_black: {
text: t('backSpecialWonderconBlackText'),
notes: t('backSpecialWonderconBlackNotes'),
value: 0,
mystery: mystery.wondercon
mystery: 'wondercon'
}
}
},
@ -11694,19 +11710,19 @@ gear = {
text: t('bodySpecialWonderconRedText'),
notes: t('bodySpecialWonderconRedNotes'),
value: 0,
mystery: mystery.wondercon
mystery: 'wondercon'
},
wondercon_gold: {
text: t('bodySpecialWonderconGoldText'),
notes: t('bodySpecialWonderconGoldNotes'),
value: 0,
mystery: mystery.wondercon
mystery: 'wondercon'
},
wondercon_black: {
text: t('bodySpecialWonderconBlackText'),
notes: t('bodySpecialWonderconBlackNotes'),
value: 0,
mystery: mystery.wondercon
mystery: 'wondercon'
},
summerHealer: {
event: events.summer,
@ -11767,25 +11783,25 @@ gear = {
201403: {
text: t('headAccessoryMystery201403Text'),
notes: t('headAccessoryMystery201403Notes'),
mystery: mystery['201403'],
mystery: '201403',
value: 0
},
201404: {
text: t('headAccessoryMystery201404Text'),
notes: t('headAccessoryMystery201404Notes'),
mystery: mystery['201404'],
mystery: '201404',
value: 0
},
201409: {
text: t('headAccessoryMystery201409Text'),
notes: t('headAccessoryMystery201409Notes'),
mystery: mystery['201409'],
mystery: '201409',
value: 0
},
301405: {
text: t('headAccessoryMystery301405Text'),
notes: t('headAccessoryMystery301405Notes'),
mystery: mystery['301405'],
mystery: '301405',
value: 0
}
}
@ -11804,13 +11820,13 @@ gear = {
text: t('eyewearSpecialWonderconRedText'),
notes: t('eyewearSpecialWonderconRedNotes'),
value: 0,
mystery: mystery.wondercon
mystery: 'wondercon'
},
wondercon_black: {
text: t('eyewearSpecialWonderconBlackText'),
notes: t('eyewearSpecialWonderconBlackNotes'),
value: 0,
mystery: mystery.wondercon
mystery: 'wondercon'
},
summerRogue: {
event: events.summer,
@ -11831,13 +11847,13 @@ gear = {
301404: {
text: t('eyewearMystery301404Text'),
notes: t('eyewearMystery301404Notes'),
mystery: mystery['301404'],
mystery: '301404',
value: 0
},
301405: {
text: t('eyewearMystery301405Text'),
notes: t('eyewearMystery301405Notes'),
mystery: mystery['301405'],
mystery: '301405',
value: 0
}
}
@ -11889,6 +11905,29 @@ _.each(gearTypes, function(type) {
});
/*
Time Traveler Store, mystery sets need their items mapped in
*/
_.each(api.mystery, function(v, k) {
return v.items = _.where(api.gear.flat, {
mystery: k
});
});
api.timeTravelerStore = function(owned) {
var ownedKeys;
ownedKeys = _.keys((typeof owned.toObject === "function" ? owned.toObject() : void 0) || owned);
return _.reduce(api.mystery, function(m, v, k) {
if (k === 'wondercon' || ~ownedKeys.indexOf(v.items[0].key)) {
return m;
}
m[k] = v;
return m;
}, {});
};
/*
---------------------------------------------------------------
Potion
@ -15126,36 +15165,26 @@ api.wrap = function(user, main) {
return typeof cb === "function" ? cb(null, user) : void 0;
},
buy: function(req, cb) {
var item, key, message, trinket;
var item, key, message;
key = req.params.key;
trinket = req.query.trinket;
item = key === 'potion' ? content.potion : content.gear.flat[key];
if (trinket) {
if (!(item.klass === 'mystery' && user.purchased.plan.consecutive.trinkets > 0)) {
return typeof cb === "function" ? cb({
code: 401,
message: "Not enough Time Trinkets"
}) : void 0;
}
} else {
if (!item) {
return typeof cb === "function" ? cb({
code: 404,
message: "Item '" + key + " not found (see https://github.com/HabitRPG/habitrpg-shared/blob/develop/script/content.coffee)"
}) : void 0;
}
if (user.stats.gp < item.value) {
return typeof cb === "function" ? cb({
code: 401,
message: i18n.t('messageNotEnoughGold', req.language)
}) : void 0;
}
if ((item.canOwn != null) && !item.canOwn(user)) {
return typeof cb === "function" ? cb({
code: 401,
message: "You can't own this item"
}) : void 0;
}
if (!item) {
return typeof cb === "function" ? cb({
code: 404,
message: "Item '" + key + " not found (see https://github.com/HabitRPG/habitrpg-shared/blob/develop/script/content.coffee)"
}) : void 0;
}
if (user.stats.gp < item.value) {
return typeof cb === "function" ? cb({
code: 401,
message: i18n.t('messageNotEnoughGold', req.language)
}) : void 0;
}
if ((item.canOwn != null) && !item.canOwn(user)) {
return typeof cb === "function" ? cb({
code: 401,
message: "You can't own this item"
}) : void 0;
}
if (item.key === 'potion') {
user.stats.hp += 15;
@ -15175,16 +15204,39 @@ api.wrap = function(user, main) {
user.fns.ultimateGear();
}
}
if (trinket) {
user.purchased.plan.consecutive.trinkets--;
} else {
user.stats.gp -= item.value;
}
user.stats.gp -= item.value;
return typeof cb === "function" ? cb({
code: 200,
message: message
}, _.pick(user, $w('items achievements stats'))) : void 0;
},
buyMysterySet: function(req, cb) {
var mysterySet, _ref;
if (!(user.purchased.plan.consecutive.trinkets > 0)) {
return typeof cb === "function" ? cb({
code: 401,
message: "You don't have enough Mystic Hourglasses"
}) : void 0;
}
mysterySet = (_ref = content.timeTravelerStore(user.items.gear.owned)) != null ? _ref[req.params.key] : void 0;
if ((typeof window !== "undefined" && window !== null ? window.confirm : void 0) != null) {
if (!window.confirm("Buy this full set of items for 1 Mystic Hourglass?")) {
return;
}
}
if (!mysterySet) {
return typeof cb === "function" ? cb({
code: 404,
message: "Mystery set not found, or set already owned"
}) : void 0;
}
_.each(mysterySet.items, function(i) {
return user.items.gear.owned[i.key] = true;
});
console.log(user.items.gear.owned);
user.purchased.plan.consecutive.trinkets--;
return typeof cb === "function" ? cb(null, _.pick(user, $w('items purchased.plan.consecutive'))) : void 0;
},
sell: function(req, cb) {
var key, type, _ref;
_ref = req.params, key = _ref.key, type = _ref.type;

View file

@ -27,20 +27,21 @@ events =
gaymerx: {start:'2014-07-02',end:'2014-08-01'}
fall: {start:'2014-09-21',end:'2014-11-01'}
mystery =
201402: {start:'2014-02-22',end:'2014-02-28'}
201403: {start:'2014-03-24',end:'2014-04-02'}
201404: {start:'2014-04-24',end:'2014-05-02'}
201405: {start:'2014-05-21',end:'2014-06-02'}
201406: {start:'2014-06-23',end:'2014-07-02'}
201407: {start:'2014-07-23',end:'2014-08-02'}
201408: {start:'2014-08-23',end:'2014-09-02'}
201409: {start:'2014-09-24',end:'2014-10-02'}
201410: {start:'2014-10-24',end:'2014-11-02'}
201411: {start:'2014-11-24',end:'2014-12-02'}
301404: {start:'3014-03-24',end:'3014-04-02'}
301405: {start:'3014-04-24',end:'3014-05-02'}
api.mystery =
201402: {start:'2014-02-22',end:'2014-02-28', text:'Winged Messenger Set'}
201403: {start:'2014-03-24',end:'2014-04-02', text:'Forest Walker Set'}
201404: {start:'2014-04-24',end:'2014-05-02', text:'Twilight Butterfly Set'}
201405: {start:'2014-05-21',end:'2014-06-02', text:'Flame Wielder Set'}
201406: {start:'2014-06-23',end:'2014-07-02', text:'Octomage Set'}
201407: {start:'2014-07-23',end:'2014-08-02', text:'Undersea Explorer Set'}
201408: {start:'2014-08-23',end:'2014-09-02', text:'Sun Sorcerer Set'}
201409: {start:'2014-09-24',end:'2014-10-02', text:'Autumn Strider Item Set'}
201410: {start:'2014-10-24',end:'2014-11-02', text:'Winged Goblin Set'}
201411: {start:'2014-11-24',end:'2014-12-02', text:'Feast and Fun Set'}
301404: {start:'3014-03-24',end:'3014-04-02', text:'Steampunk Standard Set'}
301405: {start:'3014-04-24',end:'3014-05-02', text:'Steampunk Accessories Set'}
wondercon: {start:'2014-03-24',end:'2014-04-01'} # not really, but the mechanic works
_.each api.mystery, (v,k)->v.key = k
gear =
weapon:
@ -114,8 +115,8 @@ gear =
fallMage: event: events.fall, specialClass: 'wizard', twoHanded:true, text: t('weaponSpecialFallMageText'), notes: t('weaponSpecialFallMageNotes', {int: 15, per: 7}), value: 160, int:15, per:7
fallHealer: event: events.fall, specialClass: 'healer', text: t('weaponSpecialFallHealerText'), notes: t('weaponSpecialFallHealerNotes', {int: 9}), value: 90, int: 9
mystery:
201411: text: t('weaponMystery201411Text'), notes: t('weaponMystery201411Notes'), mystery:mystery['201411'], value: 0
301404: text: t('weaponMystery301404Text'), notes: t('weaponMystery301404Notes'), mystery:mystery['301404'], value: 0
201411: text: t('weaponMystery201411Text'), notes: t('weaponMystery201411Notes'), mystery:'201411', value: 0
301404: text: t('weaponMystery301404Text'), notes: t('weaponMystery301404Notes'), mystery:'301404', value: 0
armor:
base:
@ -176,15 +177,15 @@ gear =
# Other
gaymerx: event: events.gaymerx, text: t('armorSpecialGaymerxText'), notes: t('armorSpecialGaymerxNotes'), value: 0
mystery:
201402: text: t('armorMystery201402Text'), notes: t('armorMystery201402Notes'), mystery:mystery['201402'], value: 0
201403: text: t('armorMystery201403Text'), notes: t('armorMystery201403Notes'), mystery:mystery['201403'], value: 0
201405: text: t('armorMystery201405Text'), notes: t('armorMystery201405Notes'), mystery:mystery['201405'], value: 0
201406: text: t('armorMystery201406Text'), notes: t('armorMystery201406Notes'), mystery:mystery['201406'], value: 0
201407: text: t('armorMystery201407Text'), notes: t('armorMystery201407Notes'), mystery:mystery['201407'], value: 0
201408: text: t('armorMystery201408Text'), notes: t('armorMystery201408Notes'), mystery:mystery['201408'], value: 0
201409: text: t('armorMystery201409Text'), notes: t('armorMystery201409Notes'), mystery:mystery['201409'], value: 0
201410: text: t('armorMystery201410Text'), notes: t('armorMystery201410Notes'), mystery:mystery['201410'], value: 0
301404: text: t('armorMystery301404Text'), notes: t('armorMystery301404Notes'), mystery:mystery['301404'], value: 0
201402: text: t('armorMystery201402Text'), notes: t('armorMystery201402Notes'), mystery:'201402', value: 0
201403: text: t('armorMystery201403Text'), notes: t('armorMystery201403Notes'), mystery:'201403', value: 0
201405: text: t('armorMystery201405Text'), notes: t('armorMystery201405Notes'), mystery:'201405', value: 0
201406: text: t('armorMystery201406Text'), notes: t('armorMystery201406Notes'), mystery:'201406', value: 0
201407: text: t('armorMystery201407Text'), notes: t('armorMystery201407Notes'), mystery:'201407', value: 0
201408: text: t('armorMystery201408Text'), notes: t('armorMystery201408Notes'), mystery:'201408', value: 0
201409: text: t('armorMystery201409Text'), notes: t('armorMystery201409Notes'), mystery:'201409', value: 0
201410: text: t('armorMystery201410Text'), notes: t('armorMystery201410Notes'), mystery:'201410', value: 0
301404: text: t('armorMystery301404Text'), notes: t('armorMystery301404Notes'), mystery:'301404', value: 0
head:
base:
@ -245,14 +246,14 @@ gear =
# Other
gaymerx: event: events.gaymerx, text: t('headSpecialGaymerxText'), notes: t('headSpecialGaymerxNotes'), value: 0
mystery:
201402: text: t('headMystery201402Text'), notes: t('headMystery201402Notes'), mystery:mystery['201402'], value: 0
201405: text: t('headMystery201405Text'), notes: t('headMystery201405Notes'), mystery:mystery['201405'], value: 0
201406: text: t('headMystery201406Text'), notes: t('headMystery201406Notes'), mystery:mystery['201406'], value: 0
201407: text: t('headMystery201407Text'), notes: t('headMystery201407Notes'), mystery:mystery['201407'], value: 0
201408: text: t('headMystery201408Text'), notes: t('headMystery201408Notes'), mystery:mystery['201408'], value: 0
201411: text: t('headMystery201411Text'), notes: t('headMystery201411Notes'), mystery:mystery['201411'], value: 0
301404: text: t('headMystery301404Text'), notes: t('headMystery301404Notes'), mystery:mystery['301404'], value: 0
301405: text: t('headMystery301405Text'), notes: t('headMystery301405Notes'), mystery:mystery['301405'], value: 0
201402: text: t('headMystery201402Text'), notes: t('headMystery201402Notes'), mystery:'201402', value: 0
201405: text: t('headMystery201405Text'), notes: t('headMystery201405Notes'), mystery:'201405', value: 0
201406: text: t('headMystery201406Text'), notes: t('headMystery201406Notes'), mystery:'201406', value: 0
201407: text: t('headMystery201407Text'), notes: t('headMystery201407Notes'), mystery:'201407', value: 0
201408: text: t('headMystery201408Text'), notes: t('headMystery201408Notes'), mystery:'201408', value: 0
201411: text: t('headMystery201411Text'), notes: t('headMystery201411Notes'), mystery:'201411', value: 0
301404: text: t('headMystery301404Text'), notes: t('headMystery301404Notes'), mystery:'301404', value: 0
301405: text: t('headMystery301405Text'), notes: t('headMystery301405Notes'), mystery:'301405', value: 0
shield:
base:
@ -303,26 +304,26 @@ gear =
fallWarrior: event: events.fall, specialClass: 'warrior', text: t('shieldSpecialFallWarriorText'), notes: t('shieldSpecialFallWarriorNotes', {con: 7}), value: 70, con: 7
fallHealer: event: events.fall, specialClass: 'healer', text: t('shieldSpecialFallHealerText'), notes: t('shieldSpecialFallHealerNotes', {con: 9}), value: 70, con: 9
mystery:
301405: text: t('shieldMystery301405Text'), notes: t('shieldMystery301405Notes'), mystery:mystery['301405'], value: 0
301405: text: t('shieldMystery301405Text'), notes: t('shieldMystery301405Notes'), mystery:'301405', value: 0
back:
base:
0: text: t('backBase0Text'), notes: t('backBase0Notes'), value:0
mystery:
201402: text: t('backMystery201402Text'), notes: t('backMystery201402Notes'), mystery:mystery['201402'], value: 0
201404: text: t('backMystery201404Text'), notes: t('backMystery201404Notes'), mystery:mystery['201404'], value: 0
201410: text: t('backMystery201410Text'), notes: t('backMystery201410Notes'), mystery:mystery['201410'], value: 0
201402: text: t('backMystery201402Text'), notes: t('backMystery201402Notes'), mystery:'201402', value: 0
201404: text: t('backMystery201404Text'), notes: t('backMystery201404Notes'), mystery:'201404', value: 0
201410: text: t('backMystery201410Text'), notes: t('backMystery201410Notes'), mystery:'201410', value: 0
special:
wondercon_red: text: t('backSpecialWonderconRedText'), notes: t('backSpecialWonderconRedNotes'), value: 0, mystery:mystery.wondercon
wondercon_black: text: t('backSpecialWonderconBlackText'), notes: t('backSpecialWonderconBlackNotes'), value: 0, mystery:mystery.wondercon
wondercon_red: text: t('backSpecialWonderconRedText'), notes: t('backSpecialWonderconRedNotes'), value: 0, mystery:'wondercon'
wondercon_black: text: t('backSpecialWonderconBlackText'), notes: t('backSpecialWonderconBlackNotes'), value: 0, mystery:'wondercon'
body:
base:
0: text: t('bodyBase0Text'), notes:t('bodyBase0Notes'), value:0
special:
wondercon_red: text: t('bodySpecialWonderconRedText'), notes: t('bodySpecialWonderconRedNotes'), value: 0, mystery:mystery.wondercon
wondercon_gold: text: t('bodySpecialWonderconGoldText'), notes: t('bodySpecialWonderconGoldNotes'), value: 0, mystery:mystery.wondercon
wondercon_black: text: t('bodySpecialWonderconBlackText'), notes: t('bodySpecialWonderconBlackNotes'), value: 0, mystery:mystery.wondercon
wondercon_red: text: t('bodySpecialWonderconRedText'), notes: t('bodySpecialWonderconRedNotes'), value: 0, mystery:'wondercon'
wondercon_gold: text: t('bodySpecialWonderconGoldText'), notes: t('bodySpecialWonderconGoldNotes'), value: 0, mystery:'wondercon'
wondercon_black: text: t('bodySpecialWonderconBlackText'), notes: t('bodySpecialWonderconBlackNotes'), value: 0, mystery:'wondercon'
# Summer
summerHealer: event: events.summer, specialClass: 'healer', text: t('bodySpecialSummerHealerText'), notes: t('bodySpecialSummerHealerNotes'), value: 20
summerMage: event: events.summer, specialClass: 'wizard', text: t('bodySpecialSummerMageText'), notes: t('bodySpecialSummerMageNotes'), value: 20
@ -338,23 +339,23 @@ gear =
springHealer: event: events.spring, specialClass: 'healer', text: t('headAccessorySpecialSpringHealerText'), notes: t('headAccessorySpecialSpringHealerNotes'), value: 20
mystery:
201403: text: t('headAccessoryMystery201403Text'), notes: t('headAccessoryMystery201403Notes'), mystery:mystery['201403'], value: 0
201404: text: t('headAccessoryMystery201404Text'), notes: t('headAccessoryMystery201404Notes'), mystery:mystery['201404'], value: 0
201409: text: t('headAccessoryMystery201409Text'), notes: t('headAccessoryMystery201409Notes'), mystery:mystery['201409'], value: 0
301405: text: t('headAccessoryMystery301405Text'), notes: t('headAccessoryMystery301405Notes'), mystery:mystery['301405'], value: 0
201403: text: t('headAccessoryMystery201403Text'), notes: t('headAccessoryMystery201403Notes'), mystery:'201403', value: 0
201404: text: t('headAccessoryMystery201404Text'), notes: t('headAccessoryMystery201404Notes'), mystery:'201404', value: 0
201409: text: t('headAccessoryMystery201409Text'), notes: t('headAccessoryMystery201409Notes'), mystery:'201409', value: 0
301405: text: t('headAccessoryMystery301405Text'), notes: t('headAccessoryMystery301405Notes'), mystery:'301405', value: 0
eyewear:
base:
0: text: t('eyewearBase0Text'), notes: t('eyewearBase0Notes'), value: 0, last: true
special:
wondercon_red: text: t('eyewearSpecialWonderconRedText'), notes: t('eyewearSpecialWonderconRedNotes'), value: 0, mystery:mystery.wondercon
wondercon_black: text: t('eyewearSpecialWonderconBlackText'), notes: t('eyewearSpecialWonderconBlackNotes'), value: 0, mystery:mystery.wondercon
wondercon_red: text: t('eyewearSpecialWonderconRedText'), notes: t('eyewearSpecialWonderconRedNotes'), value: 0, mystery:'wondercon'
wondercon_black: text: t('eyewearSpecialWonderconBlackText'), notes: t('eyewearSpecialWonderconBlackNotes'), value: 0, mystery:'wondercon'
#Summer
summerRogue: event: events.summer, specialClass: 'rogue', text: t('eyewearSpecialSummerRogueText'), notes: t('eyewearSpecialSummerRogueNotes'), value: 20
summerWarrior: event: events.summer, specialClass: 'warrior', text: t('eyewearSpecialSummerWarriorText'), notes: t('eyewearSpecialSummerWarriorNotes'), value: 20
mystery:
301404: text: t('eyewearMystery301404Text'), notes: t('eyewearMystery301404Notes'), mystery:mystery['301404'], value: 0
301405: text: t('eyewearMystery301405Text'), notes: t('eyewearMystery301405Notes'), mystery:mystery['301405'], value: 0
301404: text: t('eyewearMystery301404Text'), notes: t('eyewearMystery301404Notes'), mystery:'301404', value: 0
301405: text: t('eyewearMystery301405Text'), notes: t('eyewearMystery301405Notes'), mystery:'301405', value: 0
###
The gear is exported as a tree (defined above), and a flat list (eg, {weapon_healer_1: .., shield_special_0: ...}) since
@ -385,6 +386,17 @@ _.each gearTypes, (type) ->
api.gear.flat[key] = item
###
Time Traveler Store, mystery sets need their items mapped in
###
_.each api.mystery, (v,k)-> v.items = _.where api.gear.flat, {mystery:k}
api.timeTravelerStore = (owned) ->
ownedKeys = _.keys owned.toObject?() or owned # mongoose workaround
_.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
, {}
###
---------------------------------------------------------------
Potion

View file

@ -745,14 +745,11 @@ api.wrap = (user, main=true) ->
# buy is for gear, purchase is for gem-purchaseables (i know, I know...)
buy: (req, cb) ->
{key} = req.params
{trinket} = req.query
item = if key is 'potion' then content.potion else content.gear.flat[key]
if trinket
return cb?({code:401, message: "Not enough Time Trinkets"}) unless item.klass=='mystery' and user.purchased.plan.consecutive.trinkets>0
else
return cb?({code:404, message:"Item '#{key} not found (see https://github.com/HabitRPG/habitrpg-shared/blob/develop/script/content.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 own this item"}) if item.canOwn? and !item.canOwn(user)
return cb?({code:404, message:"Item '#{key} not found (see https://github.com/HabitRPG/habitrpg-shared/blob/develop/script/content.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 own this item"}) if item.canOwn? and !item.canOwn(user)
if item.key is 'potion'
user.stats.hp += 15
user.stats.hp = 50 if user.stats.hp > 50
@ -763,9 +760,21 @@ api.wrap = (user, main=true) ->
message ?= i18n.t('messageBought', {itemText: item.text(req.language)}, req.language)
if not user.achievements.ultimateGear and item.last
user.fns.ultimateGear()
if trinket then user.purchased.plan.consecutive.trinkets-- else user.stats.gp -= item.value
user.stats.gp -= item.value
cb? {code:200, message}, _.pick(user,$w 'items achievements stats')
buyMysterySet: (req, cb)->
return cb?({code:401, message:"You don't have enough Mystic Hourglasses"}) unless user.purchased.plan.consecutive.trinkets>0
mysterySet = content.timeTravelerStore(user.items.gear.owned)?[req.params.key]
# console.log {mysterySet, key:req.params.key, store:content.timeTravelerStore(user.items.gear.owned), mysteryItems:content.mystery}
if window?.confirm?
return unless window.confirm("Buy this full set of items for 1 Mystic Hourglass?")
return cb?({code:404, message:"Mystery set not found, or set already owned"}) unless mysterySet
_.each mysterySet.items, (i)->user.items.gear.owned[i.key]=true
console.log(user.items.gear.owned)
user.purchased.plan.consecutive.trinkets--
cb? null, _.pick(user,$w 'items purchased.plan.consecutive')
sell: (req, cb) ->
{key, type} = req.params
return cb?({code:404,message:":type not found. Must bes in [eggs, hatchingPotions, food]"}) unless type in ['eggs','hatchingPotions', 'food']