Skip to content

Commit

Permalink
feat: archon hunts (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTenno authored Sep 26, 2022
1 parent 1048db3 commit ad26b70
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install Dependencies
Expand Down
37 changes: 25 additions & 12 deletions src/embeds/SortieEmbed.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
import BaseEmbed from './BaseEmbed.js';

import { assetBase } from '../utilities/CommonFunctions.js';
import { cdn } from '../utilities/CommonFunctions.js';

const sortieThumb = `${assetBase}/img/sortie.png`;
const sortieThumb = cdn(`img/sortie.png`);
const narmer = cdn('img/narmer.png');

export default class SortieEmbed extends BaseEmbed {
constructor(sortie, { platform, i18n, locale }) {
super(locale);

this.color = 0xa84300;
if (typeof sortie !== 'undefined' && sortie) {
this.fields = sortie.variants.map((v) => ({
name: `${v.node} - ${v.missionType}`,
value: v.modifier,
}));
this.description = i18n`Currently in-progress sortie: **${sortie.boss}**`;
this.fields = sortie?.variants?.length
? sortie.variants.map((v) => ({
name: `${v.node} - ${v.missionType}`,
value: v.modifier,
}))
: sortie?.missions.map((m) => ({
name: `${m.node} - ${m.type}`,
value: '_ _',
}));
if (sortie?.variants?.length) {
this.description = i18n`Currently in-progress sortie: **${sortie.boss}**`;
this.title = i18n`[${platform.toUpperCase()}] Worldstate - Sortie`;
this.thumbnail = {
url: sortieThumb,
};
} else {
this.description = i18n`Currently in-progress hunt: **${sortie.boss}**`;
this.title = i18n`[${platform.toUpperCase()}] Worldstate - Archon Hunt`;
this.thumbnail = {
url: narmer,
};
}
this.footer.text = i18n`${sortie.eta} remaining`;
}

this.title = i18n`[${platform.toUpperCase()}] Worldstate - Sortie`;
this.thumbnail = {
url: sortieThumb,
};
}
}
9 changes: 8 additions & 1 deletion src/interactions/warframe/Worldstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ const aliases = {
outposts: 'sentientOutposts',
sales: 'flashSales',
steelpath: 'steelPath',
archons: 'archonHunt',
};
const embeds = {
arbitration: Arbitration,
alerts: Alert,
archonHunt: Sortie,
cambionCycle: Cambion,
cetusCycle: Cycle,
conclaveChallenges: Conclave,
Expand Down Expand Up @@ -109,6 +111,10 @@ export default class WorldState extends Interaction {
...cmds.arbi,
options: platformable,
},
{
...cmds.archons,
options: platformable,
},
{
...cmds.baro,
options: platformable,
Expand Down Expand Up @@ -287,6 +293,7 @@ export default class WorldState extends Interaction {
);
}
case 'arbitration':
case 'archonHunt':
case 'earthCycle':
case 'cetusCycle':
case 'vallisCycle':
Expand All @@ -296,7 +303,7 @@ export default class WorldState extends Interaction {
case 'nightwave':
case 'sortie':
case 'sentientOutposts':
if (!data.length && !Object.keys(data).length) {
if (!data?.length && !Object.keys(data).length) {
return interaction.editReply(ctx.i18n`No ${field.charAt(0).toUpperCase() + field.slice(1)} Active`);
}
embed = new MessageEmbed(new embeds[field](data, { platform, i18n: ctx.i18n }));
Expand Down
22 changes: 20 additions & 2 deletions src/notifications/worldstate/Notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const buildNotifiableData = (newData, platform, notified) => {
const data = {
acolytes: newData.persistentEnemies.filter((e) => !notified.includes(e.pid)),
alerts: newData.alerts.filter((a) => !a.expired && !notified.includes(a.id)),
archonHunt:
newData.archonHunt && !newData.archonHunt.expired && !notified.includes(newData.archonHunt.id)
? newData.archonHunt
: undefined,
baro:
newData.voidTrader && !notified.includes(`${newData.voidTrader.id}${newData.voidTrader.active ? '1' : '0'}`)
? newData.voidTrader
Expand Down Expand Up @@ -159,6 +163,7 @@ export default class Notifier {
{
alerts,
arbitration,
archonHunt,
dailyDeals,
events,
fissures,
Expand Down Expand Up @@ -213,6 +218,7 @@ export default class Notifier {
this.#sendNightwave(nightwave, platform);
this.#sendArbitration(arbitration, platform);
await this.#sendSteelPath(steelPath, platform);
await this.#sendArchonHunt(archonHunt, platform);
} catch (e) {
logger.error(e);
} finally {
Expand Down Expand Up @@ -240,6 +246,7 @@ export default class Notifier {
: []),
rawData.sentientOutposts.id,
rawData.steelPath && rawData.steelPath.expiry ? asId(rawData.steelPath, 'steelpath') : 'steelpath:0',
rawData.archonHunt.id,
].filter((a) => a);

await this.#settings.setNotifiedIds(platform, alreadyNotified);
Expand Down Expand Up @@ -303,6 +310,17 @@ export default class Notifier {
return this.standardBroadcast(arbitration, { Embed: embeds.Arbitration, type, platform });
}

async #sendArchonHunt(newArchonHunt, platform) {
if (!newArchonHunt) return;
const thumb = await getThumbnailForItem(newArchonHunt.boss, true);
return this.standardBroadcast(newArchonHunt, {
Embed: embeds.Sortie,
type: 'archonhunt',
platform,
thumb,
});
}

async #sendBaro(newBaro, platform) {
return perLanguage(async ({ i18n, locale }) => {
const embed = new embeds.VoidTrader(newBaro, { platform, i18n, locale });
Expand Down Expand Up @@ -445,7 +463,7 @@ export default class Notifier {
return this.#sendNews(newStreams, platform, 'streams');
}

async checkAndSendSyndicate(embed, syndicate, platform) {
async #checkAndSendSyndicate(embed, syndicate, platform) {
if (
embed.description &&
embed.description.length > 0 &&
Expand All @@ -469,7 +487,7 @@ export default class Notifier {
locale,
});
const eKey = `${prefix || ''}${key}`;
return this.checkAndSendSyndicate(embed, eKey, platform);
return this.#checkAndSendSyndicate(embed, eKey, platform);
});
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/resources/cachedEvents.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@
"fissures.t4.assassination",
"fissures.t5.assassination",
"steelpath",
"steelpath.umbra"
"steelpath.umbra",
"archonhunt"
]
4 changes: 4 additions & 0 deletions src/resources/locales/commands/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export default {
name: 'arbi',
description: 'Get WorldState Arbitrations',
},
archons: {
name: 'archons',
description: 'Get current Archon Hunt',
},
baro: {
name: 'baro',
description: 'Get Current Void Trader Inventory',
Expand Down
5 changes: 4 additions & 1 deletion src/resources/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"[{0}] Worldstate - Fissures": "[{0}] Fissures",
"[{0}] Worldstate - Void Fissures": "[{0}] Fissures",
"[{0}] Worldstate - Sortie": "[{0}] Sortie",
"[{0}] Worldstate - Archon Hunt": "[{0}] Archon Hunt",
"[{0}] Acolytes": "[{0}] Acolytes",
"[{0}] Worldstate - Sanctuary": "[{0}] Worldstate - Sanctuary",
"[{0}] {1}": "[{0}] {1}",
Expand Down Expand Up @@ -271,5 +272,7 @@
"No News Currently": "No News Currently",
"Are you sure?": "Are you sure?",
"⚠️ No {0} active.": "⚠️ No {0} active.",
"couldn't find a corgi... :(": "couldn't find a corgi... :("
"couldn't find a corgi... :(": "couldn't find a corgi... :(",
"Currently in-progress sortie: **{0}**": "Currently in-progress sortie: **{0}**",
"Currently in-progress hunt: **{0}**": "Currently in-progress hunt: **{0}**"
}
3 changes: 2 additions & 1 deletion src/resources/trackables.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"cambion.fass",
"cambion.vome",
"steelpath",
"steelpath.umbra"
"steelpath.umbra",
"archonhunt"
],
"opts": [
"all",
Expand Down
1 change: 1 addition & 0 deletions src/utilities/WorldStateClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default class WorldStateClient {
NEWS: 'news',
EVENTS: 'events',
ALERTS: 'alerts',
ARCHON_HUNT: 'archonHunt',
SORTIE: 'sortie',
SYNDICATE_MISSIONS: 'syndicateMissions',
FISSURES: 'fissures',
Expand Down

0 comments on commit ad26b70

Please sign in to comment.