Merge branch 'api-v3' into api-v3-groups

This commit is contained in:
Matteo Pagliazzi
2015-12-29 18:17:36 +01:00
552 changed files with 12321 additions and 8213 deletions
+3
View File
@@ -0,0 +1,3 @@
export const MAX_HEALTH = 50;
export const MAX_LEVEL = 100;
export const MAX_STAT_POINTS = MAX_LEVEL;
+1
View File
@@ -22,6 +22,7 @@ export const EVENTS = {
summer2015: { start: '2015-06-20', end: '2015-08-02' },
fall2015: { start: '2015-09-21', end: '2015-11-01' },
gaymerx: { start: '2015-12-01', end: '2015-12-14' },
winter2016: { start: '2015-12-18', end: '2016-02-02' },
};
export const GEAR_TYPES = [
@@ -97,6 +97,12 @@ let armor = {
mystery: '201511',
value: 0,
},
201512: {
text: t('armorMystery201512Text'),
notes: t('armorMystery201512Notes'),
mystery: '201512',
value: 0,
},
301404: {
text: t('armorMystery301404Text'),
notes: t('armorMystery301404Notes'),
@@ -250,6 +256,12 @@ let head = {
mystery: '201511',
value: 0,
},
201512: {
text: t('headMystery201512Text'),
notes: t('headMystery201512Notes'),
mystery: '201512',
value: 0,
},
301404: {
text: t('headMystery301404Text'),
notes: t('headMystery301404Notes'),
@@ -25,6 +25,9 @@ let armor = {
notes: t('armorSpecialYetiNotes', { con: 9 }),
con: 9,
value: 90,
canBuy: () => {
return true;
},
},
ski: {
event: EVENTS.winter,
@@ -33,6 +36,9 @@ let armor = {
notes: t('armorSpecialSkiNotes', { per: 15 }),
per: 15,
value: 90,
canBuy: () => {
return true;
},
},
candycane: {
event: EVENTS.winter,
@@ -41,6 +47,9 @@ let armor = {
notes: t('armorSpecialCandycaneNotes', { int: 9 }),
int: 9,
value: 90,
canBuy: () => {
return true;
},
},
snowflake: {
event: EVENTS.winter,
@@ -49,11 +58,15 @@ let armor = {
notes: t('armorSpecialSnowflakeNotes', { con: 15 }),
con: 15,
value: 90,
canBuy: () => {
return true;
},
},
birthday: {
event: EVENTS.birthday,
text: t('armorSpecialBirthdayText'),
notes: t('armorSpecialBirthdayNotes'), value: 0 },
notes: t('armorSpecialBirthdayNotes'), value: 0,
},
springRogue: {
event: EVENTS.spring,
specialClass: 'rogue',
@@ -169,6 +182,9 @@ let armor = {
notes: t('armorSpecialWinter2015RogueNotes', { per: 15 }),
value: 90,
per: 15,
canBuy: () => {
return true;
},
},
winter2015Warrior: {
event: EVENTS.winter2015,
@@ -177,6 +193,9 @@ let armor = {
notes: t('armorSpecialWinter2015WarriorNotes', { con: 9 }),
value: 90,
con: 9,
canBuy: () => {
return true;
},
},
winter2015Mage: {
event: EVENTS.winter2015,
@@ -185,6 +204,9 @@ let armor = {
notes: t('armorSpecialWinter2015MageNotes', { int: 9 }),
value: 90,
int: 9,
canBuy: () => {
return true;
},
},
winter2015Healer: {
event: EVENTS.winter2015,
@@ -193,6 +215,9 @@ let armor = {
notes: t('armorSpecialWinter2015HealerNotes', { con: 15 }),
value: 90,
con: 15,
canBuy: () => {
return true;
},
},
birthday2015: {
text: t('armorSpecialBirthday2015Text'),
@@ -302,6 +327,38 @@ let armor = {
notes: t('armorSpecialGaymerxNotes'),
value: 0,
},
winter2016Rogue: {
event: EVENTS.winter2016,
specialClass: 'rogue',
text: t('armorSpecialWinter2016RogueText'),
notes: t('armorSpecialWinter2016RogueNotes', { per: 15 }),
value: 90,
per: 15,
},
winter2016Warrior: {
event: EVENTS.winter2016,
specialClass: 'warrior',
text: t('armorSpecialWinter2016WarriorText'),
notes: t('armorSpecialWinter2016WarriorNotes', { con: 9 }),
value: 90,
con: 9,
},
winter2016Mage: {
event: EVENTS.winter2016,
specialClass: 'wizard',
text: t('armorSpecialWinter2016MageText'),
notes: t('armorSpecialWinter2016MageNotes', { int: 9 }),
value: 90,
int: 9,
},
winter2016Healer: {
event: EVENTS.winter2016,
specialClass: 'healer',
text: t('armorSpecialWinter2016HealerText'),
notes: t('armorSpecialWinter2016HealerNotes', { con: 15 }),
value: 90,
con: 15,
},
};
let back = {
@@ -400,6 +457,9 @@ let head = {
notes: t('headSpecialYetiNotes', { str: 9 }),
str: 9,
value: 60,
canBuy: () => {
return true;
},
},
ski: {
event: EVENTS.winter,
@@ -408,6 +468,9 @@ let head = {
notes: t('headSpecialSkiNotes', { per: 9 }),
per: 9,
value: 60,
canBuy: () => {
return true;
},
},
candycane: {
event: EVENTS.winter,
@@ -416,6 +479,9 @@ let head = {
notes: t('headSpecialCandycaneNotes', { per: 7 }),
per: 7,
value: 60,
canBuy: () => {
return true;
},
},
snowflake: {
event: EVENTS.winter,
@@ -424,6 +490,9 @@ let head = {
notes: t('headSpecialSnowflakeNotes', { int: 7 }),
int: 7,
value: 60,
canBuy: () => {
return true;
},
},
springRogue: {
event: EVENTS.spring,
@@ -540,6 +609,9 @@ let head = {
notes: t('headSpecialWinter2015RogueNotes', { per: 9 }),
value: 60,
per: 9,
canBuy: () => {
return true;
},
},
winter2015Warrior: {
event: EVENTS.winter2015,
@@ -548,6 +620,9 @@ let head = {
notes: t('headSpecialWinter2015WarriorNotes', { str: 9 }),
value: 60,
str: 9,
canBuy: () => {
return true;
},
},
winter2015Mage: {
event: EVENTS.winter2015,
@@ -556,6 +631,9 @@ let head = {
notes: t('headSpecialWinter2015MageNotes', { per: 7 }),
value: 60,
per: 7,
canBuy: () => {
return true;
},
},
winter2015Healer: {
event: EVENTS.winter2015,
@@ -564,6 +642,9 @@ let head = {
notes: t('headSpecialWinter2015HealerNotes', { int: 7 }),
value: 60,
int: 7,
canBuy: () => {
return true;
},
},
nye2014: {
text: t('headSpecialNye2014Text'),
@@ -673,6 +754,38 @@ let head = {
notes: t('headSpecialGaymerxNotes'),
value: 0,
},
winter2016Rogue: {
event: EVENTS.winter2016,
specialClass: 'rogue',
text: t('headSpecialWinter2016RogueText'),
notes: t('headSpecialWinter2016RogueNotes', { per: 9 }),
value: 60,
per: 9,
},
winter2016Warrior: {
event: EVENTS.winter2016,
specialClass: 'warrior',
text: t('headSpecialWinter2016WarriorText'),
notes: t('headSpecialWinter2016WarriorNotes', { str: 9 }),
value: 60,
str: 9,
},
winter2016Mage: {
event: EVENTS.winter2016,
specialClass: 'wizard',
text: t('headSpecialWinter2016MageText'),
notes: t('headSpecialWinter2016MageNotes', { per: 7 }),
value: 60,
per: 7,
},
winter2016Healer: {
event: EVENTS.winter2016,
specialClass: 'healer',
text: t('headSpecialWinter2016HealerText'),
notes: t('headSpecialWinter2016HealerNotes', { int: 7 }),
value: 60,
int: 7,
},
};
let headAccessory = {
@@ -839,6 +952,9 @@ let shield = {
notes: t('shieldSpecialYetiNotes', { con: 7 }),
con: 7,
value: 70,
canBuy: () => {
return true;
},
},
ski: {
event: EVENTS.winter,
@@ -847,6 +963,9 @@ let shield = {
notes: t('weaponSpecialSkiNotes', { str: 8 }),
str: 8,
value: 90,
canBuy: () => {
return true;
},
},
snowflake: {
event: EVENTS.winter,
@@ -855,6 +974,9 @@ let shield = {
notes: t('shieldSpecialSnowflakeNotes', { con: 9 }),
con: 9,
value: 70,
canBuy: () => {
return true;
},
},
springRogue: {
event: EVENTS.spring,
@@ -944,6 +1066,9 @@ let shield = {
notes: t('shieldSpecialWinter2015RogueNotes', { str: 8 }),
value: 80,
str: 8,
canBuy: () => {
return true;
},
},
winter2015Warrior: {
event: EVENTS.winter2015,
@@ -952,6 +1077,9 @@ let shield = {
notes: t('shieldSpecialWinter2015WarriorNotes', { con: 7 }),
value: 70,
con: 7,
canBuy: () => {
return true;
},
},
winter2015Healer: {
event: EVENTS.winter2015,
@@ -960,6 +1088,9 @@ let shield = {
notes: t('shieldSpecialWinter2015HealerNotes', { con: 9 }),
value: 70,
con: 9,
canBuy: () => {
return true;
},
},
spring2015Rogue: {
event: EVENTS.spring2015,
@@ -1033,6 +1164,30 @@ let shield = {
value: 70,
con: 9,
},
winter2016Rogue: {
event: EVENTS.winter2016,
specialClass: 'rogue',
text: t('shieldSpecialWinter2016RogueText'),
notes: t('shieldSpecialWinter2016RogueNotes', { str: 8 }),
value: 80,
str: 8,
},
winter2016Warrior: {
event: EVENTS.winter2016,
specialClass: 'warrior',
text: t('shieldSpecialWinter2016WarriorText'),
notes: t('shieldSpecialWinter2016WarriorNotes', { con: 7 }),
value: 70,
con: 7,
},
winter2016Healer: {
event: EVENTS.winter2016,
specialClass: 'healer',
text: t('shieldSpecialWinter2016HealerText'),
notes: t('shieldSpecialWinter2016HealerNotes', { con: 9 }),
value: 70,
con: 9,
},
};
let weapon = {
@@ -1055,6 +1210,9 @@ let weapon = {
notes: t('weaponSpecialYetiNotes', { str: 15 }),
str: 15,
value: 90,
canBuy: () => {
return true;
},
},
ski: {
event: EVENTS.winter,
@@ -1063,6 +1221,9 @@ let weapon = {
notes: t('weaponSpecialSkiNotes', { str: 8 }),
str: 8,
value: 90,
canBuy: () => {
return true;
},
},
candycane: {
event: EVENTS.winter,
@@ -1073,6 +1234,9 @@ let weapon = {
int: 15,
per: 7,
value: 160,
canBuy: () => {
return true;
},
},
snowflake: {
event: EVENTS.winter,
@@ -1081,6 +1245,9 @@ let weapon = {
notes: t('weaponSpecialSnowflakeNotes', { int: 9 }),
int: 9,
value: 90,
canBuy: () => {
return true;
},
},
springRogue: {
event: EVENTS.spring,
@@ -1203,6 +1370,9 @@ let weapon = {
notes: t('weaponSpecialWinter2015RogueNotes', { str: 8 }),
value: 80,
str: 8,
canBuy: () => {
return true;
},
},
winter2015Warrior: {
event: EVENTS.winter2015,
@@ -1211,6 +1381,9 @@ let weapon = {
notes: t('weaponSpecialWinter2015WarriorNotes', { str: 15 }),
value: 90,
str: 15,
canBuy: () => {
return true;
},
},
winter2015Mage: {
event: EVENTS.winter2015,
@@ -1221,6 +1394,9 @@ let weapon = {
value: 160,
int: 15,
per: 7,
canBuy: () => {
return true;
},
},
winter2015Healer: {
event: EVENTS.winter2015,
@@ -1229,6 +1405,9 @@ let weapon = {
notes: t('weaponSpecialWinter2015HealerNotes', { int: 9 }),
value: 90,
int: 9,
canBuy: () => {
return true;
},
},
spring2015Rogue: {
event: EVENTS.spring2015,
@@ -1332,6 +1511,40 @@ let weapon = {
value: 90,
int: 9,
},
winter2016Rogue: {
event: EVENTS.winter2016,
specialClass: 'rogue',
text: t('weaponSpecialWinter2016RogueText'),
notes: t('weaponSpecialWinter2016RogueNotes', { str: 8 }),
value: 80,
str: 8,
},
winter2016Warrior: {
event: EVENTS.winter2016,
specialClass: 'warrior',
text: t('weaponSpecialWinter2016WarriorText'),
notes: t('weaponSpecialWinter2016WarriorNotes', { str: 15 }),
value: 90,
str: 15,
},
winter2016Mage: {
event: EVENTS.winter2016,
specialClass: 'wizard',
twoHanded: true,
text: t('weaponSpecialWinter2016MageText'),
notes: t('weaponSpecialWinter2016MageNotes', { int: 15, per: 7 }),
value: 160,
int: 15,
per: 7,
},
winter2016Healer: {
event: EVENTS.winter2016,
specialClass: 'healer',
text: t('weaponSpecialWinter2016HealerText'),
notes: t('weaponSpecialWinter2016HealerNotes', { int: 9 }),
value: 90,
int: 9,
},
};
let specialSet = {
+44 -4
View File
@@ -922,7 +922,15 @@ api.questEggs = {
canBuy: (function(u) {
return u.achievements.quests && (u.achievements.quests.snake != null) > 0;
})
}
},
Unicorn: {
text: t('questEggUnicornText'),
mountText: t('questEggUnicornMountText'),
adjective: t('questEggUnicornAdjective'),
canBuy: (function(u) {
return u.achievements.quests && (u.achievements.quests.unicorn != null) > 0;
})
},
};
_.each(api.questEggs, function(egg, key) {
@@ -1582,7 +1590,7 @@ api.quests = {
},
evilsanta: {
canBuy: (function() {
return false;
return true;
}),
text: t('questEvilSantaText'),
notes: t('questEvilSantaNotes'),
@@ -1608,7 +1616,7 @@ api.quests = {
},
evilsanta2: {
canBuy: (function() {
return false;
return true;
}),
text: t('questEvilSanta2Text'),
notes: t('questEvilSanta2Notes'),
@@ -2940,7 +2948,39 @@ api.quests = {
exp: 725,
unlock: t('questSnakeUnlockText')
}
}
},
unicorn: {
text: t('questUnicornText'),
notes: t('questUnicornNotes'),
completion: t('questUnicornCompletion'),
value: 4,
category: 'pet',
boss: {
name: t('questUnicornBoss'),
hp: 600,
str: 1.5
},
drop: {
items: [
{
type: 'eggs',
key: 'Unicorn',
text: t('questUnicornDropUnicornEgg')
}, {
type: 'eggs',
key: 'Unicorn',
text: t('questUnicornDropUnicornEgg')
}, {
type: 'eggs',
key: 'Unicorn',
text: t('questUnicornDropUnicornEgg')
}
],
gp: 43,
exp: 350,
unlock: t('questUnicornUnlockText')
}
},
};
_.each(api.quests, function(v, key) {
+7 -24
View File
@@ -1,126 +1,108 @@
import { each } from 'lodash';
let t = require('./translation.js');
let mysterySets = {
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 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',
},
201412: {
start: '2014-12-25',
end: '2015-01-02',
text: 'Penguin Set',
},
201501: {
start: '2015-01-26',
end: '2015-02-02',
text: 'Starry Knight Set',
},
201502: {
start: '2015-02-24',
end: '2015-03-02',
text: 'Winged Enchanter Set',
},
201503: {
start: '2015-03-25',
end: '2015-04-02',
text: 'Aquamarine Set',
},
201504: {
start: '2015-04-24',
end: '2015-05-02',
text: 'Busy Bee Set',
},
201505: {
start: '2015-05-25',
end: '2015-06-02',
text: 'Green Knight Set',
},
201506: {
start: '2015-06-25',
end: '2015-07-02',
text: 'Neon Snorkeler Set',
},
201507: {
start: '2015-07-24',
end: '2015-08-02',
text: 'Rad Surfer Set',
},
201508: {
start: '2015-08-23',
end: '2015-09-02',
text: 'Cheetah Costume Set',
},
201509: {
start: '2015-09-24',
end: '2015-10-02',
text: 'Werewolf Set',
},
201510: {
start: '2015-10-26',
end: '2015-11-02',
text: 'Horned Goblin Set',
},
201511: {
start: '2015-11-25',
end: '2015-12-02',
text: 'Wood Warrior Set',
},
201512: {
start: '2015-12-23',
end: '2016-01-02',
},
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',
},
// @TODO: Remove wondercon from mystery-sets
wondercon: {
start: '2014-03-24',
end: '2014-04-01',
@@ -129,6 +111,7 @@ let mysterySets = {
each(mysterySets, (value, key) => {
value.key = key;
value.text = t(`mysterySet${key}`);
});
export default mysterySets;
+19 -11
View File
@@ -2,6 +2,11 @@ import {
daysSince,
shouldDo,
} from '../../common/script/cron';
import {
MAX_HEALTH,
MAX_LEVEL,
MAX_STAT_POINTS,
} from './constants';
import * as statHelpers from './statHelpers';
var $w, _, api, content, i18n, moment, preenHistory, sortOrder,
@@ -20,9 +25,9 @@ api = module.exports = {};
api.i18n = i18n;
api.shouldDo = shouldDo;
api.maxLevel = statHelpers.MAX_LEVEL;
api.maxLevel = MAX_LEVEL;
api.capByLevel = statHelpers.capByLevel;
api.maxHealth = statHelpers.MAX_HEALTH;
api.maxHealth = MAX_HEALTH;
api.tnl = statHelpers.toNextLevel;
api.diminishingReturns = statHelpers.diminishingReturns;
@@ -121,7 +126,7 @@ preenHistory = function(history) {
*/
api.preenTodos = function(tasks) {
return _.where(tasks, function(t) {
return _.filter(tasks, function(t) {
return !t.completed || (t.challenge && t.challenge.id) || moment(t.dateCompleted).isAfter(moment().subtract({
days: 3
}));
@@ -2267,27 +2272,30 @@ api.wrap = function(user, main) {
})()]++;
},
updateStats: function(stats, req, analytics) {
var tnl;
if (stats.hp <= 0) {
return user.stats.hp = 0;
}
user.stats.hp = stats.hp;
user.stats.gp = stats.gp >= 0 ? stats.gp : 0;
tnl = api.tnl(user.stats.lvl);
if (stats.exp >= tnl) {
var experienceToNextLevel = api.tnl(user.stats.lvl);
if (stats.exp >= experienceToNextLevel) {
user.stats.exp = stats.exp;
while (stats.exp >= tnl) {
stats.exp -= tnl;
while (stats.exp >= experienceToNextLevel) {
stats.exp -= experienceToNextLevel;
user.stats.lvl++;
tnl = api.tnl(user.stats.lvl);
experienceToNextLevel = api.tnl(user.stats.lvl);
user.stats.hp = 50;
if (user.stats.lvl > api.maxLevel) {
var userTotalStatPoints = user.stats.str + user.stats.int + user.stats.con + user.stats.per;
if (userTotalStatPoints >= MAX_STAT_POINTS) {
continue;
}
if (user.preferences.automaticAllocation) {
user.fns.autoAllocate();
} else {
user.stats.points = user.stats.lvl - (user.stats.con + user.stats.str + user.stats.per + user.stats.int);
user.stats.points = user.stats.lvl - userTotalStatPoints;
if (user.stats.points < 0) {
user.stats.points = 0;
}
+1 -1
View File
@@ -1,4 +1,4 @@
import {each, defaults, assign, capitalize, camelCase} from 'lodash';
import { each, defaults, assign, capitalize, camelCase } from 'lodash';
import i18n from '../i18n';
+4 -10
View File
@@ -1,11 +1,13 @@
import {
MAX_LEVEL,
} from './constants';
/*
------------------------------------------------------
Level cap
------------------------------------------------------
*/
export const MAX_LEVEL = 100;
export function capByLevel (lvl) {
if (lvl > MAX_LEVEL) {
return MAX_LEVEL;
@@ -14,14 +16,6 @@ export function capByLevel (lvl) {
}
}
/*
------------------------------------------------------
Health cap
------------------------------------------------------
*/
export const MAX_HEALTH = 50;
/*
------------------------------------------------------
Scoring