From 6ce0b2c433e85c5e53dd5720c28b96c2e05deeb7 Mon Sep 17 00:00:00 2001 From: gc <30398469+gc@users.noreply.github.com> Date: Sat, 14 Oct 2023 01:20:32 +1100 Subject: [PATCH] commit --- src/lib/Task.ts | 4 ++- src/lib/constants.ts | 48 ++++++++++++++++++++++++++ src/lib/util/minionStatus.ts | 4 ++- src/mahoji/commands/halloween.ts | 45 ++++++++++++++++++++++++ src/tasks/minions/halloweenActivity.ts | 31 +++++++++++++++++ 5 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 src/mahoji/commands/halloween.ts create mode 100644 src/tasks/minions/halloweenActivity.ts diff --git a/src/lib/Task.ts b/src/lib/Task.ts index c5b97ff421..5a46133d42 100644 --- a/src/lib/Task.ts +++ b/src/lib/Task.ts @@ -18,6 +18,7 @@ import { fishingTask } from '../tasks/minions/fishingActivity'; import { fletchingTask } from '../tasks/minions/fletchingActivity'; import { gloryChargingTask } from '../tasks/minions/gloryChargingActivity'; import { groupoMonsterTask } from '../tasks/minions/groupMonsterActivity'; +import { halloweenTask } from '../tasks/minions/halloweenActivity'; import { herbloreTask } from '../tasks/minions/herbloreActivity'; import { aerialFishingTask } from '../tasks/minions/HunterActivity/aerialFishingActivity'; import { birdHouseTask } from '../tasks/minions/HunterActivity/birdhouseActivity'; @@ -177,7 +178,8 @@ export const tasks: MinionTask[] = [ toaTask, underwaterAgilityThievingTask, strongholdTask, - specificQuestTask + specificQuestTask, + halloweenTask ]; export async function syncActivityCache() { diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 203e8ae9f5..fec4bbaaae 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -578,3 +578,51 @@ META_CONSTANTS.RENDERED_STR = `**Date/Time:** ${dateFm(META_CONSTANTS.STARTUP_DA **Git Hash:** ${META_CONSTANTS.GIT_HASH.slice(0, 7)} **Commit:** <${META_CONSTANTS.GITHUB_URL}> **Code Difference:** <${META_CONSTANTS.GIT_DIFF_URL}>`; + +export const hweenGiveableItems = resolveItems([ + 'Gravedigger mask', + 'Gravedigger top', + 'Gravedigger leggings', + 'Gravedigger gloves', + 'Gravedigger boots', + 'Jack lantern mask', + 'Scythe', + 'Grim reaper hood', + 'Jonas mask', + 'Skeleton mask', + 'Skeleton shirt', + 'Skeleton leggings', + 'Skeleton gloves', + 'Skeleton boots', + 'Anti-panties', + 'Banshee mask', + 'Banshee top', + 'Banshee robe', + 'Hunting knife', + 'Eek', + 'Clown mask', + 'Clown bow tie', + 'Clown gown', + 'Clown trousers', + 'Clown shoes', + 'Pumpkin lantern', + 'Skeleton lantern', + 'Spooky hood', + 'Spooky robe', + 'Spooky skirt', + 'Spooky gloves', + 'Spooky boots', + 'Headless head', + 'Magical pumpkin', + 'Haunted wine bottle', + 'Ugly halloween jumper (black)', + 'Ugly halloween jumper (orange)', + 'Saucepan', + "Black h'ween mask", + 'Witch hat', + 'Witch top', + 'Witch robes', + 'Witch boots', + 'Witch cape', + 'Halloween wig' +]); diff --git a/src/lib/util/minionStatus.ts b/src/lib/util/minionStatus.ts index 838d308507..801cfa3b74 100644 --- a/src/lib/util/minionStatus.ts +++ b/src/lib/util/minionStatus.ts @@ -670,8 +670,10 @@ export function minionStatus(user: MUser) { quests.find(i => i.id === data.questID)!.name }! The trip should take ${formatDuration(durationRemaining)}.`; } + case 'HalloweenEvent': { + return `${name} is doing the Halloween event! The trip should take ${formatDuration(durationRemaining)}.`; + } case 'Easter': - case 'HalloweenEvent': case 'BlastFurnace': { throw new Error('Removed'); } diff --git a/src/mahoji/commands/halloween.ts b/src/mahoji/commands/halloween.ts new file mode 100644 index 0000000000..0fca285932 --- /dev/null +++ b/src/mahoji/commands/halloween.ts @@ -0,0 +1,45 @@ +import { Time } from 'e'; +import { ApplicationCommandOptionType, CommandRunOptions } from 'mahoji'; + +import { hweenGiveableItems } from '../../lib/constants'; +import { ActivityTaskData } from '../../lib/types/minions'; +import addSubTaskToActivityTask from '../../lib/util/addSubTaskToActivityTask'; +import { formatDuration } from '../../lib/util/smallUtils'; +import { OSBMahojiCommand } from '../lib/util'; + +export const halloweenCommand: OSBMahojiCommand = { + name: 'halloween', + description: 'The 2023 OSB Halloween Event!', + options: [ + { + type: ApplicationCommandOptionType.Subcommand, + name: 'start', + description: 'Do the event.' + } + ], + run: async ({ + userID, + options, + channelID + }: CommandRunOptions<{ + start?: {}; + }>) => { + const user = await mUserFetch(userID); + if (options.start) { + if (hweenGiveableItems.every(i => user.cl.has(i))) { + return 'You have already completed the Halloween event!'; + } + const duration = Time.Minute * 15; + await addSubTaskToActivityTask({ + userID: user.id, + channelID, + duration, + type: 'HalloweenEvent' + }); + return `${user.minionName} is now doing the Halloween event! It'll take around ${formatDuration( + duration + )} to finish. Spooky!`; + } + return 'You can start the Halloween event by typing `/halloween start`.'; + } +}; diff --git a/src/tasks/minions/halloweenActivity.ts b/src/tasks/minions/halloweenActivity.ts new file mode 100644 index 0000000000..ccb3d376d3 --- /dev/null +++ b/src/tasks/minions/halloweenActivity.ts @@ -0,0 +1,31 @@ +import { Bank } from 'oldschooljs'; + +import { hweenGiveableItems } from '../../lib/constants'; +import { ActivityTaskData } from '../../lib/types/minions'; +import { handleTripFinish } from '../../lib/util/handleTripFinish'; + +export const halloweenTask: MinionTask = { + type: 'HalloweenEvent', + async run(data: ActivityTaskData) { + const { userID, channelID } = data; + const user = await mUserFetch(userID); + + const loot = new Bank(); + + for (const item of hweenGiveableItems) { + if (!user.cl.has(item)) { + loot.add(item); + } + } + + let str = `${user}, ${user.minionName} finished the Halloween event, you received: ${loot}.`; + + await transactItems({ + userID: user.id, + collectionLog: true, + itemsToAdd: loot + }); + + return handleTripFinish(user, channelID, str, undefined, data, loot); + } +};