From c9b1def1f7d28402de301f946ef81b125ff1549e Mon Sep 17 00:00:00 2001 From: gc <30398469+gc@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:52:07 +1100 Subject: [PATCH] fixes --- src/lib/util/tameUtil.ts | 37 +++++++++++++++++++++++++++++++++++- src/mahoji/commands/tames.ts | 32 +------------------------------ 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/lib/util/tameUtil.ts b/src/lib/util/tameUtil.ts index faf89eb647..60aa41e405 100644 --- a/src/lib/util/tameUtil.ts +++ b/src/lib/util/tameUtil.ts @@ -8,7 +8,7 @@ import { getSimilarItems } from '../data/similarItems'; import { prisma } from '../settings/prisma'; import { seaMonkeySpells, Species, tameKillableMonsters, tameSpecies, TameTaskOptions, TameType } from '../tames'; import { ItemBank } from '../types'; -import { itemNameFromID } from './smallUtils'; +import { formatDuration, itemNameFromID } from './smallUtils'; export async function tameLastFinishedActivity(user: MUser) { const tameID = user.user.selected_tame; @@ -133,3 +133,38 @@ export async function getUsersTame( const species = tameSpecies.find(i => i.id === tame.species_id)!; return { tame, activity, species }; } + +export function getTameStatus(tameActivity: TameActivity | null) { + if (tameActivity) { + const currentDate = new Date().valueOf(); + const timeRemaining = `${formatDuration(tameActivity.finish_date.valueOf() - currentDate, true)} remaining`; + const activityData = tameActivity.data as any as TameTaskOptions; + switch (activityData.type) { + case TameType.Combat: + return [ + `Killing ${activityData.quantity.toLocaleString()}x ${ + tameKillableMonsters.find(m => m.id === activityData.monsterID)?.name + }`, + timeRemaining + ]; + case TameType.Gatherer: + return [`Collecting ${itemNameFromID(activityData.itemID)?.toLowerCase()}`, timeRemaining]; + case 'SpellCasting': + return [ + `Casting ${seaMonkeySpells.find(i => i.id === activityData.spellID)!.name} ${ + activityData.quantity + }x times`, + timeRemaining + ]; + case 'Tempoross': + return ['Fighting the Tempoross', timeRemaining]; + case 'Wintertodt': + return ['Fighting the Wintertodt', timeRemaining]; + case 'Clues': { + const tier = ClueTiers.find(i => i.scrollID === activityData.clueID); + return [`Completing ${tier!.name} clues`, timeRemaining]; + } + } + } + return ['Idle']; +} diff --git a/src/mahoji/commands/tames.ts b/src/mahoji/commands/tames.ts index 12e7e4b376..f60dbcf346 100644 --- a/src/mahoji/commands/tames.ts +++ b/src/mahoji/commands/tames.ts @@ -68,6 +68,7 @@ import { calculateMaximumTameFeedingLevelGain, getMainTameLevel, getTameSpecies, + getTameStatus, getUsersTame, tameGrowthLevel, tameHasBeenFed, @@ -586,37 +587,6 @@ export async function removeRawFood({ }; } -export function getTameStatus(tameActivity: TameActivity | null) { - if (tameActivity) { - const currentDate = new Date().valueOf(); - const timeRemaining = `${formatDuration(tameActivity.finish_date.valueOf() - currentDate, true)} remaining`; - const activityData = tameActivity.data as any as TameTaskOptions; - switch (activityData.type) { - case TameType.Combat: - return [ - `Killing ${activityData.quantity.toLocaleString()}x ${ - tameKillableMonsters.find(m => m.id === activityData.monsterID)?.name - }`, - timeRemaining - ]; - case TameType.Gatherer: - return [`Collecting ${itemNameFromID(activityData.itemID)?.toLowerCase()}`, timeRemaining]; - case 'SpellCasting': - return [ - `Casting ${seaMonkeySpells.find(i => i.id === activityData.spellID)!.name} ${ - activityData.quantity - }x times`, - timeRemaining - ]; - case 'Tempoross': - return ['Fighting the Tempoross', timeRemaining]; - case 'Wintertodt': - return ['Fighting the Wintertodt', timeRemaining]; - } - } - return ['Idle']; -} - async function setNameCommand(user: MUser, name: string) { if (!name || name.length < 2 || name.length > 30 || ['\n', '`', '@', '<', ':'].some(char => name.includes(char))) { return "That's not a valid name for your tame.";