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
13 changes: 6 additions & 7 deletions src/commands/gegenstand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { ensureChatInputCommand } from "#utils/interactionUtils.ts";
import * as imageService from "#service/image.ts";

import * as lootDataService from "#service/lootData.ts";
import { LootAttributeKindId, LootKindId } from "#service/lootData.ts";
import { LootAttributeKind, LootKind } from "#service/lootData.ts";

import log from "#log";

Expand Down Expand Up @@ -156,7 +156,7 @@ export default class GegenstandCommand implements ApplicationCommand {

const wasteContents = await lootService.getUserLootsByTypeId(
interaction.user.id,
LootKindId.RADIOACTIVE_WASTE,
LootKind.RADIOACTIVE_WASTE,
);

if (wasteContents.length === 0) {
Expand All @@ -168,7 +168,7 @@ export default class GegenstandCommand implements ApplicationCommand {

const sweetContent = await lootService.getUserLootsWithAttribute(
interaction.user.id,
LootAttributeKindId.SWEET,
LootAttributeKind.SWEET,
);

if (sweetContent.length === 0) {
Expand Down Expand Up @@ -222,7 +222,7 @@ export default class GegenstandCommand implements ApplicationCommand {

const rarity =
lootDataService.extractRarityAttribute(attributes) ??
lootDataService.lootAttributeTemplates[LootAttributeKindId.RARITY_NORMAL];
lootDataService.lootAttributeTemplates[LootAttributeKind.RARITY_NORMAL];

const otherAttributes = lootDataService.extractNonRarityAttributes(attributes);

Expand All @@ -233,8 +233,7 @@ export default class GegenstandCommand implements ApplicationCommand {
let assetPath = template.asset;
if (template.attributeAsset) {
for (const attribute of otherAttributes) {
const asset =
template.attributeAsset[attribute.attributeKindId as LootAttributeKindId];
const asset = template.attributeAsset[attribute.attributeKindId];
if (asset) {
assetPath = asset;
break;
Expand Down Expand Up @@ -265,7 +264,7 @@ export default class GegenstandCommand implements ApplicationCommand {

const nutriScoreColor = lootDataService.getAttributesByClass(
otherAttributes,
lootDataService.LootAttributeClassId.NUTRI_SCORE,
lootDataService.LootAttributeClass.NUTRI_SCORE,
)[0]?.color;

await interaction.reply({
Expand Down
4 changes: 2 additions & 2 deletions src/commands/inventar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { ApplicationCommand } from "#commands/command.ts";
import * as lootService from "#service/loot.ts";
import { ensureChatInputCommand } from "#utils/interactionUtils.ts";
import * as lootDataService from "#service/lootData.ts";
import { LootAttributeKindId } from "#service/lootData.ts";
import { LootAttributeKind } from "#service/lootData.ts";

import log from "#log";

Expand Down Expand Up @@ -58,7 +58,7 @@ export default class InventarCommand implements ApplicationCommand {
const rarityAttribute = lootDataService.extractRarityAttribute(item.attributes);
const rarity =
rarityAttribute &&
rarityAttribute.attributeKindId !== LootAttributeKindId.RARITY_NORMAL
rarityAttribute.attributeKindId !== LootAttributeKind.RARITY_NORMAL
? ` (${rarityAttribute.displayName})`
: "";

Expand Down
6 changes: 2 additions & 4 deletions src/service/birthday.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ${userString} ${gotPresents ? "Zum Geurtstag habt ihr ein Geschenk erhalten" : "
}

async function awardBirthdayPresents(users: GuildMember[]) {
const present = lootDataService.resolveLootTemplate(lootDataService.LootKindId.GESCHENK);
const present = lootDataService.resolveLootTemplate(lootDataService.LootKind.GESCHENK);
if (!present) {
throw new Error("Could not resolve loot template");
}
Expand All @@ -115,9 +115,7 @@ async function awardBirthdayPresents(users: GuildMember[]) {
null,
"birthday",
null,
lootDataService.lootAttributeTemplates[
lootDataService.LootAttributeKindId.RARITY_NORMAL
],
lootDataService.lootAttributeTemplates[lootDataService.LootAttributeKind.RARITY_NORMAL],
);
}
}
18 changes: 9 additions & 9 deletions src/service/hatching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import type { Loot } from "#storage/db/model.ts";
import log from "#log";
import * as time from "#utils/time.ts";
import * as lootService from "#service/loot.ts";
import { LootKindId, resolveLootTemplate } from "./lootData.ts";
import { LootKind, resolveLootTemplate } from "./lootData.ts";
import * as randomService from "./random.ts";

export async function hatchEggs(context: BotContext) {
log.info("Checking egg hatching");

const now = Date.now();
const maxEggAge = time.days(30);
const eggs = await lootService.getLootsByKindId(LootKindId.EI);
const eggs = await lootService.getLootsByKindId(LootKind.EI);

for (const e of eggs) {
const itemAge = now - new Date(e.claimedAt).getTime();
Expand All @@ -34,15 +34,15 @@ export async function hatchEggs(context: BotContext) {
}

async function hatchEgg(context: BotContext, egg: Loot) {
console.assert(egg.lootKindId === LootKindId.EI, "Can only hatch eggs");
console.assert(egg.lootKindId === LootKind.EI, "Can only hatch eggs");

const hatchCandidates = [
LootKindId.KADSE,
LootKindId.BIBER,
LootKindId.FERRIS,
LootKindId.OETTINGER,
LootKindId.THUNFISCHSHAKE,
LootKindId.EI,
LootKind.KADSE,
LootKind.BIBER,
LootKind.FERRIS,
LootKind.OETTINGER,
LootKind.THUNFISCHSHAKE,
LootKind.EI,
];
const hatchWeights = [10, 10, 10, 1, 1, 5];

Expand Down
5 changes: 4 additions & 1 deletion src/service/loot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export async function getLootAttributes(id: LootId) {
return await loot.getLootAttributes(id);
}

export async function getUserLootCountById(userId: Snowflake, lootTypeId: number): Promise<number> {
export async function getUserLootCountById(
userId: Snowflake,
lootTypeId: LootKindId,
): Promise<number> {
return (await loot.getUserLootsByTypeId(userId, lootTypeId)).length;
}

Expand Down
Loading