diff --git a/src/service/lootData.ts b/src/service/lootData.ts index 72b1b53a..e4c14a24 100644 --- a/src/service/lootData.ts +++ b/src/service/lootData.ts @@ -85,6 +85,7 @@ export const lootTemplates: LootTemplate[] = [ dropDescription: "Awww", emote: ":catsmile:", asset: "assets/loot/01-kadse.jpg", + initialAttributes: [LootAttributeKindId.SWEET], attributeAsset: { [LootAttributeKindId.RADIOACTIVE]: "assets/loot/attributes/01-kadse-verstrahlt.jpg", }, @@ -484,6 +485,7 @@ export const lootTemplates: LootTemplate[] = [ dropDescription: "Bóbr kurwa! Ja pierdolę! Jakie bydlę!", emote: ":beaver:", asset: "assets/loot/36-biber.jpg", + initialAttributes: [LootAttributeKindId.SWEET], }, ] as const; diff --git a/src/service/lootDrop.ts b/src/service/lootDrop.ts index 23a71741..6edacd6b 100644 --- a/src/service/lootDrop.ts +++ b/src/service/lootDrop.ts @@ -182,8 +182,6 @@ export async function postLootDrop( return; } - await awardPostDropLootAttributes(claimedLoot); - await reply.delete(); log.info( @@ -284,13 +282,3 @@ async function getDropWeightAdjustments( weights: newWeights, }; } - -async function awardPostDropLootAttributes(loot: Loot) { - switch (loot.lootKindId) { - case LootKindId.KADSE: - await lootService.addLootAttributeIfNotPresent(loot.id, LootAttributeKindId.SWEET); - break; - default: - break; - } -} diff --git a/src/storage/loot.ts b/src/storage/loot.ts index cc84d7da..7b457eec 100644 --- a/src/storage/loot.ts +++ b/src/storage/loot.ts @@ -20,7 +20,7 @@ import type { } from "./db/model.js"; import db from "@db"; -import type { LootAttributeKindId } from "@/service/lootData.js"; +import { resolveLootAttributeTemplate, type LootAttributeKindId } from "@/service/lootData.js"; export type LootUseCommandInteraction = ChatInputCommandInteraction & { channel: GuildTextBasedChannel; @@ -36,6 +36,7 @@ export interface LootTemplate { emote: string; excludeFromInventory?: boolean; effects?: string[]; + initialAttributes?: LootAttributeKindId[]; onDrop?: ( context: BotContext, @@ -110,6 +111,13 @@ export async function createLoot( .returningAll() .executeTakeFirstOrThrow(); + for (const attributeId of template.initialAttributes ?? []) { + const attribute = resolveLootAttributeTemplate(attributeId); + if (!attribute) continue; + + await addLootAttributeIfNotPresent(res.id, attribute, ctx); + } + if (rarityAttribute) { await addLootAttributeIfNotPresent(res.id, rarityAttribute, ctx); }