import { randomUUID } from 'node:crypto' import { Enum, ManyToOne, PrimaryKey } from '@mikro-orm/core' import type { UUID } from '@/application/types' import type { Character } from '@/entities/character' import type { CharacterItem } from '@/entities/characterItem' import { BaseEntity } from '@/application/base/baseEntity' import { CharacterEquipmentSlotType } from '@/application/enums' 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 } }