Skip to content

Commit cd58ecb

Browse files
committed
feat: cambion
1 parent 5d8b435 commit cd58ecb

File tree

7 files changed

+123
-17
lines changed

7 files changed

+123
-17
lines changed

src/CommonFunctions.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const trackableEvents = {
9494
syndicates,
9595
conclave,
9696
deals,
97+
cambion: ['cambion.fass', 'cambion.vome'],
9798
cetus: ['cetus.day', 'cetus.night'],
9899
ostrons: ['cetus.day', 'cetus.night', 'syndicate.ostrons'],
99100
earth: ['earth.day', 'earth.night'],
@@ -168,6 +169,8 @@ const dyn = [
168169
'solaris\\.cold\\.[0-9]?[0-9]',
169170
'cetus\\.day\\.[0-1]?[0-9]?[0-9]?',
170171
'cetus\\.night\\.[0-1]?[0-9]?[0-9]?',
172+
'cambion\\.fass\\.[0-1]?[0-9]?[0-9]?',
173+
'cambion\\.vome\\.[0-1]?[0-9]?[0-9]?',
171174
...trackableEvents.rss,
172175
...trackableEvents.events,
173176
...rewardTypes,
@@ -212,6 +215,7 @@ const termToTrackable = (term) => {
212215
const cetusCustomTimeRegex = new RegExp('cetus\\.(day|night)\\.[0-1]?[0-9]?[0-9]?', 'ig');
213216
const earthCustomTimeRegex = new RegExp('earth\\.(day|night)\\.[0-1]?[0-9]?[0-9]?', 'ig');
214217
const solarisCustomTimeRegex = new RegExp('solaris\\.(warm|cold)\\.[0-9]?[0-9]?', 'ig');
218+
const cambionCustomTimeRegex = new RegExp('cambion\\.(fass|vome)\\.[0-1]?[0-9]?[0-9]?', 'ig');
215219

216220
const trackable = {
217221
events: [],
@@ -220,7 +224,8 @@ const termToTrackable = (term) => {
220224

221225
if (cetusCustomTimeRegex.test(term)
222226
|| earthCustomTimeRegex.test(term)
223-
|| solarisCustomTimeRegex.test(term)) {
227+
|| solarisCustomTimeRegex.test(term)
228+
|| cambionCustomTimeRegex.test(term)) {
224229
trackable.events = term;
225230
return trackable;
226231
}
@@ -1062,6 +1067,8 @@ const giveawayDefaults = {
10621067
},
10631068
};
10641069

1070+
const toTitleCase = str => str.toLowerCase().replace(/\b\w/g, l => l.toUpperCase());
1071+
10651072
/**
10661073
* Common functions for determining common functions
10671074
* @typedef {Object} CommonFunctions
@@ -1112,4 +1119,5 @@ module.exports = {
11121119
games,
11131120
giveawayDefaults,
11141121
markdinate,
1122+
toTitleCase,
11151123
};

src/commands/Worldstate/Cambion.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
const Command = require('../../models/Command');
4+
const CambionEmbed = require('../../embeds/CambionEmbed');
5+
const { captures } = require('../../CommonFunctions');
6+
7+
class Cambion extends Command {
8+
constructor(bot) {
9+
super(bot, 'warframe.worldstate.cambion', 'cambion', 'Display the currently active Cambion info', 'WARFRAME');
10+
this.regex = new RegExp(`^${this.call}s?\\s?(?:on\\s+${captures.platforms})?`, 'i');
11+
}
12+
13+
async run(message, ctx) {
14+
const platformParam = message.strippedContent.match(captures.platforms);
15+
const platform = platformParam && platformParam.length ? platformParam[0] : ctx.platform;
16+
const entrati = (await this.ws.get('syndicateMissions', platform, ctx.language))
17+
.filter(m => m.syndicate === 'EntratiSyndicate');
18+
const cambion = await this.ws.get('cambionCycle', platform, ctx.language);
19+
if (entrati && entrati.length) {
20+
[cambion.bounty] = entrati;
21+
}
22+
23+
// make the embed
24+
this.messageManager.embed(message, new CambionEmbed(this.bot, cambion), true, true);
25+
return this.messageManager.statuses.SUCCESS;
26+
}
27+
}
28+
29+
module.exports = Cambion;

src/commands/Worldstate/Solaris.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Solaris extends Command {
1515
}
1616

1717
async run(message, ctx) {
18-
const platformParam = message.strippedContent.match(/[pcsxb14]{2,3}/ig);
18+
const platformParam = message.strippedContent.match(captures.platforms);
1919
const platform = platformParam && platformParam.length ? platformParam[0] : ctx.platform;
2020
const solaris = (await this.ws.get('syndicateMissions', platform, ctx.language)).filter(m => m.syndicate === 'Solaris United');
2121
const vallis = await this.ws.get('vallisCycle', platform, ctx.language);

src/embeds/CambionEmbed.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
'use strict';
2+
3+
const BaseEmbed = require('./BaseEmbed.js');
4+
5+
const {
6+
timeDeltaToString, fromNow, assetBase, toTitleCase,
7+
} = require('../CommonFunctions.js');
8+
9+
const fass = `${assetBase}/img/FassBanner.png`;
10+
const vome = `${assetBase}/img/VomeBanner.png`;
11+
12+
const makeJobs = (mission) => {
13+
if (mission && mission.jobs && mission.jobs.length) {
14+
const tokens = [];
15+
mission.jobs.forEach((job) => {
16+
const totalStanding = job.standingStages.reduce((a, b) => a + b, 0);
17+
const levels = job.enemyLevels.join(' - ');
18+
const rewards = job.rewardPool instanceof Array ? job.rewardPool.join(' • ') : '';
19+
tokens.push(`\u200B \\⬆ ${totalStanding} - ${job.type} (${levels})`);
20+
if (job.rewardPool[0] && !job.rewardPool[0].startsWith('Pattern Mismatch.')) {
21+
tokens.push(`\\💰 ${rewards}\n`);
22+
}
23+
});
24+
25+
tokens.push(`\n**Expires in ${mission.eta}**`);
26+
27+
return tokens.join('\n');
28+
}
29+
return undefined;
30+
};
31+
32+
class CambionEmbed extends BaseEmbed {
33+
constructor(bot, state) {
34+
super();
35+
36+
this.title = `Cambion Drift Cycle - ${toTitleCase(state.active)}`;
37+
this.color = state.active === 'fass' ? 0xC6733F : 0x415B9E;
38+
this.thumbnail = {
39+
url: state.active === 'fass' ? fass : vome,
40+
};
41+
42+
const next = toTitleCase(state.active === 'fass' ? 'vome' : 'fass');
43+
44+
const nextCtd = `Time remaining until ${next}: ${timeDeltaToString(fromNow(new Date(state.expiry)))}`;
45+
this.description = `${state.bounty ? makeJobs(state.bounty) : ''}\n\n${nextCtd}`;
46+
47+
this.footer.text = `${next} starts `;
48+
this.timestamp = new Date(state.expiry);
49+
}
50+
}
51+
52+
module.exports = CambionEmbed;

src/notifications/Notifier.js

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function buildNotifiableData(newData, platform, notified) {
7575
const data = {
7676
acolytes: newData.persistentEnemies.filter(e => !notified.includes(e.pid)),
7777
alerts: newData.alerts.filter(a => !a.expired && !notified.includes(a.id)),
78-
baro: newData.voidTrader && !notified.includes(newData.voidTrader.id)
78+
baro: newData.voidTrader && !notified.includes(`${newData.voidTrader.id}${newData.voidTrader.active ? '1' : '0'}`)
7979
? newData.voidTrader
8080
: undefined,
8181
conclave: newData.conclaveChallenges
@@ -108,6 +108,8 @@ function buildNotifiableData(newData, platform, notified) {
108108
cetusCycleChange: between(newData.cetusCycle.activation, platform),
109109
earthCycleChange: between(newData.earthCycle.activation, platform),
110110
vallisCycleChange: between(newData.vallisCycle.activation, platform),
111+
cambionCycleChange: between(newData.cambionCycle.activation, platform),
112+
cambionCycle: newData.cambionCycle,
111113
cetusCycle: newData.cetusCycle,
112114
earthCycle: newData.earthCycle,
113115
vallisCycle: newData.vallisCycle,
@@ -178,9 +180,7 @@ class Notifier {
178180
refreshRate = timeout;
179181
}
180182

181-
/**
182-
* Start the notifier
183-
*/
183+
/** Start the notifier */
184184
async start() {
185185
Object.entries(this.worldStates).forEach(([, ws]) => {
186186
ws.on('newData', async (platform, newData) => {
@@ -220,6 +220,7 @@ class Notifier {
220220
cetusCycle, earthCycle, vallisCycle, tweets, nightwave,
221221
cetusCycleChange, earthCycleChange, vallisCycleChange,
222222
featuredDeals, streams, popularDeals, primeAccess, updates, conclave,
223+
cambionCycle, cambionCycleChange,
223224
}) {
224225
// Send all notifications
225226
const cycleIds = [];
@@ -256,6 +257,9 @@ class Notifier {
256257
cycleIds.push(
257258
await this.sendVallisCycle(vallisCycle, platform, vallisCycleChange, notifiedIds),
258259
);
260+
cycleIds.push(
261+
await this.sendCambionCycle(cambionCycle, platform, cambionCycleChange, notifiedIds),
262+
);
259263
this.sendUpdates(updates, platform);
260264
this.sendAlerts(alerts, platform);
261265
cycleIds.push(
@@ -272,7 +276,7 @@ class Notifier {
272276
alreadyNotified.push(
273277
...rawData.persistentEnemies.map(a => a.pid),
274278
...cycleIds,
275-
rawData.voidTrader.id,
279+
`${rawData.voidTrader.id}${rawData.voidTrader.active ? '1' : '0'}`,
276280
...rawData.fissures.map(f => f.id),
277281
...rawData.invasions.map(i => i.id),
278282
...rawData.news.map(n => n.id),
@@ -281,7 +285,6 @@ class Notifier {
281285
rawData.sortie.id,
282286
...rawData.syndicateMissions.map(m => m.id),
283287
...rawData.flashSales.map(s => s.id),
284-
rawData.voidTrader.id,
285288
...rawData.dailyDeals.map(d => d.id),
286289
...rawData.conclaveChallenges.map(cc => cc.id),
287290
...rawData.weeklyChallenges.map(w => w.id),
@@ -349,10 +352,21 @@ class Notifier {
349352
}
350353
}
351354

352-
async sendCetusCycle(newCetusCycle, platform, cetusCycleChange, notifiedIds) {
353-
const minutesRemaining = cetusCycleChange ? '' : `.${Math.round(fromNow(newCetusCycle.expiry) / 60000)}`;
354-
const type = `cetus.${newCetusCycle.isDay ? 'day' : 'night'}${minutesRemaining}`;
355-
const embed = new embeds.Cycle({ logger }, newCetusCycle);
355+
async sendCambionCycle(newCycle, platform, cycleChange, notifiedIds) {
356+
const minutesRemaining = cycleChange ? '' : `.${Math.round(fromNow(newCycle.expiry) / 60000)}`;
357+
const type = `cambion.${newCycle.active}${minutesRemaining}`;
358+
if (!notifiedIds.includes(type)) {
359+
await this.broadcaster.broadcast(
360+
new embeds.Cambion({ logger }, newCycle), platform, type,
361+
);
362+
}
363+
return type;
364+
}
365+
366+
async sendCetusCycle(newCycle, platform, cycleChange, notifiedIds) {
367+
const minutesRemaining = cycleChange ? '' : `.${Math.round(fromNow(newCycle.expiry) / 60000)}`;
368+
const type = `cetus.${newCycle.isDay ? 'day' : 'night'}${minutesRemaining}`;
369+
const embed = new embeds.Cycle({ logger }, newCycle);
356370
if (!notifiedIds.includes(type)) {
357371
await this.broadcaster.broadcast(embed, platform, type);
358372
}
@@ -379,12 +393,12 @@ class Notifier {
379393
await Promise.all(newDarvoDeals.map(d => this.broadcaster.broadcast(new embeds.Darvo({ logger }, d, platform), platform, 'darvo')));
380394
}
381395

382-
async sendEarthCycle(newEarthCycle, platform, earthCycleChange, notifiedIds) {
383-
const minutesRemaining = earthCycleChange ? '' : `.${Math.round(fromNow(newEarthCycle.expiry) / 60000)}`;
384-
const type = `earth.${newEarthCycle.isDay ? 'day' : 'night'}${minutesRemaining}`;
396+
async sendEarthCycle(newCycle, platform, cycleChange, notifiedIds) {
397+
const minutesRemaining = cycleChange ? '' : `.${Math.round(fromNow(newCycle.expiry) / 60000)}`;
398+
const type = `earth.${newCycle.isDay ? 'day' : 'night'}${minutesRemaining}`;
385399
if (!notifiedIds.includes(type)) {
386400
await this.broadcaster.broadcast(
387-
new embeds.Cycle({ logger }, newEarthCycle), platform, type,
401+
new embeds.Cycle({ logger }, newCycle), platform, type,
388402
);
389403
}
390404
return type;

src/notifications/NotifierUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const embeds = {
55
Alert: require('../embeds/AlertEmbed'),
66
Arbitration: require('../embeds/ArbitrationEmbed'),
77
Acolyte: require('../embeds/AcolyteEmbed'),
8+
Cambion: require('../embeds/CambionEmbed'),
89
Conclave: require('../embeds/ConclaveChallengeEmbed'),
910
Darvo: require('../embeds/DarvoEmbed'),
1011
Enemy: require('../embeds/EnemyEmbed'),

src/resources/trackables.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@
7979
"nightwave.daily",
8080
"nightwave.elite",
8181
"nightwave.weekly",
82-
"outposts"
82+
"outposts",
83+
"cambion.fass",
84+
"cambion.vome"
8385
],
8486
"opts": [
8587
"all",

0 commit comments

Comments
 (0)