From baa32191b41bf3435fa61443bfdca284a74b12a6 Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Sat, 18 Nov 2023 17:53:09 +0300 Subject: [PATCH] extra content --- src/lib/rpg/craftingStations.ts | 77 ++++++++++++++-------- src/lib/rpg/items.ts | 110 ++++++++++++++++++++++++++++++++ src/lib/rpg/recipes.ts | 107 ++++++++++++++++++++++++++++++- 3 files changed, 266 insertions(+), 28 deletions(-) diff --git a/src/lib/rpg/craftingStations.ts b/src/lib/rpg/craftingStations.ts index 63b7056..ddddafc 100644 --- a/src/lib/rpg/craftingStations.ts +++ b/src/lib/rpg/craftingStations.ts @@ -20,6 +20,34 @@ export function getStation(key: string) { export const defaultVerb = 'Crafted'; +const rollBunch = (outputs: Items[]) => { + const totalItems = outputs.reduce((a, b) => a + b.quantity, 0); + // grab from 1/3 to the entire pool, ensure it never goes below 1 + const rolledItems = Math.max(Math.round(totalItems/3 + Math.random() * totalItems*2/3), 1); + const res: Items[] = []; + for (let i = 0; i < rolledItems; i++) { + const rolled = pickRandom(outputs); + const r = res.find(r => r.item.id === rolled.item.id); + if (r) { + if (r.quantity === rolled.quantity) { + // don't roll more than can be rolled + i--; + } else { + r.quantity = r.quantity + 1; + } + } else { + res.push({ item: rolled.item, quantity: 1 }); + } + } + return res; +}; + +const formatMaybeCountable = (inputs: Items[], requirements: Items[], outputs: Items[], disableBold = false) => + `${formatItemsArray(inputs, disableBold)} ${requirements.length > 0 ? `w/ ${formatItemsArray(requirements, disableBold)}: ` : ''}${outputs.map(i => formatItems(i.item, i.quantity, disableBold) + '?').join(' ')}`; + +const formatMaybe = (inputs: Items[], requirements: Items[], outputs: Items[], disableBold = false) => + `${formatItemsArray(inputs, disableBold)} ${requirements.length > 0 ? `w/ ${formatItemsArray(requirements, disableBold)} ` : ''}=> ${outputs.map(i => formatItem(i.item, disableBold) + '?').join(' ')}`; + export const craftingStations: CraftingStation[] = [ { key: 'forage', @@ -28,29 +56,8 @@ export const craftingStations: CraftingStation[] = [ description: 'Pick up various sticks and stones from the forest', emoji: '🌲', cooldown: 60 * 5, - formatRecipe: (_inputs, requirements, outputs, disableBold = false) => - `${requirements.length > 0 ? `w/ ${formatItemsArray(requirements, disableBold)}: ` : ''}${outputs.map(i => formatItems(i.item, i.quantity, disableBold) + '?').join(' ')}`, - manipulateResults: (outputs) => { - const totalItems = outputs.reduce((a, b) => a + b.quantity, 0); - // grab from 1/3 to the entire pool, ensure it never goes below 1 - const rolledItems = Math.max(Math.round(totalItems/3 + Math.random() * totalItems*2/3), 1); - const res: Items[] = []; - for (let i = 0; i < rolledItems; i++) { - const rolled = pickRandom(outputs); - const r = res.find(r => r.item.id === rolled.item.id); - if (r) { - if (r.quantity === rolled.quantity) { - // don't roll more than can be rolled - i--; - } else { - r.quantity = r.quantity + 1; - } - } else { - res.push({ item: rolled.item, quantity: 1 }); - } - } - return res; - } + formatRecipe: formatMaybeCountable, + manipulateResults: rollBunch }, { key: 'hand', @@ -72,9 +79,9 @@ export const craftingStations: CraftingStation[] = [ verb: 'Fished up', description: 'fish gaming wednesday', emoji: '🎣', + cooldown: 60 * 60 * 2, requires: getDefaultItem(DefaultItems.FISHING_ROD), - formatRecipe: (inputs, requirements, outputs, disableBold = false) => - `${formatItemsArray(inputs, disableBold)} => ${outputs.map(i => formatItem(i.item, disableBold) + '?').join(' ')}`, + formatRecipe: formatMaybe, // weighted random manipulateResults: (outputs) => { const pool: Item[] = []; @@ -86,6 +93,26 @@ export const craftingStations: CraftingStation[] = [ return [{ item: pickRandom(pool), quantity: 1 }]; } }, + { + key: 'mining', + name: 'Mining', + verb: 'Mined', + description: 'mine diamonds', + emoji: '⛏️', + cooldown: 60 * 30, + requires: getDefaultItem(DefaultItems.MINESHAFT), + formatRecipe: formatMaybeCountable, + manipulateResults: rollBunch, + }, + { + key: 'smelting', + name: 'Smelting', + verb: 'Smelt', + description: 'Smelt ores, minerals, food, whatever you please', + emoji: 'πŸ”₯', + cooldown: 30, + requires: getDefaultItem(DefaultItems.FURNACE), + }, ]; export async function canUseStation(user: string, station: CraftingStation) { diff --git a/src/lib/rpg/items.ts b/src/lib/rpg/items.ts index 3aca51b..edf4d64 100644 --- a/src/lib/rpg/items.ts +++ b/src/lib/rpg/items.ts @@ -26,6 +26,17 @@ export enum DefaultItems { EXOTIC_FISH = 14, SHOVEL = 15, DIRT = 16, + MINESHAFT = 17, + PICKAXE = 18, + IRON_PICKAXE = 19, + COAL = 20, + IRON_ORE = 21, + IRON_INGOT = 22, + DIAMOND = 23, + RUBY = 24, + EMERALD = 25, + FURNACE = 26, + FRIED_FISH = 27, } export const defaultItems: DefaultItem[] = [ @@ -172,6 +183,105 @@ export const defaultItems: DefaultItem[] = [ maxStack: 64, untradable: false, }, + { + id: -17, + name: 'Mineshaft', + description: 'A place for you to mine ores and minerals!', + emoji: '⛏️', + type: 'plain', + maxStack: 1, + untradable: true + }, + { + id: -18, + name: 'Pickaxe', + description: 'Basic mining equipment', + emoji: '⛏️', + type: 'plain', + maxStack: 8, + untradable: false + }, + { + id: -19, + name: 'Iron Pickaxe', + description: 'More durable and strong mining equipment', + emoji: 'βš’οΈ', + type: 'plain', + maxStack: 8, + untradable: false + }, + { + id: -20, + name: 'Coal', + description: 'Fuel, NOT EDIBLE', + emoji: '◾️', + type: 'plain', + maxStack: 128, + untradable: false + }, + { + id: -21, + name: 'Iron Ore', + description: 'Unsmelted iron', + emoji: '◽️', + type: 'plain', + maxStack: 128, + untradable: false + }, + { + id: -22, + name: 'Iron Ingot', + description: 'A sturdy material', + emoji: '◻️', + type: 'plain', + maxStack: 128, + untradable: false + }, + { + id: -23, + name: 'Diamond', + description: 'Shiny rock!', + emoji: 'πŸ’Ž', + type: 'plain', + maxStack: 128, + untradable: false + }, + { + id: -24, + name: 'Ruby', + description: 'Reference to the progarmiing......g.', + emoji: 'πŸ”»', + type: 'plain', + maxStack: 128, + untradable: false + }, + { + id: -25, + name: 'Emerald', + description: 'A currency in some other world', + emoji: '🟩', + type: 'plain', + maxStack: 128, + untradable: false + }, + { + id: -26, + name: 'Furnace', + description: 'A smeltery for your own needs', + emoji: 'πŸ”₯', + type: 'plain', + maxStack: 1, + untradable: false + }, + { + id: -27, + name: 'Fried Fish', + description: 'A very nice and filling meal', + emoji: '🍱', + type: 'consumable', + maxStack: 16, + untradable: false + }, ]; diff --git a/src/lib/rpg/recipes.ts b/src/lib/rpg/recipes.ts index 9addbab..9dba031 100644 --- a/src/lib/rpg/recipes.ts +++ b/src/lib/rpg/recipes.ts @@ -92,7 +92,7 @@ export const defaultRecipes: DefaultRecipe[] = [ }, { id: -7, - station: 'hand', + station: 'forage', inputs: [], requirements: [ { item: getDefaultItem(DefaultItems.AXE), quantity: 1 }, @@ -134,9 +134,9 @@ export const defaultRecipes: DefaultRecipe[] = [ { item: getDefaultItem(DefaultItems.SHOVEL), quantity: 1 }, ], outputs: [ - { item: getDefaultItem(DefaultItems.BAIT), quantity: 3 }, + { item: getDefaultItem(DefaultItems.BAIT), quantity: 4 }, { item: getDefaultItem(DefaultItems.PEBBLE), quantity: 1 }, - { item: getDefaultItem(DefaultItems.DIRT), quantity: 1 }, + { item: getDefaultItem(DefaultItems.DIRT), quantity: 3 }, ], }, { @@ -151,6 +151,107 @@ export const defaultRecipes: DefaultRecipe[] = [ { item: getDefaultItem(DefaultItems.SHOVEL), quantity: 1 }, ] }, + { + id: -12, + station: 'hand', + inputs: [ + { item: getDefaultItem(DefaultItems.DIRT), quantity: 4 }, + { item: getDefaultItem(DefaultItems.PEBBLE), quantity: 4 }, + ], + requirements: [], + outputs: [ + { item: getDefaultItem(DefaultItems.MINESHAFT), quantity: 1 }, + ] + }, + { + id: -13, + station: 'mining', + inputs: [ + { item: getDefaultItem(DefaultItems.PICKAXE), quantity: 1 }, + ], + requirements: [], + outputs: [ + { item: getDefaultItem(DefaultItems.PEBBLE), quantity: 10 }, + { item: getDefaultItem(DefaultItems.COAL), quantity: 5 }, + { item: getDefaultItem(DefaultItems.IRON_ORE), quantity: 5 }, + ] + }, + { + id: -14, + station: 'mining', + inputs: [ + { item: getDefaultItem(DefaultItems.IRON_PICKAXE), quantity: 1 }, + ], + requirements: [], + outputs: [ + { item: getDefaultItem(DefaultItems.PEBBLE), quantity: 10 }, + { item: getDefaultItem(DefaultItems.COAL), quantity: 5 }, + { item: getDefaultItem(DefaultItems.IRON_ORE), quantity: 5 }, + { item: getDefaultItem(DefaultItems.DIAMOND), quantity: 1 }, + { item: getDefaultItem(DefaultItems.EMERALD), quantity: 1 }, + { item: getDefaultItem(DefaultItems.RUBY), quantity: 1 }, + ] + }, + { + id: -15, + station: 'workbench', + inputs: [ + { item: getDefaultItem(DefaultItems.PEBBLE), quantity: 4 }, + { item: getDefaultItem(DefaultItems.TWIG), quantity: 3 }, + ], + requirements: [], + outputs: [ + { item: getDefaultItem(DefaultItems.PICKAXE), quantity: 1 }, + ] + }, + { + id: -16, + station: 'workbench', + inputs: [ + { item: getDefaultItem(DefaultItems.IRON_INGOT), quantity: 4 }, + { item: getDefaultItem(DefaultItems.TWIG), quantity: 3 }, + ], + requirements: [], + outputs: [ + { item: getDefaultItem(DefaultItems.IRON_PICKAXE), quantity: 1 }, + ] + }, + { + id: -17, + station: 'smelting', + inputs: [ + { item: getDefaultItem(DefaultItems.IRON_ORE), quantity: 2 }, + { item: getDefaultItem(DefaultItems.COAL), quantity: 1 }, + ], + requirements: [], + outputs: [ + { item: getDefaultItem(DefaultItems.IRON_INGOT), quantity: 1 }, + ] + }, + { + id: -18, + station: 'smelting', + inputs: [ + { item: getDefaultItem(DefaultItems.CARP), quantity: 1 }, + { item: getDefaultItem(DefaultItems.COAL), quantity: 1 }, + ], + requirements: [], + outputs: [ + { item: getDefaultItem(DefaultItems.FRIED_FISH), quantity: 1 }, + ] + }, + { + id: -19, + station: 'workbench', + inputs: [ + { item: getDefaultItem(DefaultItems.PEBBLE), quantity: 4 }, + { item: getDefaultItem(DefaultItems.COAL), quantity: 1 }, + ], + requirements: [], + outputs: [ + { item: getDefaultItem(DefaultItems.FURNACE), quantity: 1 }, + ] + } ]; export function getDefaultRecipe(id: number): DefaultRecipe | undefined {