small consistency tweaks

This commit is contained in:
Jill 2023-11-15 19:09:15 +03:00
parent 9af3499d3d
commit 20b914417f
Signed by: oat
GPG Key ID: 33489AA58A955108
2 changed files with 12 additions and 3 deletions

View File

@ -1,6 +1,6 @@
import { AutocompleteInteraction, GuildMember, Interaction, SlashCommandBuilder } from 'discord.js';
import { CraftingStationCooldown, db } from '../lib/db';
import { getStation, canUseStation, craftingStations } from '../lib/rpg/craftingStations';
import { getStation, canUseStation, craftingStations, verb } from '../lib/rpg/craftingStations';
import { formatItem, getItemQuantity, formatItems, getMaxStack, giveItem, formatItemsArray } from '../lib/rpg/items';
import { getRecipe, defaultRecipes, formatRecipe } from '../lib/rpg/recipes';
@ -47,7 +47,7 @@ module.exports = {
}
for (const out of recipe.outputs) {
const inv = await getItemQuantity(member.id, out.item.id);
if (inv.quantity + out.quantity > getMaxStack(out.item)) return interaction.followUp(`You do not have enough inventory storage for this recipe! (${formatItems(out.item, inv.quantity + out.quantity)} is bigger than the stack size of ${getMaxStack(out.item)}.)`);
if (inv.quantity + out.quantity > getMaxStack(out.item)) return interaction.followUp(`You do not have enough inventory storage for this recipe! (${formatItems(out.item, inv.quantity + out.quantity)} is bigger than the stack size of ${getMaxStack(out.item)}x.)`);
}
let cooldown;
@ -92,7 +92,7 @@ module.exports = {
nextUsableAt = Date.now() + station.cooldown * 1000;
}
return interaction.followUp(`${station.emoji} Crafted ${formatItemsArray(outputs)}!${nextUsableAt ? `\n${station.name} usable again <t:${Math.floor(nextUsableAt / 1000)}:R>` : ''}`);
return interaction.followUp(`${station.emoji} ${verb(station)} ${formatItemsArray(outputs)}!${nextUsableAt ? `\n${station.name} usable again <t:${Math.floor(nextUsableAt / 1000)}:R>` : ''}`);
},
autocomplete: async (interaction: AutocompleteInteraction) => {

View File

@ -4,6 +4,7 @@ import { DefaultItems, Item, Items, formatItems, formatItemsArray, getDefaultIte
export interface CraftingStation {
key: string,
name: string,
verb?: string,
description: string,
emoji: string,
requires?: Item,
@ -17,10 +18,13 @@ export function getStation(key: string) {
return craftingStations.find(station => station.key === key);
}
export const defaultVerb = 'Crafted';
export const craftingStations: CraftingStation[] = [
{
key: 'forage',
name: 'Forage',
verb: 'Foraged',
description: 'Pick up various sticks and stones from the forest',
emoji: '🌲',
cooldown: 60 * 5,
@ -51,6 +55,7 @@ export const craftingStations: CraftingStation[] = [
{
key: 'hand',
name: 'Hand',
verb: 'Made',
description: 'You can use your hands to make a small assortment of things',
emoji: '✋'
},
@ -68,4 +73,8 @@ export async function canUseStation(user: string, station: CraftingStation) {
const inv = await getItemQuantity(user, station.requires.id);
return inv.quantity > 0;
}
export function verb(station: CraftingStation) {
return station.verb || defaultVerb;
}