Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Feb 19, 2024
1 parent abab625 commit c9b1def
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 32 deletions.
37 changes: 36 additions & 1 deletion src/lib/util/tameUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'];
}
32 changes: 1 addition & 31 deletions src/mahoji/commands/tames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import {
calculateMaximumTameFeedingLevelGain,
getMainTameLevel,
getTameSpecies,
getTameStatus,
getUsersTame,
tameGrowthLevel,
tameHasBeenFed,
Expand Down Expand Up @@ -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.";
Expand Down

0 comments on commit c9b1def

Please sign in to comment.