Skip to content

Commit

Permalink
feat: new times for sentient outposts
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobiah committed May 1, 2020
1 parent ccb93dc commit e0a9331
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions lib/SentientOutpost.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';

const approxDuration = 1800;
const duration = 1800;

const sat = () => {
const now = Math.floor(Date.now() / 1000);
// One cycle = 3 hours
const cycleSeconds = now % 10800;
const cycleSeconds = now % duration;
// active range is after 30m and lasts for 30m
const active = cycleSeconds > 1800 && cycleSeconds < 3600;
const start = ((now - cycleSeconds) + 1800) * 1000;
const end = ((now - cycleSeconds) + 3600) * 1000;
const active = cycleSeconds > 0 && cycleSeconds < 1800;
const start = ((now - cycleSeconds)) * 1000;
const end = ((now - cycleSeconds) + duration) * 1000;

return {
active,
Expand Down Expand Up @@ -41,7 +41,7 @@ const sat = () => {
*/
class SentientOutpost {
constructor(data = '{\\"sfn\\":000}', {
translator, locale, sentientData, logger,
translator, locale,
}) {
const node = (data.match(/\d{3}/g) || ['000'])[0];
const id = `CrewBattleNode${node}`;
Expand All @@ -57,18 +57,6 @@ class SentientOutpost {
({ activation: this.activation, expiry: this.expiry } = sat());
this.active = this.mission !== null;
this.id = `${id}:${this.active}`;

if (!sentientData) {
logger.debug('No outpost data, skipping');
} else {
this.previous = {
activation: new Date(sentientData.start * 1000),
expiry: new Date(sentientData.end * 1000),
};

this.activation = new Date(sentientData.projection * 1000);
this.expiry = new Date((sentientData.projection + approxDuration) * 1000);
}
}
}

Expand Down

0 comments on commit e0a9331

Please sign in to comment.