Skip to content

Commit

Permalink
explicitly filter loot attributes for rarities
Browse files Browse the repository at this point in the history
  • Loading branch information
twobiers committed Nov 3, 2024
1 parent 0a0243f commit 7d132e5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/service/lootDrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { randomEntry, randomEntryWeighted } from "@/utils/arrayUtils.js";

import * as lootService from "@/service/loot.js";
import {
LootAttributeClassId,
LootAttributeKindId,
lootAttributeTemplates,
LootKindId,
Expand Down Expand Up @@ -157,12 +158,11 @@ export async function postLootDrop(

const template = randomEntryWeighted(lootTemplates, weights);

const rarityWeights = lootAttributeTemplates.map(a => a.initialDropWeight ?? 0);
const rarities = lootAttributeTemplates.filter(a => a.classId === LootAttributeClassId.RARITY);
const rarityWeights = rarities.map(a => a.initialDropWeight ?? 0);

const initialAttribute =
template.id === LootKindId.NICHTS
? null
: randomEntryWeighted(lootAttributeTemplates, rarityWeights);
template.id === LootKindId.NICHTS ? null : randomEntryWeighted(rarities, rarityWeights);

const claimedLoot = await lootService.createLoot(
template,
Expand Down

0 comments on commit 7d132e5

Please sign in to comment.