diff --git a/lib/SyndicateJob.js b/lib/SyndicateJob.js index 1530cc934..508ceed8d 100644 --- a/lib/SyndicateJob.js +++ b/lib/SyndicateJob.js @@ -5,7 +5,7 @@ const fetch = require('node-fetch'); const WorldstateObject = require('./WorldstateObject'); const apiBase = process.env.API_BASE_URL || 'https://api.warframestat.us'; -const bountyRewardRegex = /Tier([ABCDE])Table([ABC])Rewards/i; +const bountyRewardRegex = /(?:Tier([ABCDE])|Narmer)Table([ABC])Rewards/i; const ghoulRewardRegex = /GhoulBountyTable([AB])Rewards/i; /** @@ -75,17 +75,20 @@ const getBountyRewards = async (i18n, isVault, raw) => { return []; }; +const FIFTY_MINUTES = 3000000; + /** * Represents a syndicate daily mission * @extends {WorldstateObject} */ class SyndicateJob extends WorldstateObject { /** - * @param {Object} data The syndicate mission data - * @param {Date} expiry The syndicate job expiration - * @param {Object} deps The dependencies object - * @param {Translator} deps.translator The string translator - * @param {string} deps.locale Locale to use for translations + * @param {Object} data The syndicate mission data + * @param {Date} expiry The syndicate job expiration + * @param {Object} deps The dependencies object + * @param {Object} timeDate Time/Date functions + * @param {Translator} translator The string translator + * @param {string} locale Locale to use for translations */ constructor(data, expiry, { translator, timeDate, locale }) { super({ _id: { $oid: data.JobCurrentVersion ? data.JobCurrentVersion.$oid : `${(data.jobType || '').split('/').slice(-1)[0]}${expiry.getTime()}` } }, { timeDate }); @@ -141,6 +144,27 @@ class SyndicateJob extends WorldstateObject { * @type {string|null} */ this.locationTag = data.locationTag; + + /** + * End time for the syndicate mission. + * Should be inherited from the Syndicate, but some are timebound. + * @type {Date} + */ + this.expiry = expiry; + + /** + * What time phase this bounty is bound to + * @type {string} + */ + this.timeBound = undefined; + if (data.jobType && data.jobType.toLowerCase().includes('narmer')) { + if (data.jobType.toLowerCase().includes('eidolon')) { + this.timeBound = 'day'; + this.expiry = new Date(this.expiry.getTime() - FIFTY_MINUTES); + } else { + this.timeBoound = 'night'; + } + } } } diff --git a/test/integration/integration.spec.js b/test/integration/integration.spec.js index bc9bd6320..4007ed295 100644 --- a/test/integration/integration.spec.js +++ b/test/integration/integration.spec.js @@ -22,26 +22,30 @@ const WorldState = rewire('../../lib/WorldState.js'); describe('WorldState (integration)', () => { describe('#constructor()', async () => { ['pc', 'ps4', 'xb1', 'swi'].forEach((platform) => { - it('should parse live worldstate data', async function () { + it('should parse live worldstate data', function (done) { this.timeout = 10000; // allow 10 seconds to parse the worldstate const url = `https://content.${platform === 'pc' ? '' : `${platform}.`}warframe.com/dynamic/worldState.php`; - const ws = await fetch(url).then((d) => d.text()); - - let wsl; - (() => { - wsl = new WorldState(ws, { logger, locale: 'zh' }); - }).should.not.throw(); - - wsl.news.forEach((article) => { - if (article.message.toLowerCase().includes('stream')) { - article.should.include({ stream: true }); - } - }); - - /* Easy debugging! */ - setTimeout(() => { - fs.writeFileSync(`./data.${platform}.json`, JSON.stringify(wsl)); - }, 1000); + fetch(url) + .then((d) => d.text()) + .then((ws) => { + let wsl; + (() => { + wsl = new WorldState(ws, { logger, locale: 'en' }); + }).should.not.throw(); + + wsl.news.forEach((article) => { + if (article.message.toLowerCase().includes('stream')) { + article.should.include({ stream: true }); + } + }); + + /* Easy debugging! */ + setTimeout(() => { + fs.writeFileSync(`./data.${platform}.json`, JSON.stringify(wsl.syndicateMissions + .find((m) => m.syndicateKey === 'Ostrons'))); + done(); + }, 1000); + }); }); }); });