Skip to content

Commit

Permalink
Merge b9ad58f into 82bec02
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTenno committed Jul 16, 2021
2 parents 82bec02 + b9ad58f commit c77dee3
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 401 deletions.
17 changes: 0 additions & 17 deletions .github/update_docs.sh

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Supplemental Dependencies
run: npm i
- run: npm i
- run: npm install jsdoc ink-docstrap tsd-jsdoc
- name: Build
uses: andstor/jsdoc-action@v1
with:
Expand Down
55 changes: 36 additions & 19 deletions lib/SteelPathOffering.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,25 @@ function getFirstDayOfWeek() {
function getLastDayOfWeek() {
const last = new Date(getFirstDayOfWeek());
last.setUTCDate(last.getUTCDate() + 4);
last.setUTCHours(59);
last.setUTCHours(23);
last.setUTCMinutes(59);
last.setUTCSeconds(59);
last.setUTCMilliseconds(0);
return last;
}

function getStartOfDay() {
const today = new Date();
today.setUTCHours(0);
today.setUTCMinutes(0);
today.setUTCSeconds(0);
today.setUTCMilliseconds(0);
return today;
}

function getEndOfDay() {
const last = new Date();
last.setUTCHours(23);
last.setUTCMinutes(59);
last.setUTCSeconds(59);
last.setUTCMilliseconds(0);
Expand All @@ -29,37 +47,36 @@ function getLastDayOfWeek() {
*/
const start = new Date('2020-11-16T00:00:00.000Z');

/**
* Array of rewards
* @type {string[]}
*/
const rewards = [
{ name: 'Umbra Forma Blueprint', cost: 150 },
{ name: '50,000 Kuva', cost: 55 },
{ name: 'Kitgun Riven Mod', cost: 75 },
{ name: '3x Forma', cost: 75 },
{ name: 'Zaw Riven Mod', cost: 75 },
{ name: '30,000 Endo', cost: 150 },
{ name: 'Rifle Riven Mod', cost: 75 },
{ name: 'Shotgun Riven Mod', cost: 75 },
];

module.exports = class SteelPathOffering {
constructor({ timeDate }) {
constructor({ timeDate, translator, locale }) {
const sSinceStart = (Date.now() - start.getTime()) / 1000;
const eightWeeks = 4838400;
const sevenDays = 604800;

const ind = Math.floor((sSinceStart % eightWeeks) / sevenDays);

this.currentReward = rewards[ind];
this.currentReward = translator.steelPath(locale).rotation[ind];

this.activation = getFirstDayOfWeek();

this.expiry = getLastDayOfWeek();

this.remaining = timeDate.timeDeltaToString(this.expiry.getTime() - Date.now());

this.rotation = rewards;
this.rotation = translator.steelPath(locale).rotation;
this.evergreens = translator.steelPath(locale).evergreen;

/**
* General data pertaining to incursions
* @type {Object}
* @property {string} id Identifier for steel path incursion based on start of day.
* @property {Date} activation when the current incursions became active
* @property {Date} expiry when the current incursions become inactive
*/
this.incursions = {
id: `spi:${getStartOfDay().getTime()}`,
activation: getStartOfDay(),
expiry: getEndOfDay(),
};
}
};
6 changes: 6 additions & 0 deletions lib/translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @property {function} sortieModDesc - Converts sortie modifier type descriptions
* @property {function} region - Converts persistent enemy region indicies
* @property {function} conclaveChallenge - Convert conclave identifiers into standing data
* @property {function} steelPath - Retrieve Steel Path rotation data for locale
*/

const data = require('warframe-worldstate-data');
Expand Down Expand Up @@ -206,6 +207,10 @@ function conclaveChallenge(key, dataOverride) {
};
}

function steelPath(dataOverride) {
return (i18n(dataOverride) || data).steelPath;
}

module.exports = {
faction,
node,
Expand All @@ -228,4 +233,5 @@ module.exports = {
sortieFaction,
region,
conclaveChallenge,
steelPath,
};
Loading

0 comments on commit c77dee3

Please sign in to comment.