import { randomUUID } from 'node:crypto' import { Enum, ManyToOne, PrimaryKey } from '@mikro-orm/core' import { BaseEntity } from '#application/base/baseEntity' import { CharacterEquipmentSlotType } from '#application/enums' import { UUID } from '#application/types' import { Character } from '#entities/character' import { CharacterItem } from '#entities/characterItem' export class BaseCharacterEquipment extends BaseEntity { @PrimaryKey() id = randomUUID() @Enum(() => CharacterEquipmentSlotType) slot!: CharacterEquipmentSlotType @ManyToOne({ deleteRule: 'cascade' }) character!: Character @ManyToOne({ deleteRule: 'cascade' }) characterItem!: CharacterItem setId(id: UUID) { this.id = id return this } getId() { return this.id } setSlot(slot: CharacterEquipmentSlotType) { this.slot = slot return this } getSlot() { return this.slot } setCharacter(character: Character) { this.character = character return this } getCharacter() { return this.character } setCharacterItem(characterItem: CharacterItem) { this.characterItem = characterItem return this } getCharacterItem() { return this.characterItem } }