diff --git a/src/commands/fight.ts b/src/commands/fight.ts index 799d1e78..7a96d7c1 100644 --- a/src/commands/fight.ts +++ b/src/commands/fight.ts @@ -22,8 +22,8 @@ import { type FightScene, } from "@/service/fightData.js"; import { setTimeout } from "node:timers/promises"; -import { getFightInventoryEnriched, removeItemsAfterFight } from "@/storage/fightinventory.js"; -import { getLastFight, insertResult } from "@/storage/fighthistory.js"; +import { getFightInventoryEnriched, removeItemsAfterFight } from "@/storage/fightInventory.js"; +import { getLastFight, insertResult } from "@/storage/fightHistory.js"; async function getFighter(user: User): Promise { const userInventory = await getFightInventoryEnriched(user.id); diff --git a/src/commands/gegenstand.ts b/src/commands/gegenstand.ts index 4b160569..51b4f2a8 100644 --- a/src/commands/gegenstand.ts +++ b/src/commands/gegenstand.ts @@ -24,7 +24,7 @@ import * as lootDataService from "@/service/lootData.js"; import { LootAttributeClassId, LootAttributeKindId, LootKindId } from "@/service/lootData.js"; import log from "@log"; -import { equipItembyLoot, getFightInventoryUnsorted } from "@/storage/fightinventory.js"; +import { equipItembyLoot, getFightInventoryUnsorted } from "@/storage/fightInventory.js"; export default class GegenstandCommand implements ApplicationCommand { name = "gegenstand"; diff --git a/src/commands/inventar.ts b/src/commands/inventar.ts index 2994c304..6161d432 100644 --- a/src/commands/inventar.ts +++ b/src/commands/inventar.ts @@ -18,7 +18,7 @@ import * as lootDataService from "@/service/lootData.js"; import { LootAttributeKindId } from "@/service/lootData.js"; import log from "@log"; -import { getFightInventoryEnriched } from "@/storage/fightinventory.js"; +import { getFightInventoryEnriched } from "@/storage/fightInventory.js"; export default class InventarCommand implements ApplicationCommand { name = "inventar"; @@ -39,7 +39,7 @@ export default class InventarCommand implements ApplicationCommand { .setDescription("Anzeige") .setRequired(false) .addChoices( - { name: "Kampfausrüstung", value: "fightinventory" }, + { name: "Kampfausrüstung", value: "fightInventory" }, { name: "Komplett", value: "all" }, ), ); @@ -59,7 +59,7 @@ export default class InventarCommand implements ApplicationCommand { } switch (type) { - case "fightinventory": + case "fightInventory": return await this.#createFightEmbed(context, interaction, user); case "all": return await this.#createLongEmbed(context, interaction, user); @@ -172,7 +172,7 @@ export default class InventarCommand implements ApplicationCommand { } async #createFightEmbed(context: BotContext, interaction: CommandInteraction, user: User) { - const fightinventory = await getFightInventoryEnriched(user.id); + const fightInventory = await getFightInventoryEnriched(user.id); const avatarURL = user.avatarURL(); const display = { title: `Kampfausrüstung von ${user.displayName}`, @@ -180,9 +180,9 @@ export default class InventarCommand implements ApplicationCommand { "Du kannst maximal eine Rüstung, eine Waffe und drei Items tragen. Wenn du kämpfst, setzt du die Items ein und verlierst diese, egal ob du gewinnst oder verlierst.", thumbnail: avatarURL ? { url: avatarURL } : undefined, fields: [ - { name: "Waffe", value: fightinventory.weapon?.itemInfo?.displayName ?? "Nix" }, - { name: "Rüstung", value: fightinventory.armor?.itemInfo?.displayName ?? "Nackt" }, - ...fightinventory.items.map(item => { + { name: "Waffe", value: fightInventory.weapon?.itemInfo?.displayName ?? "Nix" }, + { name: "Rüstung", value: fightInventory.armor?.itemInfo?.displayName ?? "Nackt" }, + ...fightInventory.items.map(item => { return { name: item.itemInfo?.displayName ?? "", value: "Hier sollten die buffs stehen", diff --git a/src/storage/db/model.ts b/src/storage/db/model.ts index a0cd1064..f3c21278 100644 --- a/src/storage/db/model.ts +++ b/src/storage/db/model.ts @@ -24,8 +24,8 @@ export interface Database { lootAttribute: LootAttributeTable; emote: EmoteTable; emoteUse: EmoteUseTable; - fighthistory: FightHistoryTable; - fightinventory: FightInventoryTable; + fightHistory: FightHistoryTable; + fightInventory: FightInventoryTable; } export type OneBasedMonth = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; diff --git a/src/storage/fighthistory.ts b/src/storage/fightHistory.ts similarity index 89% rename from src/storage/fighthistory.ts rename to src/storage/fightHistory.ts index 892db891..2cf33c64 100644 --- a/src/storage/fighthistory.ts +++ b/src/storage/fightHistory.ts @@ -5,7 +5,7 @@ import { FightScene } from "@/service/fightData.js"; export async function insertResult(userId: User["id"], boss: string, win: boolean, ctx = db()) { const lastWins = await getWinsForBoss(userId, boss); return await ctx - .insertInto("fighthistory") + .insertInto("fightHistory") .values({ userid: userId, result: win, @@ -17,7 +17,7 @@ export async function insertResult(userId: User["id"], boss: string, win: boolea export async function getWinsForBoss(userId: User["id"], boss: string, ctx = db()) { return await ctx - .selectFrom("fighthistory") + .selectFrom("fightHistory") .where("userid", "=", userId) .where("bossName", "=", boss) .where("result", "=", true) @@ -27,7 +27,7 @@ export async function getWinsForBoss(userId: User["id"], boss: string, ctx = db( export async function getLastFight(userId: User["id"], ctx = db()) { return await ctx - .selectFrom("fighthistory") + .selectFrom("fightHistory") .where("userid", "=", userId) .orderBy("createdAt desc") .selectAll() diff --git a/src/storage/fightinventory.ts b/src/storage/fightInventory.ts similarity index 93% rename from src/storage/fightinventory.ts rename to src/storage/fightInventory.ts index c0a3cbcd..4a3d082f 100644 --- a/src/storage/fightinventory.ts +++ b/src/storage/fightInventory.ts @@ -9,7 +9,7 @@ import { deleteLoot } from "@/storage/loot.js"; export async function getFightInventoryUnsorted(userId: User["id"], ctx = db()) { return await ctx - .selectFrom("fightinventory") + .selectFrom("fightInventory") .where("userid", "=", userId) .selectAll() .execute(); @@ -40,7 +40,7 @@ export async function getGameTemplate( export async function getItemsByType(userId: User["id"], fightItemType: string, ctx = db()) { return await ctx - .selectFrom("fightinventory") + .selectFrom("fightInventory") .where("userid", "=", userId) .where("equippedSlot", "=", fightItemType) .selectAll() @@ -54,7 +54,7 @@ export async function removeItemsAfterFight(userId: User["id"], ctx = db()) { await deleteLoot(item.lootId, ctx); } await ctx - .deleteFrom("fightinventory") + .deleteFrom("fightInventory") .where("userid", "=", userId) .where("equippedSlot", "=", "item") .execute(); @@ -83,11 +83,11 @@ export async function equipItembyLoot( ctx, ); unequippeditems.push(unequipitem?.displayName ?? String(equippedStuff[i].lootId)); - await ctx.deleteFrom("fightinventory").where("id", "=", equippedStuff[i].id).execute(); + await ctx.deleteFrom("fightInventory").where("id", "=", equippedStuff[i].id).execute(); } await ctx - .insertInto("fightinventory") + .insertInto("fightInventory") .values({ userid: userId, lootId: loot.id, diff --git a/src/storage/migrations/11-fightsystem.ts b/src/storage/migrations/11-fightsystem.ts index 2a8d0d04..15c42761 100644 --- a/src/storage/migrations/11-fightsystem.ts +++ b/src/storage/migrations/11-fightsystem.ts @@ -3,15 +3,16 @@ import { createUpdatedAtTrigger } from "@/storage/migrations/10-loot-attributes. export async function up(db: Kysely) { await db.schema - .createTable("fightinventory") + .createTable("fightInventory") .ifNotExists() .addColumn("id", "integer", c => c.primaryKey().autoIncrement()) .addColumn("userid", "text") .addColumn("lootId", "integer", c => c.references("loot.id")) .addColumn("equippedSlot", "text") .execute(); + await db.schema - .createTable("fighthistory") + .createTable("fightHistory") .ifNotExists() .addColumn("id", "integer", c => c.primaryKey().autoIncrement()) .addColumn("userid", "text", c => c.notNull()) @@ -21,7 +22,8 @@ export async function up(db: Kysely) { .addColumn("createdAt", "timestamp", c => c.notNull().defaultTo(sql`current_timestamp`)) .addColumn("updatedAt", "timestamp", c => c.notNull().defaultTo(sql`current_timestamp`)) .execute(); - await createUpdatedAtTrigger(db, "fighthistory"); + + await createUpdatedAtTrigger(db, "fightHistory"); } export async function down(_db: Kysely) {