Skip to content

Commit

Permalink
Geschenk Embeds mit Feldern ausschmücken (#489)
Browse files Browse the repository at this point in the history
* Add loot opener and rarity as fields to embed

* explicitly filter loot attributes for rarities

* remove unrequired template string

* Field Tweaks

* Update ehren word

* remove rarity from title
  • Loading branch information
twobiers authored Nov 4, 2024
1 parent 3c2a647 commit bd0e78f
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 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 Expand Up @@ -197,15 +197,31 @@ export async function postLootDrop(
await message.edit({
embeds: [
{
title: `Das Geschenk enthielt: ${template.titleText} ${initialAttribute?.shortDisplay ?? ""}`.trim(),
title: `Das Geschenk enthielt: ${template.titleText}`,
description: template.dropDescription,
image: attachment
? {
url: "attachment://opened.gif",
}
: undefined,
fields: [
{
name: "🎉 Ehrenwerter Empfänger",
value: winner.toString(),
inline: true,
},
...(initialAttribute
? [
{
name: "✨ Rarität",
value: `${initialAttribute.shortDisplay} ${initialAttribute.displayName}`.trim(),
inline: true,
},
]
: []),
],
footer: {
text: `🎉 ${winner.displayName} hat das Geschenk geöffnet\n${messages.join("\n")}`.trim(),
text: messages.join("\n").trim(),
},
},
],
Expand Down

0 comments on commit bd0e78f

Please sign in to comment.