import { randomUUID } from 'node:crypto' import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core' import type { UUID } from'@/application/types' import { BaseEntity } from'@/application/base/baseEntity' import { ItemType, ItemRarity } from'@/application/enums' import { CharacterItem } from'@/entities/characterItem' import { Sprite } from'@/entities/sprite' export class BaseItem extends BaseEntity { @PrimaryKey() id = randomUUID() @Property() name!: string @Property() description: string = '' @Enum(() => ItemType) itemType!: ItemType @Property() stackable = false @Enum(() => ItemRarity) rarity: ItemRarity = ItemRarity.COMMON @ManyToOne(() => Sprite) sprite?: Sprite @Property() createdAt = new Date() @Property() updatedAt = new Date() setId(id: UUID) { this.id = id return this } getId() { return this.id } setName(name: string) { this.name = name return this } getName() { return this.name } setDescription(description: string) { this.description = description return this } getDescription() { return this.description } setItemType(itemType: ItemType) { this.itemType = itemType return this } getItemType() { return this.itemType } setStackable(stackable: boolean) { this.stackable = stackable return this } getStackable() { return this.stackable } setRarity(rarity: ItemRarity) { this.rarity = rarity return this } getRarity() { return this.rarity } setSprite(sprite: Sprite) { this.sprite = sprite return this } getSprite() { return this.sprite } setCreatedAt(createdAt: Date) { this.createdAt = createdAt return this } getCreatedAt() { return this.createdAt } setUpdatedAt(updatedAt: Date) { this.updatedAt = updatedAt return this } getUpdatedAt() { return this.updatedAt } }