Skip to content

Commit

Permalink
Add getDropWeightAdjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
holzmaster committed Sep 6, 2024
1 parent de8e84b commit a211ac4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/service/loot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
type Guild,
type GuildBasedChannel,
type TextBasedChannel,
GuildMember,
} from "discord.js";
import { Temporal } from "@js-temporal/polyfill";
import * as sentry from "@sentry/bun";
Expand Down Expand Up @@ -518,7 +519,9 @@ async function postLootDrop(context: BotContext, channel: GuildBasedChannel & Te
return;
}

const weights = lootTemplates.map(t => t.weight); // TODO: User penalties
const defaultWeights = lootTemplates.map(t => t.weight);

const weights = await getDropWeightAdjustments(interaction.user, defaultWeights);

const template = randomEntryWeighted(lootTemplates, weights);
const l = await loot.createLoot(template, validUntil, message);
Expand Down Expand Up @@ -628,3 +631,7 @@ export async function getUserLootsById(user: User, lootTypeId: number) {
export function transferLootToUser(lootId: number, user: User) {
return loot.transferLootToUser(lootId, user.id);
}

async function getDropWeightAdjustments(user: User, weights: readonly number[]): Promise<number[]> {
return [...weights]; // TODO: User penalties
}

0 comments on commit a211ac4

Please sign in to comment.