1
0
forked from noxious/server
2025-02-12 00:50:51 +01:00

118 lines
1.9 KiB
TypeScript

import { randomUUID } from 'node:crypto'
import { BaseEntity } from '@/application/base/baseEntity'
import { ItemRarity, ItemType } from '@/application/enums'
import type { UUID } from '@/application/types'
import { CharacterItem } from '@/entities/characterItem'
import { Sprite } from '@/entities/sprite'
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
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
}
}