Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/service/lootData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -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;

Expand Down
12 changes: 0 additions & 12 deletions src/service/lootDrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ export async function postLootDrop(
return;
}

await awardPostDropLootAttributes(claimedLoot);

await reply.delete();

log.info(
Expand Down Expand Up @@ -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;
}
}
10 changes: 9 additions & 1 deletion src/storage/loot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,6 +36,7 @@ export interface LootTemplate {
emote: string;
excludeFromInventory?: boolean;
effects?: string[];
initialAttributes?: LootAttributeKindId[];

onDrop?: (
context: BotContext,
Expand Down Expand Up @@ -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);
}
Expand Down