Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Halloween event #5427

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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';
Expand Down Expand Up @@ -177,11 +178,12 @@
toaTask,
underwaterAgilityThievingTask,
strongholdTask,
specificQuestTask
specificQuestTask,
halloweenTask
];

export async function syncActivityCache() {
const tasks = await prisma.activity.findMany({ where: { completed: false } });

Check warning on line 186 in src/lib/Task.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 'tasks' is already declared in the upper scope on line 95 column 14. Raw Output: {"ruleId":"no-shadow","severity":1,"message":"'tasks' is already declared in the upper scope on line 95 column 14.","line":186,"column":8,"nodeType":"Identifier","messageId":"noShadow","endLine":186,"endColumn":13}

minionActivityCache.clear();
for (const task of tasks) {
Expand All @@ -198,7 +200,7 @@
}

const task = tasks.find(i => i.type === activity.type)!;
if (!task) {

Check warning on line 203 in src/lib/Task.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 Unexpected object value in conditional. The condition is always true. Raw Output: {"ruleId":"@typescript-eslint/strict-boolean-expressions","severity":1,"message":"Unexpected object value in conditional. The condition is always true.","line":203,"column":7,"nodeType":"Identifier","messageId":"conditionErrorObject","endLine":203,"endColumn":11}
throw new Error('Missing task');
}

Expand Down
48 changes: 48 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

export const Channel = {
General: DISCORD_SETTINGS.Channels?.General ?? '342983479501389826',
Notifications: production ? '469523207691436042' : '1042760447830536212',

Check warning on line 25 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 Unexpected any value in conditional. An explicit comparison or type cast is required. Raw Output: {"ruleId":"@typescript-eslint/strict-boolean-expressions","severity":1,"message":"Unexpected any value in conditional. An explicit comparison or type cast is required.","line":25,"column":17,"nodeType":"Identifier","messageId":"conditionErrorAny","endLine":25,"endColumn":27,"suggestions":[{"messageId":"conditionFixCastBoolean","fix":{"range":[982,992],"text":"(Boolean(production))"},"desc":"Explicitly cast value to a boolean (`Boolean(value)`)"}]}
GrandExchange: DISCORD_SETTINGS.Channels?.GrandExchange ?? '682996313209831435',
Developers: DISCORD_SETTINGS.Channels?.Developers ?? '648196527294251020',
BlacklistLogs: DISCORD_SETTINGS.Channels?.BlacklistLogs ?? '782459317218967602',
Expand All @@ -32,13 +32,13 @@
TestingMain: TestingMainChannelID,
BarbarianAssault: DISCORD_SETTINGS.Channels?.BarbarianAssault ?? '789717054902763520',
ChambersOfXeric: DISCORD_SETTINGS.Channels?.ChambersOfXeric ?? '835876917252587581',
BotLogs: production ? '1051725977320964197' : TestingMainChannelID,

Check warning on line 35 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 Unexpected any value in conditional. An explicit comparison or type cast is required. Raw Output: {"ruleId":"@typescript-eslint/strict-boolean-expressions","severity":1,"message":"Unexpected any value in conditional. An explicit comparison or type cast is required.","line":35,"column":11,"nodeType":"Identifier","messageId":"conditionErrorAny","endLine":35,"endColumn":21,"suggestions":[{"messageId":"conditionFixCastBoolean","fix":{"range":[1653,1663],"text":"(Boolean(production))"},"desc":"Explicitly cast value to a boolean (`Boolean(value)`)"}]}
GeneralChannel:
BOT_TYPE === 'OSB'
? production

Check warning on line 38 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 Unexpected any value in conditional. An explicit comparison or type cast is required. Raw Output: {"ruleId":"@typescript-eslint/strict-boolean-expressions","severity":1,"message":"Unexpected any value in conditional. An explicit comparison or type cast is required.","line":38,"column":6,"nodeType":"Identifier","messageId":"conditionErrorAny","endLine":38,"endColumn":16,"suggestions":[{"messageId":"conditionFixCastBoolean","fix":{"range":[1755,1765],"text":"(Boolean(production))"},"desc":"Explicitly cast value to a boolean (`Boolean(value)`)"}]}
? '346304390858145792'
: '1154056119019393035'
: production

Check warning on line 41 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 Unexpected any value in conditional. An explicit comparison or type cast is required. Raw Output: {"ruleId":"@typescript-eslint/strict-boolean-expressions","severity":1,"message":"Unexpected any value in conditional. An explicit comparison or type cast is required.","line":41,"column":6,"nodeType":"Identifier","messageId":"conditionErrorAny","endLine":41,"endColumn":16,"suggestions":[{"messageId":"conditionFixCastBoolean","fix":{"range":[1826,1836],"text":"(Boolean(production))"},"desc":"Explicitly cast value to a boolean (`Boolean(value)`)"}]}
? '792691343284764693'
: '1154056119019393035'
};
Expand Down Expand Up @@ -66,7 +66,7 @@
TopGlobalCL: '1072426869028294747'
};

export const enum Emoji {

Check warning on line 69 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 'Emoji' is already declared in the upper scope on line 69 column 19. Raw Output: {"ruleId":"no-shadow","severity":1,"message":"'Emoji' is already declared in the upper scope on line 69 column 19.","line":69,"column":19,"nodeType":"Identifier","messageId":"noShadow","endLine":69,"endColumn":24}
MoneyBag = '<:MoneyBag:493286312854683654>',
OSBot = '<:OSBot:601768469905801226>',
Joy = '😂',
Expand Down Expand Up @@ -168,14 +168,14 @@
BronzeTrophy = '<:BronzeTrophy:1152881057788592188>'
}

export enum ActivityGroup {

Check warning on line 171 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 'ActivityGroup' is already declared in the upper scope on line 171 column 13. Raw Output: {"ruleId":"no-shadow","severity":1,"message":"'ActivityGroup' is already declared in the upper scope on line 171 column 13.","line":171,"column":13,"nodeType":"Identifier","messageId":"noShadow","endLine":171,"endColumn":26}
Skilling = 'Skilling',
Clue = 'Clue',
Monster = 'Monster',
Minigame = 'Minigame'
}

export const enum Events {

Check warning on line 178 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 'Events' is already declared in the upper scope on line 178 column 19. Raw Output: {"ruleId":"no-shadow","severity":1,"message":"'Events' is already declared in the upper scope on line 178 column 19.","line":178,"column":19,"nodeType":"Identifier","messageId":"noShadow","endLine":178,"endColumn":25}
Error = 'error',
Log = 'log',
Verbose = 'verbose',
Expand All @@ -188,7 +188,7 @@

export const COINS_ID = 995;

export const enum PerkTier {

Check warning on line 191 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 'PerkTier' is already declared in the upper scope on line 191 column 19. Raw Output: {"ruleId":"no-shadow","severity":1,"message":"'PerkTier' is already declared in the upper scope on line 191 column 19.","line":191,"column":19,"nodeType":"Identifier","messageId":"noShadow","endLine":191,"endColumn":27}
/**
* Boosters
*/
Expand Down Expand Up @@ -578,3 +578,51 @@
**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'
]);
4 changes: 3 additions & 1 deletion src/lib/util/minionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
45 changes: 45 additions & 0 deletions src/mahoji/commands/halloween.ts
Original file line number Diff line number Diff line change
@@ -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<ActivityTaskData>({
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`.';
}
};
31 changes: 31 additions & 0 deletions src/tasks/minions/halloweenActivity.ts
Original file line number Diff line number Diff line change
@@ -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);
}
};